From 4ded7fad9118bdba68f5a14371c51bcf63c5ff25 Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 29 Aug 2020 11:43:46 +0200 Subject: [PATCH] fix unavailable endcard test id: WYjgHLFZMa0 --- app/common/innertube.py | 1 + app/youtube/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/common/innertube.py b/app/common/innertube.py index 96d5fe4..88f1418 100644 --- a/app/common/innertube.py +++ b/app/common/innertube.py @@ -300,6 +300,7 @@ def parse_endcard(card): 'icons': mkthumbs(card['image']['thumbnails']), }} elif ctype == "VIDEO": + if not 'endpoint' in card: return None # title == "This video is unavailable." return {'type': ctype, 'content': { 'video_id': card['endpoint']['watchEndpoint']['videoId'], 'title': card['title']['simpleText'], diff --git a/app/youtube/__init__.py b/app/youtube/__init__.py index 2d016c8..a94f543 100644 --- a/app/youtube/__init__.py +++ b/app/youtube/__init__.py @@ -76,6 +76,7 @@ def watch(): extra = {'geolocked':'local=1', 'livestream':'raw=0'}.get(error,'') invidious_url = f"https://invidio.us/watch?v={video_id}&{extra}" errdetails = { + 'banned': "Instance is being rate limited.", 'malformed': "Video ID is invalid.", 'geolocked': "This video is geolocked.", 'livestream': "Livestreams not yet supported.", @@ -127,7 +128,7 @@ def watch(): return redirect(stream) else: if error and not metadata: # e.g. malformed, private/deleted video, ... - return errdetails,400 # TODO: nicer + return errdetails + f"
Try visiting an Invidious instance.",400 # TODO: nicer meta = prepare_metadata(metadata) with sqlite3.connect(cf['global']['database']) as conn: c = conn.cursor() -- 2.39.3