mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-22 15:54:26 +00:00
cb420628f8
* Upgraded cloudscraper to fix multiple issues with providers that uses antibot page. * Fixed subs4series provider. It now require anti-captcha provider to download subtitles. One captcha will have to be solved for each download. #1442
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
import abc
|
|
import logging
|
|
import sys
|
|
|
|
if sys.version_info >= (3, 4):
|
|
ABC = abc.ABC # noqa
|
|
else:
|
|
ABC = abc.ABCMeta('ABC', (), {})
|
|
|
|
# ------------------------------------------------------------------------------- #
|
|
|
|
captchaSolvers = {}
|
|
|
|
# ------------------------------------------------------------------------------- #
|
|
|
|
|
|
class Captcha(ABC):
|
|
@abc.abstractmethod
|
|
def __init__(self, name):
|
|
captchaSolvers[name] = self
|
|
|
|
# ------------------------------------------------------------------------------- #
|
|
|
|
@classmethod
|
|
def dynamicImport(cls, name):
|
|
if name not in captchaSolvers:
|
|
try:
|
|
__import__(f'{cls.__module__}.{name}')
|
|
if not isinstance(captchaSolvers.get(name), Captcha):
|
|
raise ImportError('The anti captcha provider was not initialized.')
|
|
except ImportError as e:
|
|
sys.tracebacklimit = 0
|
|
logging.error(f'Unable to load {name} anti captcha provider -> {e}')
|
|
raise
|
|
|
|
return captchaSolvers[name]
|
|
|
|
# ------------------------------------------------------------------------------- #
|
|
|
|
@abc.abstractmethod
|
|
def getCaptchaAnswer(self, captchaType, url, siteKey, captchaParams):
|
|
pass
|
|
|
|
# ------------------------------------------------------------------------------- #
|
|
|
|
def solveCaptcha(self, captchaType, url, siteKey, captchaParams):
|
|
return self.getCaptchaAnswer(captchaType, url, siteKey, captchaParams)
|