Add check for statuscode 200 when fetching frontpage videos

This commit is contained in:
metalune 2021-07-31 12:05:28 +02:00
parent 287b2cdbc4
commit 7c3d3531e8

10
main.py
View file

@ -191,6 +191,7 @@ def find_subscription(request):
if identifier.startswith('@'): if identifier.startswith('@'):
# Strip @ from identifier # Strip @ from identifier
return identifier[1:] return identifier[1:]
if identifier.startswith('http'): if identifier.startswith('http'):
identifier = identifier[4:] identifier = identifier[4:]
# HTTPS? # HTTPS?
@ -206,6 +207,7 @@ def find_subscription(request):
# Just check there's an @ in there and it should be fine # Just check there's an @ in there and it should be fine
if '@' in identifier: if '@' in identifier:
return identifier return identifier
# No match was found, we don't understand this URL # No match was found, we don't understand this URL
print("[WARN] Identifier not understood from local subscriptions:\n%s" % request) print("[WARN] Identifier not understood from local subscriptions:\n%s" % request)
return '' return ''
@ -214,8 +216,12 @@ def find_subscription(request):
def get_subscriptions_channels_videos(limit=12): def get_subscriptions_channels_videos(limit=12):
latest = [] latest = []
for sub in get_subscriptions_channels(): for sub in get_subscriptions_channels():
channel_latest = get_latest_channel_videos(sub)["data"] result = get_latest_channel_videos(sub)
latest.extend(channel_latest) 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) latest.sort(key = lambda vid: dateutil.isoparse(vid["createdAt"]), reverse=True)
return latest[0:limit] return latest[0:limit]