summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2023-12-28 16:03:23 -0500
committermorpheus65535 <[email protected]>2023-12-28 16:03:23 -0500
commitcb71b11fd2332a5175e9cb4d87cd26faf98d1f42 (patch)
treeb8e4c888f2e708616e38bf13addfe0d4be2d99be
parent9379d1b7f843e46b16483a0d54a17b4453b21590 (diff)
downloadbazarr-1.4.1-beta.9.tar.gz
bazarr-1.4.1-beta.9.zip
Improved error handling for betaseries provider.v1.4.1-beta.9
-rw-r--r--libs/subliminal_patch/providers/betaseries.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/libs/subliminal_patch/providers/betaseries.py b/libs/subliminal_patch/providers/betaseries.py
index ea4d248e8..a11179406 100644
--- a/libs/subliminal_patch/providers/betaseries.py
+++ b/libs/subliminal_patch/providers/betaseries.py
@@ -1,20 +1,16 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
-import json
import logging
import os
-import re
import io
import rarfile
import zipfile
-from babelfish import language_converters
from guessit import guessit
from requests import Session
-from subzero.language import Language
-from subliminal import Movie, Episode, ProviderError, __short_version__
-from subliminal.exceptions import AuthenticationError, ConfigurationError, DownloadLimitExceeded, ProviderError
+from subliminal import Episode
+from subliminal.exceptions import AuthenticationError, ConfigurationError
from subliminal_patch.subtitle import Subtitle, guess_matches
from subliminal.subtitle import fix_line_ending, SUBTITLE_EXTENSIONS
from subliminal_patch.providers import Provider
@@ -77,7 +73,6 @@ class BetaSeriesProvider(Provider):
def query(self, languages, video):
# query the server
- result = None
self.video = video
matches = set()
if video.tvdb_id:
@@ -101,6 +96,8 @@ 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")
res.raise_for_status()
result = res.json()
matches.add('series_tvdb_id')
@@ -115,9 +112,9 @@ class BetaSeriesProvider(Provider):
# parse the subtitles
subtitles = []
- if 'episode' in result:
+ if 'episode' in result and 'subtitles' in result['episode']:
subs = result['episode']['subtitles']
- elif 'episodes' in result:
+ elif 'episodes' in result and len(result['episodes'] and 'subtitles' in result['episodes'][0]):
subs = result['episodes'][0]['subtitles']
else:
return []