From 85af031c26c9b36d4665d3e40c4594456a0afc98 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 17 Sep 2021 10:47:01 +0200 Subject: [PATCH] Empty torrent responses can sometimes include the objects as an empty list instead of an empty dict --- platypush/plugins/torrent/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/torrent/__init__.py b/platypush/plugins/torrent/__init__.py index db9e5aa53..c186fc118 100644 --- a/platypush/plugins/torrent/__init__.py +++ b/platypush/plugins/torrent/__init__.py @@ -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'),