crunchyroll server: fix
This commit is contained in:
@@ -16,7 +16,6 @@ proxy = "http://anonymouse.org/cgi-bin/anon-www.cgi/"
|
||||
|
||||
def test_video_exists(page_url):
|
||||
logger.info("(page_url='%s')" % page_url)
|
||||
|
||||
premium = config.get_setting("premium", server="crunchyroll")
|
||||
if premium:
|
||||
return login(page_url)
|
||||
@@ -27,29 +26,23 @@ def test_video_exists(page_url):
|
||||
if disp:
|
||||
disp = "Disponible gratuitamente: %s" % disp
|
||||
return False, "[Crunchyroll] Error, se necesita cuenta premium. %s" % disp
|
||||
|
||||
return True, ""
|
||||
|
||||
|
||||
def get_video_url(page_url, premium=False, user="", password="", video_password=""):
|
||||
logger.info("url=" + page_url)
|
||||
|
||||
video_urls = []
|
||||
|
||||
if "crunchyroll.com" in page_url:
|
||||
media_id = page_url.rsplit("-", 1)[1]
|
||||
else:
|
||||
media_id = scrapertools.find_single_match(page_url, 'media_id=(\d+)')
|
||||
|
||||
url = "http://www.crunchyroll.com/xml/?req=RpcApiVideoPlayer_GetStandardConfig&media_id=%s" \
|
||||
url = "https://www.crunchyroll.com/xml/?req=RpcApiVideoPlayer_GetStandardConfig&media_id=%s" \
|
||||
"&video_format=0&video_quality=0&auto_play=0&aff=af-12299-plwa" % media_id
|
||||
post = "current_page=%s" % page_url
|
||||
data = httptools.downloadpage(url, post, headers=GLOBAL_HEADER, replace_headers=True).data
|
||||
|
||||
if "<msg>Media not available</msg>" in data or "flash_block.png" in data:
|
||||
data = httptools.downloadpage(proxy + url, post, headers=GLOBAL_HEADER, replace_headers=True,
|
||||
cookies=False).data
|
||||
|
||||
media_url = scrapertools.find_single_match(data, '<file>(.*?)</file>').replace("&", "&")
|
||||
if not media_url:
|
||||
return video_urls
|
||||
@@ -60,7 +53,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
|
||||
else:
|
||||
filename = scrapertools.get_filename_from_url(media_url)[-4:]
|
||||
quality = scrapertools.find_single_match(data, '<height>(.*?)</height>')
|
||||
|
||||
try:
|
||||
idiomas = ['Español \(España\)', 'Español\]', 'English', 'Italiano', 'Français', 'Português', 'Deutsch']
|
||||
index_sub = int(config.get_setting("sub", server="crunchyroll"))
|
||||
@@ -70,12 +62,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
|
||||
link_sub = scrapertools.find_single_match(data, "link='([^']+)' title='\[Español\]")
|
||||
elif not link_sub and index_sub == 1:
|
||||
link_sub = scrapertools.find_single_match(data, "link='([^']+)' title='\[Español \(España\)")
|
||||
|
||||
if not link_sub:
|
||||
link_sub = scrapertools.find_single_match(data, "link='([^']+)' title='\[English")
|
||||
data_sub = httptools.downloadpage(link_sub.replace("&", "&"), headers=GLOBAL_HEADER,
|
||||
replace_headers=True).data
|
||||
|
||||
id_sub = scrapertools.find_single_match(data_sub, "subtitle id='([^']+)'")
|
||||
iv = scrapertools.find_single_match(data_sub, '<iv>(.*?)</iv>')
|
||||
data_sub = scrapertools.find_single_match(data_sub, '<data>(.*?)</data>')
|
||||
@@ -84,12 +74,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
|
||||
import traceback
|
||||
logger.error(traceback.format_exc())
|
||||
file_sub = ""
|
||||
|
||||
video_urls.append(["%s %sp [crunchyroll]" % (filename, quality), media_url, 0, file_sub])
|
||||
|
||||
for video_url in video_urls:
|
||||
logger.info("%s - %s" % (video_url[0], video_url[1]))
|
||||
|
||||
return video_urls
|
||||
|
||||
|
||||
@@ -98,13 +85,11 @@ def login(page_url):
|
||||
user = config.get_setting("user", server="crunchyroll")
|
||||
password = config.get_setting("password", server="crunchyroll")
|
||||
data = httptools.downloadpage(login_page, headers=GLOBAL_HEADER, replace_headers=True).data
|
||||
|
||||
if not "<title>Redirecting" in data:
|
||||
token = scrapertools.find_single_match(data, 'name="login_form\[_token\]" value="([^"]+)"')
|
||||
redirect_url = scrapertools.find_single_match(data, 'name="login_form\[redirect_url\]" value="([^"]+)"')
|
||||
post = "login_form%5Bname%5D=" + user + "&login_form%5Bpassword%5D=" + password + \
|
||||
"&login_form%5Bredirect_url%5D=" + redirect_url + "&login_form%5B_token%5D=" + token
|
||||
|
||||
data = httptools.downloadpage(login_page, post, headers=GLOBAL_HEADER, replace_headers=True).data
|
||||
if "<title>Redirecting" in data:
|
||||
return True, ""
|
||||
@@ -115,7 +100,6 @@ def login(page_url):
|
||||
return False, "Es necesario resolver un captcha. Loguéate desde un navegador y vuelve a intentarlo"
|
||||
else:
|
||||
return False, "Error en la contraseña de crunchyroll. Corrígelo o desactiva la opción premium para ver enlaces free"
|
||||
|
||||
return True, ""
|
||||
|
||||
|
||||
@@ -124,7 +108,6 @@ def decrypt_subs(iv, data, id):
|
||||
data = base64.b64decode(data.encode('utf-8'))
|
||||
iv = base64.b64decode(iv.encode('utf-8'))
|
||||
id = int(id)
|
||||
|
||||
def obfuscate_key_aux(count, modulo, start):
|
||||
output = list(start)
|
||||
for _ in range(count):
|
||||
@@ -133,7 +116,6 @@ def decrypt_subs(iv, data, id):
|
||||
output = output[2:]
|
||||
output = list(map(lambda x: x % modulo + 33, output))
|
||||
return output
|
||||
|
||||
def obfuscate_key(key):
|
||||
from math import pow, sqrt, floor
|
||||
num1 = int(floor(pow(2, 25) * sqrt(6.9)))
|
||||
@@ -148,17 +130,13 @@ def decrypt_subs(iv, data, id):
|
||||
decshaHash.append(ord(char))
|
||||
# Extend 160 Bit hash to 256 Bit
|
||||
return decshaHash + [0] * 12
|
||||
|
||||
key = obfuscate_key(id)
|
||||
key = struct.pack('B' * len(key), *key)
|
||||
|
||||
decryptor = jscrypto.new(key, 2, iv)
|
||||
decrypted_data = decryptor.decrypt(data)
|
||||
data = zlib.decompress(decrypted_data)
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
raiz = ET.fromstring(data)
|
||||
|
||||
ass_sub = convert_to_ass(raiz)
|
||||
file_sub = filetools.join(config.get_data_path(), 'crunchyroll_sub.ass')
|
||||
filetools.write(file_sub, ass_sub)
|
||||
@@ -167,13 +145,11 @@ def decrypt_subs(iv, data, id):
|
||||
|
||||
def convert_to_ass(raiz):
|
||||
output = ''
|
||||
|
||||
def ass_bool(strvalue):
|
||||
assvalue = '0'
|
||||
if strvalue == '1':
|
||||
assvalue = '-1'
|
||||
return assvalue
|
||||
|
||||
output = '[Script Info]\n'
|
||||
output += 'Title: %s\n' % raiz.attrib['title']
|
||||
output += 'ScriptType: v4.00+\n'
|
||||
|
||||
Reference in New Issue
Block a user