Logowanie przez clouda
This commit is contained in:
parent
19b9de13c4
commit
38592b0123
@ -52,28 +52,51 @@ class CrunchyrollBaseIE(InfoExtractor):
|
|||||||
username, password = self._get_login_info()
|
username, password = self._get_login_info()
|
||||||
if username is None:
|
if username is None:
|
||||||
return
|
return
|
||||||
|
'''
|
||||||
|
import cfscrape
|
||||||
|
|
||||||
self._download_webpage(
|
proxies = {"http": self._downloader.params.get('proxy'), "https": self._downloader.params.get('proxy')}
|
||||||
|
tokens, user_agent = cfscrape.get_tokens(self._LOGIN_URL, proxies=proxies, user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0")
|
||||||
|
|
||||||
|
self._set_cookie( '.crunchyroll.com', 'cf_clearance',tokens['cf_clearance'])
|
||||||
|
self._set_cookie( '.crunchyroll.com', '__cfduid',tokens['__cfduid'])
|
||||||
|
'''
|
||||||
|
login_page = self._download_webpage(
|
||||||
'https://www.crunchyroll.com/?a=formhandler',
|
'https://www.crunchyroll.com/?a=formhandler',
|
||||||
None, 'Logging in', 'Wrong login info',
|
None, 'Logging in', 'Wrong login info',
|
||||||
data=urlencode_postdata({
|
data=urlencode_postdata({
|
||||||
'formname': 'RpcApiUser_Login',
|
'formname': 'RpcApiUser_Login',
|
||||||
'next_url': 'https://www.crunchyroll.com/acct/membership',
|
'next_url': 'https://www.crunchyroll.com/acct/membership',
|
||||||
|
'fail_url': self._LOGIN_URL,
|
||||||
'name': username,
|
'name': username,
|
||||||
'password': password,
|
'password': password,
|
||||||
}))
|
}), expected_status=503)
|
||||||
|
|
||||||
'''
|
|
||||||
login_page = self._download_webpage(
|
|
||||||
self._LOGIN_URL, None, 'Downloading login page')
|
|
||||||
|
|
||||||
def is_logged(webpage):
|
def is_logged(webpage):
|
||||||
return '<title>Redirecting' in webpage
|
return '<title>Redirecting' in webpage or '/logout' in webpage
|
||||||
|
|
||||||
# Already logged in
|
# Already logged in
|
||||||
if is_logged(login_page):
|
if is_logged(login_page):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
print [tokens, user_agent]
|
||||||
|
|
||||||
|
|
||||||
|
form_data = self._form_hidden_inputs('challenge-form', login_page)
|
||||||
|
form_data['jschl_answer'] = self.solve_challenge(login_page, 'www.crunchyroll.com')
|
||||||
|
print form_data
|
||||||
|
self._sleep(6, None, 'Solving CloudFlare Challenge')
|
||||||
|
login_page = self._download_webpage('https://www.crunchyroll.com/cdn-cgi/l/chk_jschl', None, 'Login Form', data=urlencode_postdata(form_data), headers={
|
||||||
|
'Referer': self._LOGIN_URL,
|
||||||
|
}, expected_status= 503)
|
||||||
|
|
||||||
|
import codecs
|
||||||
|
with codecs.open("yop", "w", encoding="utf-8") as f:
|
||||||
|
f.write(login_page)
|
||||||
|
'''
|
||||||
|
|
||||||
login_form_str = self._search_regex(
|
login_form_str = self._search_regex(
|
||||||
r'(?P<form><form[^>]+?id=(["\'])%s\2[^>]*>)' % self._LOGIN_FORM,
|
r'(?P<form><form[^>]+?id=(["\'])%s\2[^>]*>)' % self._LOGIN_FORM,
|
||||||
login_page, 'login form', group='form')
|
login_page, 'login form', group='form')
|
||||||
@ -107,7 +130,7 @@ class CrunchyrollBaseIE(InfoExtractor):
|
|||||||
raise ExtractorError('Unable to login: %s' % error, expected=True)
|
raise ExtractorError('Unable to login: %s' % error, expected=True)
|
||||||
|
|
||||||
raise ExtractorError('Unable to log in')
|
raise ExtractorError('Unable to log in')
|
||||||
'''
|
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
self._login()
|
self._login()
|
||||||
@ -123,6 +146,7 @@ class CrunchyrollBaseIE(InfoExtractor):
|
|||||||
# Crunchyroll to not work in georestriction cases in some browsers that don't place
|
# Crunchyroll to not work in georestriction cases in some browsers that don't place
|
||||||
# the locale lang first in header. However allowing any language seems to workaround the issue.
|
# the locale lang first in header. However allowing any language seems to workaround the issue.
|
||||||
request.add_header('Accept-Language', '*')
|
request.add_header('Accept-Language', '*')
|
||||||
|
request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0')
|
||||||
return super(CrunchyrollBaseIE, self)._download_webpage(request, *args, **kwargs)
|
return super(CrunchyrollBaseIE, self)._download_webpage(request, *args, **kwargs)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user