From c8b46999222cad3ffb76862474d1e127125ffac6 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 19 Feb 2021 01:17:54 +1300 Subject: [PATCH] Support topic channels with no videos tab https://second.cadence.moe/api/v1/channels/UCr-iHMODX8D4a6MVQ_RtdQg --- extractors/channel.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extractors/channel.py b/extractors/channel.py index f080597..8c78ec3 100644 --- a/extractors/channel.py +++ b/extractors/channel.py @@ -51,8 +51,11 @@ 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") - tab_parts = videos_tab["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0] + try: + videos_tab = next(tab["tabRenderer"] for tab in tabs if tab["tabRenderer"]["title"] == "Videos") + tab_parts = videos_tab["content"]["sectionListRenderer"]["contents"][0]["itemSectionRenderer"]["contents"][0] + except StopIteration: + tab_parts = {} # check that the channel actually has videos - this may be replaced # with messageRenderer.text.simpleText == "This channel has no videos."