From 7f599fe70bf084f438ba82241cee637b3948c372 Mon Sep 17 00:00:00 2001 From: girst Date: Mon, 20 Jul 2020 13:30:45 +0200 Subject: [PATCH] Revert "use all muxed stream sources" for breaking edge-cases specifically, geolocked video handling This reverts commit e38be6698b853bcdeccfb2f664a276b6f669e4b4. --- app/common/common.py | 9 +++------ app/youtube/__init__.py | 6 +++--- app/youtube/templates/watch.html.j2 | 4 +--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/common/common.py b/app/common/common.py index 4b73f79..90b094b 100644 --- a/app/common/common.py +++ b/app/common/common.py @@ -204,15 +204,12 @@ def get_video_info(video_id, sts=0, algo=""): formats[i]['url'] = unscramble(cipher, algo) # todo: check if we have urls or try again - muxed = [ - f['url'] for f in - sorted(formats, key=lambda k: k['height'], reverse=True) - ] + url = sorted(formats, key=lambda k: k['height'], reverse=True)[0]['url'] - if 'gcr' in parse_qs(muxed[0]): + if 'gcr' in parse_qs(url): return None, metadata, 'geolocked', None - return muxed, metadata, None, None + return url, metadata, None, None else: return None, metadata, 'exhausted', player_error diff --git a/app/youtube/__init__.py b/app/youtube/__init__.py index 6b4cff8..046ae11 100644 --- a/app/youtube/__init__.py +++ b/app/youtube/__init__.py @@ -67,7 +67,7 @@ def watch(): video_id = request.args.get('v') sts, algo = get_cipher() - muxed, metadata, error, errdetails = get_video_info(video_id, sts, algo) + video_url, metadata, error, errdetails = get_video_info(video_id, sts, algo) extra = {'geolocked':'local=1', 'livestream':'raw=0'}.get(error,'') invidious_url = f"https://invidio.us/watch?v={video_id}&{extra}&raw=1" @@ -86,7 +86,7 @@ def watch(): return f"{msg}\n\nRedirecting to Invidious.", 502, { 'Refresh': f'2; URL={invidious_url}', **plaintextheaders} - return redirect(muxed[0], code=307) + return redirect(video_url, code=307) elif show == "json": if error and not metadata: return {'error': True, error: errdetails}, 400 # TODO: better (test _CpR4o81XQc) @@ -105,7 +105,7 @@ def watch(): ))""", (meta['channel_id'], token, video_id, token)) (is_subscribed, is_pinned) = c.fetchone() return render_template('watch.html.j2', - video_id=video_id, video_urls=muxed, + video_id=video_id, video_url=video_url, video_error=error, errdetails=errdetails, invidious_url=invidious_url, is_pinned=is_pinned, is_subscribed=is_subscribed, **meta) diff --git a/app/youtube/templates/watch.html.j2 b/app/youtube/templates/watch.html.j2 index 4586c55..2c06a9c 100644 --- a/app/youtube/templates/watch.html.j2 +++ b/app/youtube/templates/watch.html.j2 @@ -10,12 +10,10 @@ {% include 'messages.inc.j2' %}
-{% if video_urls|length %} +{% if video_url %}