[youtube] Don't fail if some items in the response have missing attrs.

This commit is contained in:
Fabio Manganiello 2023-11-05 22:12:21 +01:00
parent daa93f5994
commit 6411688e65
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -57,10 +57,10 @@ class YoutubePlugin(Plugin):
results = [ results = [
{ {
"url": "https://www.youtube.com" + item["url"], "url": "https://www.youtube.com" + item["url"],
"title": item["title"], "title": item.get("title", '[No title]'),
"image": item["thumbnail"], "image": item.get("thumbnail"),
"duration": item["duration"], "duration": item.get("duration", 0),
"description": item["shortDescription"], "description": item.get("shortDescription"),
} }
for item in rs.json().get("items", []) for item in rs.json().get("items", [])
] ]