add support for GUC proxy, move safeTraverse to ythdd_globals

This commit is contained in:
2025-02-28 00:56:13 +01:00
parent 019e47edd9
commit d1b9f90e7e
5 changed files with 27 additions and 12 deletions

View File

@@ -86,8 +86,21 @@ def translateLinks(link):
link = link.replace("https://i.ytimg.com/", config['general']['public_facing_url'])
link = link.replace("https://yt3.ggpht.com/", config['general']['public_facing_url'] + "ggpht/")
link = link.replace("https://yt3.googleusercontent.com/", config['general']['public_facing_url'] + "guc/")
return link
def getUptime():
return int(time.time()) - starttime
return int(time.time()) - starttime
def safeTraverse(obj: dict, path: list, default=None):
result = obj
try:
for x in path:
#print(f"traversing {result} with respect to {x}")
result = result[x]
except KeyError:
result = default
print(f"error reading: {' -> '.join(path)} - returning: {default}")
finally:
return result