feat: check for playback errors and return them in invidious api fashion
This commit is contained in:
@@ -93,19 +93,21 @@ def trending():
|
|||||||
def popular():
|
def popular():
|
||||||
return send(200, [{}])
|
return send(200, [{}])
|
||||||
|
|
||||||
def getError(idata: dict):
|
def getError(wdata: dict):
|
||||||
unknown_error = {"status": "Unknown error", "reason": "This is a generic ythdd error."}
|
unknown_error = {"status": "Unknown error", "reason": "This is a generic ythdd error."}
|
||||||
error = ""
|
error = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
playabilityStatus = safeTraverse(idata, ['stage1', 'playabilityStatus'], default=unknown_error)
|
playabilityStatus = safeTraverse(wdata, ['ec1', 'playabilityStatus'], default=unknown_error)
|
||||||
print(playabilityStatus)
|
# check for error
|
||||||
|
if safeTraverse(playabilityStatus, ["status"], default="error") == "OK":
|
||||||
|
return None # no error? return None
|
||||||
error += f"({playabilityStatus['status']}) {playabilityStatus['reason']}"
|
error += f"({playabilityStatus['status']}) {playabilityStatus['reason']}"
|
||||||
except:
|
except:
|
||||||
error += f"Generic error"
|
error += f"Generic error"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
errorScreen = safeTraverse(idata, ['stage1', 'playabilityStatus', 'errorScreen', 'playerErrorMessageRenderer', 'subreason', 'runs'], default=[])
|
errorScreen = safeTraverse(wdata, ['ec1', 'playabilityStatus', 'errorScreen', 'playerErrorMessageRenderer', 'subreason', 'runs'], default=[])
|
||||||
error += " - "
|
error += " - "
|
||||||
for x in errorScreen:
|
for x in errorScreen:
|
||||||
error += f"{x['text']} "
|
error += f"{x['text']} "
|
||||||
@@ -349,9 +351,14 @@ def videos(data):
|
|||||||
else:
|
else:
|
||||||
del ythdd_globals.video_cache[data[3]]
|
del ythdd_globals.video_cache[data[3]]
|
||||||
|
|
||||||
ydata = ythdd_extractor.extract(data[3], manifest_fix=True)
|
|
||||||
wdata = ythdd_extractor.WEBextractSinglePage(data[3])
|
wdata = ythdd_extractor.WEBextractSinglePage(data[3])
|
||||||
|
|
||||||
|
error = getError(wdata)
|
||||||
|
if error is not None:
|
||||||
|
return send(500, {"status": "error", "error": error})
|
||||||
|
|
||||||
|
ydata = ythdd_extractor.extract(data[3], manifest_fix=True)
|
||||||
|
|
||||||
#return send(200, {'ydata': ydata, 'wdata': wdata})
|
#return send(200, {'ydata': ydata, 'wdata': wdata})
|
||||||
#return send(200, {'idata': idata, 'wdata': wdata})
|
#return send(200, {'idata': idata, 'wdata': wdata})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user