youtube: Don’t fail if default thumb size is missing

This commit is contained in:
Mattéo Delabre 2021-09-13 00:06:59 +02:00
parent 527077fab4
commit efdbd0fdb2
Signed by: matteo
GPG Key ID: AE3FBD02DC583ABB
1 changed files with 5 additions and 1 deletions

View File

@ -31,7 +31,11 @@ def construct_rss(client: APIClient, channel_id: str) -> str:
video_id = video["resourceId"]["videoId"]
link = f"https://www.youtube.com/watch?v={video_id}"
thumbnail = video["thumbnails"]["standard"]["url"]
thumbnail = ""
for size in ("standard", "maxres", *video["thumbnails"].keys()):
if size in video["thumbnails"]:
thumbnail = video["thumbnails"][size]["url"]
item["guid"] = video["resourceId"]["videoId"]
item["title"] = video.get("title", "Untitled Video")