From f1ddf66f50776702bde3d5ec2460e1f1162aa62d Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 17 Jan 2021 14:55:57 +1300 Subject: [PATCH] Touch up Bopol's patch --- extractors/channel.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/extractors/channel.py b/extractors/channel.py index 944ddf5..8468e93 100644 --- a/extractors/channel.py +++ b/extractors/channel.py @@ -22,7 +22,7 @@ def extract_channel(ucid): r.raise_for_status() yt_initial_data = extract_yt_initial_data(r.content.decode("utf8")) - header = yt_initial_data["header"]["c4TabbedHeaderRenderer"] if "c4TabbedHeaderRenderer" in yt_initial_data["header"] else [] + header = yt_initial_data["header"]["c4TabbedHeaderRenderer"] if "c4TabbedHeaderRenderer" in yt_initial_data["header"] else {} channel_metadata = yt_initial_data["metadata"]["channelMetadataRenderer"] if header: @@ -45,10 +45,9 @@ def extract_channel(ucid): t["url"] = normalise_url_protocol(t["url"]) author_thumbnails = [] - if "avatar" in header: - author_thumbnails = generate_full_author_thumbnails(header["avatar"]["thumbnails"]) - elif "avatar" in channel_metadata: - author_thumbnails = generate_full_author_thumbnails(channel_metadata["avatar"]["thumbnails"]) + avatar = header.get("avatar") or channel_metadata.get("avatar") + if avatar: + author_thumbnails = generate_full_author_thumbnails(avatar["thumbnails"]) latest_videos = [] tabs = yt_initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]