From b4071f0af6d73976680bbbcb2655259ca000200e Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Mon, 18 Mar 2024 20:28:19 -0400 Subject: [PATCH] Fixed betaseries provider when series doesn't exist. #2431 --- .../subliminal_patch/providers/betaseries.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/custom_libs/subliminal_patch/providers/betaseries.py b/custom_libs/subliminal_patch/providers/betaseries.py index 4cd66401c..dfc92ccdd 100644 --- a/custom_libs/subliminal_patch/providers/betaseries.py +++ b/custom_libs/subliminal_patch/providers/betaseries.py @@ -83,6 +83,14 @@ class BetaSeriesProvider(Provider): logger.debug('Searching subtitles %r', params) res = self.session.get( server_url + 'episodes/display', params=params, timeout=10) + try: + if res.status_code == 400 and res.json()['errors'][0]['code'] == 4001: + # this is to catch no series found + return [] + elif res.status_code == 400 and res.json()['errors'][0]['code'] == 1001: + raise AuthenticationError("Invalid token provided") + except Exception: + pass res.raise_for_status() result = res.json() matches.add('tvdb_id') @@ -96,8 +104,14 @@ class BetaSeriesProvider(Provider): logger.debug('Searching subtitles %r', params) res = self.session.get( server_url + 'shows/episodes', params=params, timeout=10) - if res.status_code == 400: - raise AuthenticationError("Invalid token provided") + try: + if res.status_code == 400 and res.json()['errors'][0]['code'] == 4001: + # this is to catch no series found + return [] + elif res.status_code == 400 and res.json()['errors'][0]['code'] == 1001: + raise AuthenticationError("Invalid token provided") + except Exception: + pass res.raise_for_status() result = res.json() matches.add('series_tvdb_id')