diff options
author | morpheus65535 <[email protected]> | 2020-12-03 16:43:21 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-03 16:43:21 -0500 |
commit | 11060792be15c4a35f9d755c5f7fbf8d87b5abf2 (patch) | |
tree | fb01cdbd3c7bdbaabbca9569f1d998843a4eaee2 | |
parent | 108540dbd98c525a87e51e3efb4afb0b785de553 (diff) | |
parent | 99a3abb24083711a575031671929503cdd9a5604 (diff) | |
download | bazarr-11060792be15c4a35f9d755c5f7fbf8d87b5abf2.tar.gz bazarr-11060792be15c4a35f9d755c5f7fbf8d87b5abf2.zip |
Merge pull request #1204 from vitiko98/sucha-new-api
Fix TypeError
-rw-r--r-- | libs/subliminal_patch/providers/sucha.py | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/libs/subliminal_patch/providers/sucha.py b/libs/subliminal_patch/providers/sucha.py index 5201db04d..463e5157d 100644 --- a/libs/subliminal_patch/providers/sucha.py +++ b/libs/subliminal_patch/providers/sucha.py @@ -103,42 +103,41 @@ class SuchaProvider(Provider): ) res.raise_for_status() result = res.json() - - try: - subtitles = [] - for i in result: - matches = set() + subtitles = [] + for i in result: + matches = set() + try: if ( video.title.lower() in i["title"].lower() or video.title.lower() in i["alt_title"].lower() ): matches.add("title") - if is_episode: - if ( - q["query"].lower() in i["title"].lower() - or q["query"].lower() in i["alt_title"].lower() - ): - matches.add("title") - matches.add("series") - matches.add("season") - matches.add("episode") - matches.add("year") - if str(i["year"]) == video.year: + except TypeError: + logger.debug("No subtitles found") + return [] + if is_episode: + if ( + q["query"].lower() in i["title"].lower() + or q["query"].lower() in i["alt_title"].lower() + ): + matches.add("title") + matches.add("series") + matches.add("season") + matches.add("episode") matches.add("year") - subtitles.append( - SuchaSubtitle( - language, - i["release"], - i["filename"], - str(i["id"]), - "episode" if is_episode else "movie", - matches, - ) + if str(i["year"]) == video.year: + matches.add("year") + subtitles.append( + SuchaSubtitle( + language, + i["release"], + i["filename"], + str(i["id"]), + "episode" if is_episode else "movie", + matches, ) - return subtitles - except KeyError: - logger.debug("No subtitles found") - return [] + ) + return subtitles def list_subtitles(self, video, languages): return self.query(languages, video) |