1
0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2024-11-22 07:37:29 +00:00

Touch up Bopol's patch

This commit is contained in:
Cadence Ember 2021-01-17 14:55:57 +13:00
parent 6cc921c2dc
commit f1ddf66f50
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17

View File

@ -22,7 +22,7 @@ def extract_channel(ucid):
r.raise_for_status() r.raise_for_status()
yt_initial_data = extract_yt_initial_data(r.content.decode("utf8")) 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"] channel_metadata = yt_initial_data["metadata"]["channelMetadataRenderer"]
if header: if header:
@ -45,10 +45,9 @@ def extract_channel(ucid):
t["url"] = normalise_url_protocol(t["url"]) t["url"] = normalise_url_protocol(t["url"])
author_thumbnails = [] author_thumbnails = []
if "avatar" in header: avatar = header.get("avatar") or channel_metadata.get("avatar")
author_thumbnails = generate_full_author_thumbnails(header["avatar"]["thumbnails"]) if avatar:
elif "avatar" in channel_metadata: author_thumbnails = generate_full_author_thumbnails(avatar["thumbnails"])
author_thumbnails = generate_full_author_thumbnails(channel_metadata["avatar"]["thumbnails"])
latest_videos = [] latest_videos = []
tabs = yt_initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"] tabs = yt_initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]