Empty torrent responses can sometimes include the objects as an empty list instead of an empty dict

This commit is contained in:
Fabio Manganiello 2021-09-17 10:47:01 +02:00
parent 7b8938cb12
commit 85af031c26

View file

@ -190,7 +190,7 @@ class TorrentPlugin(Plugin):
'url': item.get('url'),
}
for result in results
for (lang, items) in result.get('torrents', {}).items()
for (lang, items) in (result.get('torrents', {}) or {}).items()
if not language or language == lang
for (quality, item) in items.items()
if quality != '0'
@ -232,7 +232,7 @@ class TorrentPlugin(Plugin):
}
for result in results
for episode in result.get('episodes', [])
for quality, item in episode.get('torrents', {}).items()
for quality, item in (episode.get('torrents', {}) or {}).items()
if quality != '0'
], key=lambda item: '{series}.{quality}.{season:02d}.{episode:02d}'.format(
series=item.get('series'), quality=item.get('quality'),