diff options
author | Vitiko <[email protected]> | 2022-01-01 19:18:40 -0400 |
---|---|---|
committer | Vitiko <[email protected]> | 2022-01-01 19:18:40 -0400 |
commit | 1261e91870a6e08b1942c7a2fbcb74b19d0da4c9 (patch) | |
tree | 4a6578f9c8724ea4f9d13cfe229eee9f2f496ec4 /libs | |
parent | b90dab03e89e03b73bfbe15741c8108fc0d2a806 (diff) | |
download | bazarr-1261e91870a6e08b1942c7a2fbcb74b19d0da4c9.tar.gz bazarr-1261e91870a6e08b1942c7a2fbcb74b19d0da4c9.zip |
Add MustGetBlacklisted exception for redundant download_subtitle calls
Diffstat (limited to 'libs')
-rw-r--r-- | libs/subliminal_patch/core.py | 6 | ||||
-rw-r--r-- | libs/subliminal_patch/exceptions.py | 18 |
2 files changed, 19 insertions, 5 deletions
diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index 9ed698c09..08415a3c5 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -25,6 +25,7 @@ from subliminal import ProviderError, refiner_manager from concurrent.futures import as_completed from .extensions import provider_registry +from .exceptions import MustGetBlacklisted from subliminal.exceptions import ServiceUnavailable, DownloadLimitExceeded from subliminal.score import compute_score as default_compute_score from subliminal.utils import hash_napiprojekt, hash_opensubtitles, hash_shooter, hash_thesubdb @@ -339,9 +340,8 @@ class SZProviderPool(ProviderPool): logger.error('Provider %r connection error', subtitle.provider_name) self.throttle_callback(subtitle.provider_name, e) - except rarfile.BadRarFile: - logger.error('Malformed RAR file from provider %r, skipping subtitle.', subtitle.provider_name) - logger.debug("RAR Traceback: %s", traceback.format_exc()) + except (rarfile.BadRarFile, MustGetBlacklisted) as e: + self.throttle_callback(subtitle.provider_name, e) return False except Exception as e: diff --git a/libs/subliminal_patch/exceptions.py b/libs/subliminal_patch/exceptions.py index 6cd73e769..8b931425a 100644 --- a/libs/subliminal_patch/exceptions.py +++ b/libs/subliminal_patch/exceptions.py @@ -5,15 +5,29 @@ from subliminal import ProviderError class TooManyRequests(ProviderError): """Exception raised by providers when too many requests are made.""" + pass + class APIThrottled(ProviderError): pass + class ParseResponseError(ProviderError): """Exception raised by providers when they are not able to parse the response.""" + pass + class IPAddressBlocked(ProviderError): - """Exception raised when providers block requests from IP Address.""" - pass
\ No newline at end of file + """Exception raised when providers block requests from IP Address.""" + + pass + + +class MustGetBlacklisted(ProviderError): + def __init__(self, id: str, media_type: str): + super().__init__() + + self.id = id + self.media_type = media_type |