1
0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2024-11-21 23:27:29 +00:00

Support new channel layout

This commit is contained in:
Cadence Ember 2022-11-06 13:55:22 +13:00
parent 714f1030fb
commit 412b4934ed
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17

View File

@ -72,16 +72,16 @@ def extract_channel(ucid, second__path="user"):
latest_videos = [] latest_videos = []
tabs = yt_initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"] tabs = yt_initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]
try: try:
videos_tab = next(tab["tabRenderer"] for tab in tabs if tab["tabRenderer"]["title"] == "Videos") videos_tab = next(tab["tabRenderer"] for tab in tabs if tab.get("tabRenderer", {}).get("title") == "Videos")
tab_parts = videos_tab["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0] tab_parts = videos_tab["content"]
except StopIteration: except StopIteration:
tab_parts = {} tab_parts = {}
# check that the channel actually has videos - this may be replaced # check that the channel actually has videos - this may be replaced
# with messageRenderer.text.simpleText == "This channel has no videos." # with messageRenderer.text.simpleText == "This channel has no videos."
if "gridRenderer" in tab_parts: if "richGridRenderer" in tab_parts:
videos = ( videos = (
v["gridVideoRenderer"] for v in tab_parts["gridRenderer"]["items"] if "gridVideoRenderer" in v v["richItemRenderer"]["content"]["videoRenderer"] for v in tab_parts["richGridRenderer"]["contents"] if "richItemRenderer" in v
) )
for v in videos: for v in videos:
live = False live = False