From 46051646c620d7db37f0be56df8b9f20c1b42d83 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Thu, 30 Dec 2021 10:49:15 -0500 Subject: [PATCH] Improved opensubtitles.com server-side error handling --- libs/subliminal_patch/providers/opensubtitlescom.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/subliminal_patch/providers/opensubtitlescom.py b/libs/subliminal_patch/providers/opensubtitlescom.py index f5ee0f8e9..94e041ab7 100644 --- a/libs/subliminal_patch/providers/opensubtitlescom.py +++ b/libs/subliminal_patch/providers/opensubtitlescom.py @@ -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