From efdbd0fdb24ada5f733d741ff0cf2c58f7815213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Mon, 13 Sep 2021 00:06:59 +0200 Subject: [PATCH] =?UTF-8?q?youtube:=20Don=E2=80=99t=20fail=20if=20default?= =?UTF-8?q?=20thumb=20size=20is=20missing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feedleware/youtube/feed.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/feedleware/youtube/feed.py b/feedleware/youtube/feed.py index cae5862..5c51d75 100644 --- a/feedleware/youtube/feed.py +++ b/feedleware/youtube/feed.py @@ -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")