mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-22 22:10:42 +00:00
Improved subtitles providers settings to reset Authentication or Configuration error throttling while saving.
This commit is contained in:
parent
333c6b23f5
commit
faa9566431
2 changed files with 27 additions and 3 deletions
|
@ -391,6 +391,7 @@ def save_settings(settings_items):
|
|||
undefined_audio_track_default_changed = False
|
||||
undefined_subtitles_track_default_changed = False
|
||||
audio_tracks_parsing_changed = False
|
||||
reset_providers = False
|
||||
|
||||
# Subzero Mods
|
||||
update_subzero = False
|
||||
|
@ -491,46 +492,62 @@ def save_settings(settings_items):
|
|||
|
||||
if key == 'settings-addic7ed-username':
|
||||
if key != settings.addic7ed.username:
|
||||
reset_providers = True
|
||||
region.delete('addic7ed_data')
|
||||
elif key == 'settings-addic7ed-password':
|
||||
if key != settings.addic7ed.password:
|
||||
reset_providers = True
|
||||
region.delete('addic7ed_data')
|
||||
|
||||
if key == 'settings-legendasdivx-username':
|
||||
if key != settings.legendasdivx.username:
|
||||
reset_providers = True
|
||||
region.delete('legendasdivx_cookies2')
|
||||
elif key == 'settings-legendasdivx-password':
|
||||
if key != settings.legendasdivx.password:
|
||||
reset_providers = True
|
||||
region.delete('legendasdivx_cookies2')
|
||||
|
||||
if key == 'settings-opensubtitles-username':
|
||||
if key != settings.opensubtitles.username:
|
||||
reset_providers = True
|
||||
region.delete('os_token')
|
||||
elif key == 'settings-opensubtitles-password':
|
||||
if key != settings.opensubtitles.password:
|
||||
reset_providers = True
|
||||
region.delete('os_token')
|
||||
|
||||
if key == 'settings-opensubtitlescom-username':
|
||||
if key != settings.opensubtitlescom.username:
|
||||
reset_providers = True
|
||||
region.delete('oscom_token')
|
||||
elif key == 'settings-opensubtitlescom-password':
|
||||
if key != settings.opensubtitlescom.password:
|
||||
reset_providers = True
|
||||
region.delete('oscom_token')
|
||||
|
||||
if key == 'settings-subscene-username':
|
||||
if key != settings.subscene.username:
|
||||
reset_providers = True
|
||||
region.delete('subscene_cookies2')
|
||||
elif key == 'settings-subscene-password':
|
||||
if key != settings.subscene.password:
|
||||
reset_providers = True
|
||||
region.delete('subscene_cookies2')
|
||||
|
||||
if key == 'settings-titlovi-username':
|
||||
if key != settings.titlovi.username:
|
||||
reset_providers = True
|
||||
region.delete('titlovi_token')
|
||||
elif key == 'settings-titlovi-password':
|
||||
if key != settings.titlovi.password:
|
||||
reset_providers = True
|
||||
region.delete('titlovi_token')
|
||||
|
||||
if reset_providers:
|
||||
from .get_providers import reset_throttled_providers
|
||||
reset_throttled_providers(only_auth_or_conf_error=True)
|
||||
|
||||
if settings_keys[0] == 'settings':
|
||||
settings[settings_keys[1]][settings_keys[2]] = str(value)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import requests
|
|||
from subliminal_patch.exceptions import TooManyRequests, APIThrottled, ParseResponseError, IPAddressBlocked, \
|
||||
MustGetBlacklisted, SearchLimitReached
|
||||
from subliminal.providers.opensubtitles import DownloadLimitReached
|
||||
from subliminal.exceptions import DownloadLimitExceeded, ServiceUnavailable
|
||||
from subliminal.exceptions import DownloadLimitExceeded, ServiceUnavailable, AuthenticationError, ConfigurationError
|
||||
from subliminal import region as subliminal_cache_region
|
||||
from subliminal_patch.extensions import provider_registry
|
||||
|
||||
|
@ -76,6 +76,8 @@ def provider_throttle_map():
|
|||
APIThrottled: (datetime.timedelta(seconds=15), "15 seconds"),
|
||||
},
|
||||
"opensubtitlescom": {
|
||||
AuthenticationError: (datetime.timedelta(hours=12), "12 hours"),
|
||||
ConfigurationError: (datetime.timedelta(hours=12), "12 hours"),
|
||||
TooManyRequests: (datetime.timedelta(minutes=1), "1 minute"),
|
||||
DownloadLimitExceeded: (datetime.timedelta(hours=24), "24 hours"),
|
||||
},
|
||||
|
@ -413,11 +415,16 @@ def list_throttled_providers():
|
|||
return throttled_providers
|
||||
|
||||
|
||||
def reset_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']:
|
||||
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).')
|
||||
else:
|
||||
logging.info('BAZARR throttled providers have been reset.')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue