mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-04 05:52:24 +08:00
Improved opensubtitles.com server-side error handling
This commit is contained in:
parent
6e52ce2ecf
commit
46051646c6
1 changed files with 6 additions and 6 deletions
|
@ -177,7 +177,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
|
||||||
raise AuthenticationError('Login failed: {}'.format(r.reason))
|
raise AuthenticationError('Login failed: {}'.format(r.reason))
|
||||||
elif r.status_code == 429:
|
elif r.status_code == 429:
|
||||||
raise TooManyRequests()
|
raise TooManyRequests()
|
||||||
elif r.status_code == 503:
|
elif 500 <= r.status_code <= 599:
|
||||||
raise ProviderError(r.reason)
|
raise ProviderError(r.reason)
|
||||||
else:
|
else:
|
||||||
raise ProviderError('Bad status code: {}'.format(r.status_code))
|
raise ProviderError('Bad status code: {}'.format(r.status_code))
|
||||||
|
@ -207,11 +207,11 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
|
||||||
|
|
||||||
if results.status_code == 429:
|
if results.status_code == 429:
|
||||||
raise TooManyRequests()
|
raise TooManyRequests()
|
||||||
elif results.status_code == 503:
|
elif 500 <= results.status_code <= 599:
|
||||||
raise ProviderError(results.reason)
|
raise ProviderError(results.reason)
|
||||||
elif results.status_code == 429:
|
elif results.status_code == 429:
|
||||||
raise TooManyRequests()
|
raise TooManyRequests()
|
||||||
elif results.status_code == 503:
|
elif 500 <= results.status_code <= 599:
|
||||||
raise ProviderError(results.reason)
|
raise ProviderError(results.reason)
|
||||||
|
|
||||||
# deserialize results
|
# deserialize results
|
||||||
|
@ -304,7 +304,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
|
||||||
if res.status_code == 429:
|
if res.status_code == 429:
|
||||||
raise TooManyRequests()
|
raise TooManyRequests()
|
||||||
|
|
||||||
elif res.status_code == 503:
|
elif 500 <= res.status_code <= 599:
|
||||||
raise ProviderError(res.reason)
|
raise ProviderError(res.reason)
|
||||||
|
|
||||||
subtitles = []
|
subtitles = []
|
||||||
|
@ -378,7 +378,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
|
||||||
raise TooManyRequests()
|
raise TooManyRequests()
|
||||||
elif res.status_code == 406:
|
elif res.status_code == 406:
|
||||||
raise DownloadLimitExceeded("Daily download limit reached")
|
raise DownloadLimitExceeded("Daily download limit reached")
|
||||||
elif res.status_code == 503:
|
elif 500 <= res.status_code <= 599:
|
||||||
raise ProviderError(res.reason)
|
raise ProviderError(res.reason)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -392,7 +392,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
|
||||||
raise TooManyRequests()
|
raise TooManyRequests()
|
||||||
elif res.status_code == 406:
|
elif res.status_code == 406:
|
||||||
raise DownloadLimitExceeded("Daily download limit reached")
|
raise DownloadLimitExceeded("Daily download limit reached")
|
||||||
elif res.status_code == 503:
|
elif 500 <= res.status_code <= 599:
|
||||||
raise ProviderError(res.reason)
|
raise ProviderError(res.reason)
|
||||||
|
|
||||||
subtitle_content = r.content
|
subtitle_content = r.content
|
||||||
|
|
Loading…
Reference in a new issue