[PATCH Second] Fix stacktrace on auto-generated "X - Topic" channels without Videos tab
Export this patch
From: Lomanic <lomanic@hotmail.fr>
See https://second.cadence.moe/api/v1/channels/UCr-iHMODX8D4a6MVQ_RtdQg as an example
---
extractors/channel.py | 2 + -
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/extractors/channel.py b/extractors/channel.py
index 787a2ec..bb84cc3 100644
--- a/extractors/channel.py
@@ -51,7 +51,7 @@ def extract_channel(ucid):
latest_videos = []
tabs = yt_initial_data["contents"]["twoColumnBrowseResultsRenderer"]["tabs"]
- 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["tabRenderer"]["title"] == "Videos"), {"content": {"sectionListRenderer": {"contents": [{"itemSectionRenderer": {"contents": [""]}}]}}})
tab_parts = videos_tab["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0]
# check that the channel actually has videos - this may be replaced
--
2.26.2
Hardcoding a JSON object in here looked like code smell, so I fixed
the core issue using different code in commit
c8b46999222cad3ffb76862474d1e127125ffac6. Thanks for bringing it to my
attention, though!