KoD 0.8.1
- riorganizzate le impostazioni - aggiunte descrizioni tag qualità su cb01 (presto anche sugli altri) - aggiunto il supporto alle serie di polpotv - fixato server mystream - fix Rinumerazione per episodi Nuovi
This commit is contained in:
Regular → Executable
+39
-18
@@ -1,5 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from builtins import range
|
||||
import sys
|
||||
PY3 = False
|
||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||
|
||||
if PY3:
|
||||
#from future import standard_library
|
||||
#standard_library.install_aliases()
|
||||
import urllib.parse as urllib # Es muy lento en PY2. En PY3 es nativo
|
||||
else:
|
||||
import urllib # Usamos el nativo de PY2 que es más rápido
|
||||
|
||||
import base64
|
||||
import struct
|
||||
import zlib
|
||||
@@ -11,15 +23,14 @@ from core import scrapertools
|
||||
from platformcode import config, logger
|
||||
|
||||
GLOBAL_HEADER = {'User-Agent': 'Mozilla/5.0', 'Accept-Language': '*'}
|
||||
proxy = "http://anonymouse.org/cgi-bin/anon-www.cgi/"
|
||||
proxy_i = "https://www.usa-proxy.org/index.php"
|
||||
proxy = "https://www.usa-proxy.org/"
|
||||
|
||||
|
||||
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)
|
||||
data = httptools.downloadpage(page_url, headers=GLOBAL_HEADER, replace_headers=True).data
|
||||
|
||||
data = httptools.downloadpage(page_url, headers=GLOBAL_HEADER).data
|
||||
if "Este es un clip de muestra" in data:
|
||||
disp = scrapertools.find_single_match(data, '<a href="/freetrial".*?</span>.*?<span>\s*(.*?)</span>')
|
||||
disp = disp.strip()
|
||||
@@ -30,6 +41,7 @@ def test_video_exists(page_url):
|
||||
|
||||
|
||||
def get_video_url(page_url, premium=False, user="", password="", video_password=""):
|
||||
#page_url='https://www.crunchyroll.com/es-es/one-piece/episode-891-climbing-up-a-waterfall-a-great-journey-through-the-land-of-wanos-sea-zone-786643'
|
||||
logger.info("url=" + page_url)
|
||||
video_urls = []
|
||||
if "crunchyroll.com" in page_url:
|
||||
@@ -39,10 +51,13 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
|
||||
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
|
||||
data = httptools.downloadpage(url, post=post, headers=GLOBAL_HEADER).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
|
||||
httptools.downloadpage(proxy_i)
|
||||
url = urllib.quote(url)
|
||||
get = '%sbrowse.php?u=%s&b=4' % (proxy, url)
|
||||
data = httptools.downloadpage(get, post=post, headers=GLOBAL_HEADER).data
|
||||
media_url = scrapertools.find_single_match(data, '<file>(.*?)</file>').replace("&", "&")
|
||||
if not media_url:
|
||||
return video_urls
|
||||
@@ -54,18 +69,19 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
|
||||
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"))
|
||||
#idiomas = ['Español \(España\)', 'Español\]', 'English', 'Italiano', 'Français', 'Português', 'Deutsch']
|
||||
idiomas = ['Deutsch', 'Português', 'Français', 'Italiano', 'English', 'Español\]', 'Español \(España\)']
|
||||
index_sub = int(config.get_setting("crunchyrollsub", "crunchyroll"))
|
||||
idioma_sub = idiomas[index_sub]
|
||||
|
||||
link_sub = scrapertools.find_single_match(data, "link='([^']+)' title='\[%s" % idioma_sub)
|
||||
if not link_sub and index_sub == 0:
|
||||
if not link_sub and index_sub == 6:
|
||||
link_sub = scrapertools.find_single_match(data, "link='([^']+)' title='\[Español\]")
|
||||
elif not link_sub and index_sub == 1:
|
||||
elif not link_sub and index_sub == 5:
|
||||
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
|
||||
data_sub = httptools.downloadpage(link_sub.replace("&", "&"), headers=GLOBAL_HEADER).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,13 +100,13 @@ def login(page_url):
|
||||
login_page = "https://www.crunchyroll.com/login"
|
||||
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
|
||||
data = httptools.downloadpage(login_page, headers=GLOBAL_HEADER).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
|
||||
data = httptools.downloadpage(login_page, post=post, headers=GLOBAL_HEADER).data
|
||||
if "<title>Redirecting" in data:
|
||||
return True, ""
|
||||
else:
|
||||
@@ -108,14 +124,16 @@ 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):
|
||||
output.append(output[-1] + output[-2])
|
||||
# cut off start values
|
||||
output = output[2:]
|
||||
output = list(map(lambda x: x % modulo + 33, output))
|
||||
output = list([x % modulo + 33 for x in output])
|
||||
return output
|
||||
|
||||
def obfuscate_key(key):
|
||||
from math import pow, sqrt, floor
|
||||
num1 = int(floor(pow(2, 25) * sqrt(6.9)))
|
||||
@@ -130,6 +148,7 @@ 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)
|
||||
@@ -202,5 +221,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||
output += ',' + event.attrib['effect']
|
||||
output += ',' + event.attrib['text']
|
||||
output += '\n'
|
||||
output = output.encode('utf-8')
|
||||
if PY3: output = output.decode("utf-8")
|
||||
|
||||
return output.encode('utf-8')
|
||||
return output
|
||||
|
||||
Reference in New Issue
Block a user