Fixed opensubtitles.com exception when invalid JSON is returned from provider. #1572

pull/1581/head
morpheus65535 3 years ago
parent ff8865555a
commit 95a509cf23

@ -43,7 +43,7 @@ def fix_tv_naming(title):
def fix_movie_naming(title):
return fix_inconsistent_naming(title, {
}, True)
}, True)
class OpenSubtitlesComSubtitle(Subtitle):
@ -299,6 +299,8 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
try:
result = res.json()
if 'data' not in result:
raise ValueError
except ValueError:
raise ProviderError('Invalid JSON returned by provider')
else:
@ -323,19 +325,19 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
if len(item['attributes']['files']):
subtitle = OpenSubtitlesComSubtitle(
language=Language.fromietf(item['attributes']['language']),
forced=item['attributes']['foreign_parts_only'],
hearing_impaired=item['attributes']['hearing_impaired'],
page_link=item['attributes']['url'],
file_id=item['attributes']['files'][0]['file_id'],
releases=item['attributes']['release'],
uploader=item['attributes']['uploader']['name'],
title=item['attributes']['feature_details']['movie_name'],
year=item['attributes']['feature_details']['year'],
season=season_number,
episode=episode_number,
hash_matched=moviehash_match
)
language=Language.fromietf(item['attributes']['language']),
forced=item['attributes']['foreign_parts_only'],
hearing_impaired=item['attributes']['hearing_impaired'],
page_link=item['attributes']['url'],
file_id=item['attributes']['files'][0]['file_id'],
releases=item['attributes']['release'],
uploader=item['attributes']['uploader']['name'],
title=item['attributes']['feature_details']['movie_name'],
year=item['attributes']['feature_details']['year'],
season=season_number,
episode=episode_number,
hash_matched=moviehash_match
)
subtitle.get_matches(self.video)
subtitles.append(subtitle)

Loading…
Cancel
Save