Compare commits

..

2 Commits

Author SHA1 Message Date
7086177a58 fix: make safeTraverse handle IndexErrors 2025-09-14 01:06:40 +02:00
dc8009db23 chore: update innertube client strings 2025-09-13 04:05:25 +02:00
2 changed files with 6 additions and 6 deletions

View File

@@ -81,7 +81,7 @@ stage3_headers = {
"Sec-Fetch-Mode": "navigate", "Sec-Fetch-Mode": "navigate",
"Content-Type": "application/json", "Content-Type": "application/json",
"X-Youtube-Client-Name": "1", "X-Youtube-Client-Name": "1",
"X-Youtube-Client-Version": "2.20250829.01.00", "X-Youtube-Client-Version": "2.20250911.00.00",
"Origin": "https://www.youtube.com", "Origin": "https://www.youtube.com",
"Accept-Encoding": "gzip, deflate, br", "Accept-Encoding": "gzip, deflate, br",
"Cookie": "PREF=hl=en&tz=UTC; SOCS=CAI" "Cookie": "PREF=hl=en&tz=UTC; SOCS=CAI"
@@ -93,7 +93,7 @@ stage3_body = {
"client": "client":
{ {
"clientName": "WEB", "clientName": "WEB",
"clientVersion": "2.20250829.01.00", "clientVersion": "2.20250911.00.00",
"hl": "en", "hl": "en",
"timeZone": "UTC", "timeZone": "UTC",
"utcOffsetMinutes": 0 "utcOffsetMinutes": 0
@@ -113,7 +113,7 @@ web_context_dict = {
'deviceModel': '', 'deviceModel': '',
'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0) Gecko/20100101 Firefox/142.0,gzip(gfe)', 'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0) Gecko/20100101 Firefox/142.0,gzip(gfe)',
'clientName': 'WEB', 'clientName': 'WEB',
'clientVersion': '2.20250829.01.00', 'clientVersion': '2.20250911.00.00',
'osName': 'Windows', 'osName': 'Windows',
'osVersion': '10.0', 'osVersion': '10.0',
'screenPixelDensity': 2, 'screenPixelDensity': 2,

View File

@@ -95,15 +95,15 @@ def translateLinks(link):
def getUptime(): def getUptime():
return int(time.time()) - starttime return int(time.time()) - starttime
def safeTraverse(obj: dict, path: list, default=None): def safeTraverse(obj: dict, path: list, default=None, quiet: bool = False):
result = obj result = obj
try: try:
for x in path: for x in path:
#print(f"traversing {result} with respect to {x}") #print(f"traversing {result} with respect to {x}")
result = result[x] result = result[x]
except (KeyError, TypeError): except (KeyError, TypeError, IndexError):
result = default result = default
print(f"error reading: {' -> '.join(path)} - returning: {default}") if not quiet: print(f"error reading: {' -> '.join(path)} - returning: {default}")
finally: finally:
return result return result