From 14548b7166cb224dbe8146089960e0f21de47ab2 Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 20 Nov 2021 14:27:36 +0100 Subject: [PATCH] tell the user to log in to view livestreams/geolocked videos, if applicable. --- app/youtube/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/youtube/__init__.py b/app/youtube/__init__.py index aecde45..6bb528f 100644 --- a/app/youtube/__init__.py +++ b/app/youtube/__init__.py @@ -79,20 +79,25 @@ def watch(): video_id = request.args.get('v') video_url, stream_map, metadata, error, errdetails = get_video_info(video_id) + proxy_on = getattr(g, 'proxy_on', None) + proxy_msg = { + False: "Log in to use proxy.", # proxy for logged-in users only + None: "", # proxy disabled globally + True: "", # proxy is available to this user + }[proxy_on] extra = {'geolocked':'local=1', 'livestream':'raw=0'}.get(error,'') invidious_url = f"https://invidious.snopyta.org/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 supported on this instance.", + 'geolocked': f"This video is geolocked. {proxy_msg}", + 'livestream': f"Livestreams disabled. {proxy_msg}", 'agegated': "Unable to bypass age-restriction.", 'no-url': "No muxed stream available.", 'exhausted': errdetails or "Couldn't extract video URLs.", 'player': errdetails, }.get(error, error) - proxy_on = getattr(g, 'proxy_on', False) # if the video is geolocked, and the proxy is enabled, we can still play # it, if the video is available in the instance server's region: if error == 'geolocked' and video_url and proxy_on: -- 2.39.3