Improved opensubtitles.com server-side error handling

pull/1656/head
morpheus65535 3 years ago
parent 6e52ce2ecf
commit 46051646c6

@ -177,7 +177,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
raise AuthenticationError('Login failed: {}'.format(r.reason))
elif r.status_code == 429:
raise TooManyRequests()
elif r.status_code == 503:
elif 500 <= r.status_code <= 599:
raise ProviderError(r.reason)
else:
raise ProviderError('Bad status code: {}'.format(r.status_code))
@ -207,11 +207,11 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
if results.status_code == 429:
raise TooManyRequests()
elif results.status_code == 503:
elif 500 <= results.status_code <= 599:
raise ProviderError(results.reason)
elif results.status_code == 429:
raise TooManyRequests()
elif results.status_code == 503:
elif 500 <= results.status_code <= 599:
raise ProviderError(results.reason)
# deserialize results
@ -304,7 +304,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
if res.status_code == 429:
raise TooManyRequests()
elif res.status_code == 503:
elif 500 <= res.status_code <= 599:
raise ProviderError(res.reason)
subtitles = []
@ -378,7 +378,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
raise TooManyRequests()
elif res.status_code == 406:
raise DownloadLimitExceeded("Daily download limit reached")
elif res.status_code == 503:
elif 500 <= res.status_code <= 599:
raise ProviderError(res.reason)
else:
try:
@ -392,7 +392,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
raise TooManyRequests()
elif res.status_code == 406:
raise DownloadLimitExceeded("Daily download limit reached")
elif res.status_code == 503:
elif 500 <= res.status_code <= 599:
raise ProviderError(res.reason)
subtitle_content = r.content

Loading…
Cancel
Save