major rework of ythdd.py, new method for setting config in ythdd_globals.py

- slightly modified config, api keys now have the value "CHANGEME"
- requirements.txt has new dependency, flask apscheduler
- ythdd.py has been reworked, support for argument parsing has been added, code is now split into functions
- ythdd_api_v1.py features real uptime as well
- ythdd_db.py is no longer dependent on ythdd_globals.py
- ythdd_globals.py has a method for setting config and getting it from configfile variable
This commit is contained in:
2024-12-12 11:02:11 +01:00
parent c60f7db698
commit 1e4b05c33b
7 changed files with 161 additions and 60 deletions

View File

@@ -20,8 +20,10 @@ def stub_hello():
def stats():
data_to_send = {
"starttime": ythdd_globals.starttime,
# TODO: include yt-dlp version
"start_time": ythdd_globals.starttime,
"uptime": ythdd_globals.getUptime(),
"real_uptime": ythdd_globals.realUptime,
"total_api_requests": ythdd_globals.apiRequests,
"failed_api_requests": ythdd_globals.apiFailedRequests,
"outside_api_requests": ythdd_globals.outsideApiHits,
@@ -29,6 +31,12 @@ def stats():
}
return 200, "OK", data_to_send
def videoIdSanityCheck(videoId: str):
if len(videId) != 11:
incrementBadRequests()
return 400, f'error: bad request. wrong videoId: {videoId} is {len(videoId)} characters long, but should be 11.', []
# elif... check
def hot(data):
#print(data)
# if we are given not enough data to work with, return bad request.
@@ -119,7 +127,7 @@ def hot(data):
case _:
incrementBadRequests()
return notImplemented(data)
return notImplemented([data[1]]) # workaround before notImplemented is reworked
def lookup(data):
match data[0]: