mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-27 10:07:22 +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
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from __future__ import absolute_import
|
|
|
|
import js2py
|
|
import logging
|
|
import base64
|
|
|
|
from . import JavaScriptInterpreter
|
|
|
|
from .encapsulated import template
|
|
from .jsunfuck import jsunfuck
|
|
|
|
# ------------------------------------------------------------------------------- #
|
|
|
|
|
|
class ChallengeInterpreter(JavaScriptInterpreter):
|
|
|
|
# ------------------------------------------------------------------------------- #
|
|
|
|
def __init__(self):
|
|
super(ChallengeInterpreter, self).__init__('js2py')
|
|
|
|
# ------------------------------------------------------------------------------- #
|
|
|
|
def eval(self, body, domain):
|
|
|
|
jsPayload = template(body, domain)
|
|
|
|
if js2py.eval_js('(+(+!+[]+[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]])+[])[+!+[]]') == '1':
|
|
logging.warning('WARNING - Please upgrade your js2py https://github.com/PiotrDabkowski/Js2Py, applying work around for the meantime.')
|
|
jsPayload = jsunfuck(jsPayload)
|
|
|
|
def atob(s):
|
|
return base64.b64decode('{}'.format(s)).decode('utf-8')
|
|
|
|
js2py.disable_pyimport()
|
|
context = js2py.EvalJs({'atob': atob})
|
|
result = context.eval(jsPayload)
|
|
|
|
return result
|
|
|
|
|
|
# ------------------------------------------------------------------------------- #
|
|
|
|
ChallengeInterpreter()
|