From e0dfd9fa5b2e4eaa1d90cfddb5be4df333c9f4f1 Mon Sep 17 00:00:00 2001 From: girst Date: Sun, 13 Feb 2022 17:26:39 +0100 Subject: [PATCH] remove fetch_xml call from browse/playlist no need for this, since youtube now apparently returns this information for us. --- app/browse/__init__.py | 7 +------ app/common/innertube.py | 10 +++++++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/browse/__init__.py b/app/browse/__init__.py index 885adb9..bfebfbf 100644 --- a/app/browse/__init__.py +++ b/app/browse/__init__.py @@ -139,11 +139,6 @@ def playlist(): if not playlist_id: raise BadRequest("No playlist ID") - xmlfeed = fetch_xml("playlist_id", playlist_id) - if not xmlfeed: - raise NotFound("Unable to fetch playlist") - title, author, _, channel_id, _ = parse_xml(xmlfeed) - # if we don't have a continuation, we create parameters for page 1 manually: continuation = request.args.get('continuation') or \ make_playlist_params(playlist_id, 0) @@ -158,7 +153,7 @@ def playlist(): flash(f"2 {error}. Loading fallback.", 'error') return fallback_route() - rows, continuation = prepare_playlist(result) + title, author, channel_id, rows, continuation = prepare_playlist(result) return render_template('playlist.html.j2', title=title, diff --git a/app/common/innertube.py b/app/common/innertube.py index 29d4d74..9287132 100644 --- a/app/common/innertube.py +++ b/app/common/innertube.py @@ -109,7 +109,15 @@ def prepare_playlist(result): |G('continuation') ) - return list(filter(None, map(parse_playlist, unparsed))), more + meta = result|G('sidebar')|G('playlistSidebarRenderer')|G('items') + meta1 = meta|Select('playlistSidebarPrimaryInfoRenderer') + meta2 = meta|Select('playlistSidebarSecondaryInfoRenderer') \ + |G('videoOwner')|G('videoOwnerRenderer') + title = meta1|G('title')|G.text + author = meta2|G('title')|G.text + channel_id = meta2|G('navigationEndpoint')|G('browseEndpoint')|G('browseId') + + return title, author, channel_id, list(filter(None, map(parse_playlist, unparsed))), more def mkthumbs(thumbs): output = {str(e['height']): e['url'] for e in thumbs} -- 2.39.3