mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-02-24 14:57:16 +08:00
Implemented PaymentRequired exception on opensubtitles.org that now requires VIP subscription.
This commit is contained in:
parent
7e650c2bab
commit
b3b4fef8c7
3 changed files with 14 additions and 4 deletions
|
@ -15,7 +15,7 @@ import re
|
|||
from subzero.language import Language
|
||||
from subliminal_patch.exceptions import TooManyRequests, APIThrottled, ParseResponseError, IPAddressBlocked, \
|
||||
MustGetBlacklisted, SearchLimitReached
|
||||
from subliminal.providers.opensubtitles import DownloadLimitReached
|
||||
from subliminal.providers.opensubtitles import DownloadLimitReached, PaymentRequired
|
||||
from subliminal.exceptions import DownloadLimitExceeded, ServiceUnavailable, AuthenticationError, ConfigurationError
|
||||
from subliminal import region as subliminal_cache_region
|
||||
from subliminal_patch.extensions import provider_registry
|
||||
|
@ -79,6 +79,7 @@ def provider_throttle_map():
|
|||
TooManyRequests: (datetime.timedelta(hours=3), "3 hours"),
|
||||
DownloadLimitExceeded: (datetime.timedelta(hours=6), "6 hours"),
|
||||
DownloadLimitReached: (datetime.timedelta(hours=6), "6 hours"),
|
||||
PaymentRequired: (datetime.timedelta(hours=12), "12 hours"),
|
||||
APIThrottled: (datetime.timedelta(seconds=15), "15 seconds"),
|
||||
ServiceUnavailable: (datetime.timedelta(hours=1), "1 hour"),
|
||||
},
|
||||
|
@ -458,13 +459,15 @@ def list_throttled_providers():
|
|||
|
||||
def reset_throttled_providers(only_auth_or_conf_error=False):
|
||||
for provider in list(tp):
|
||||
if only_auth_or_conf_error and tp[provider][0] not in ['AuthenticationError', 'ConfigurationError']:
|
||||
if only_auth_or_conf_error and tp[provider][0] not in ['AuthenticationError', 'ConfigurationError',
|
||||
'PaymentRequired']:
|
||||
continue
|
||||
del tp[provider]
|
||||
set_throttled_providers(str(tp))
|
||||
update_throttled_provider()
|
||||
if only_auth_or_conf_error:
|
||||
logging.info('BAZARR throttled providers have been reset (only AuthenticationError and ConfigurationError).')
|
||||
logging.info('BAZARR throttled providers have been reset (only AuthenticationError, ConfigurationError and '
|
||||
'PaymentRequired).')
|
||||
else:
|
||||
logging.info('BAZARR throttled providers have been reset.')
|
||||
|
||||
|
|
|
@ -237,6 +237,11 @@ class Unauthorized(OpenSubtitlesError, AuthenticationError):
|
|||
pass
|
||||
|
||||
|
||||
class PaymentRequired(OpenSubtitlesError):
|
||||
"""Exception raised when status is '402 Payment Required'."""
|
||||
pass
|
||||
|
||||
|
||||
class NoSession(OpenSubtitlesError, AuthenticationError):
|
||||
"""Exception raised when status is '406 No session'."""
|
||||
pass
|
||||
|
|
|
@ -15,7 +15,7 @@ from guessit import guessit
|
|||
from subliminal.exceptions import ConfigurationError, ServiceUnavailable
|
||||
from subliminal.providers.opensubtitles import OpenSubtitlesProvider as _OpenSubtitlesProvider,\
|
||||
OpenSubtitlesSubtitle as _OpenSubtitlesSubtitle, Episode, Movie, ServerProxy, Unauthorized, NoSession, \
|
||||
DownloadLimitReached, InvalidImdbid, UnknownUserAgent, DisabledUserAgent, OpenSubtitlesError
|
||||
DownloadLimitReached, InvalidImdbid, UnknownUserAgent, DisabledUserAgent, OpenSubtitlesError, PaymentRequired
|
||||
from .mixins import ProviderRetryMixin
|
||||
from subliminal.subtitle import fix_line_ending
|
||||
from subliminal_patch.providers import reinitialize_on_error
|
||||
|
@ -418,6 +418,8 @@ def checked(fn, raise_api_limit=False):
|
|||
|
||||
if status_code == 401:
|
||||
raise Unauthorized
|
||||
if status_code == 402:
|
||||
raise PaymentRequired
|
||||
if status_code == 406:
|
||||
raise NoSession
|
||||
if status_code == 407:
|
||||
|
|
Loading…
Reference in a new issue