From 7c3d3531e8b510be36cae69b325c31cb893f112e Mon Sep 17 00:00:00 2001 From: metalune Date: Sat, 31 Jul 2021 12:05:28 +0200 Subject: [PATCH] Add check for statuscode 200 when fetching frontpage videos --- main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 5e2a348..5387c7a 100644 --- a/main.py +++ b/main.py @@ -191,6 +191,7 @@ def find_subscription(request): if identifier.startswith('@'): # Strip @ from identifier return identifier[1:] + if identifier.startswith('http'): identifier = identifier[4:] # HTTPS? @@ -206,6 +207,7 @@ def find_subscription(request): # Just check there's an @ in there and it should be fine if '@' in identifier: return identifier + # No match was found, we don't understand this URL print("[WARN] Identifier not understood from local subscriptions:\n%s" % request) return '' @@ -214,8 +216,12 @@ def find_subscription(request): def get_subscriptions_channels_videos(limit=12): latest = [] for sub in get_subscriptions_channels(): - channel_latest = get_latest_channel_videos(sub)["data"] - latest.extend(channel_latest) + result = get_latest_channel_videos(sub) + if result["status"] == 200: + channel_latest = get_latest_channel_videos(sub)["data"] + latest.extend(channel_latest) + else: + print("[WARN] Unable to get content from " + sub) latest.sort(key = lambda vid: dateutil.isoparse(vid["createdAt"]), reverse=True) return latest[0:limit]