From 90574c6b0a2052ecceebc48123a06f423306f1c3 Mon Sep 17 00:00:00 2001 From: Alfa <30527549+alfa-addon@users.noreply.github.com> Date: Fri, 19 Oct 2018 11:40:18 -0500 Subject: [PATCH] cinetux: fix --- plugin.video.alfa/channels/cinetux.py | 250 ++++++++++++++++---------- 1 file changed, 154 insertions(+), 96 deletions(-) diff --git a/plugin.video.alfa/channels/cinetux.py b/plugin.video.alfa/channels/cinetux.py index 8776effd..fcb6cb67 100644 --- a/plugin.video.alfa/channels/cinetux.py +++ b/plugin.video.alfa/channels/cinetux.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import re from channels import autoplay from channels import filtertools from core import httptools @@ -231,6 +232,7 @@ def findvideos(item): data = httptools.downloadpage(item.url).data if filtro_enlaces != 0: list_enlaces = bloque_enlaces(data, filtro_idioma, dict_idiomas, "online", item) + return if list_enlaces: itemlist.append(item.clone(action="", title="Enlaces Online", text_color=color1, text_bold=True)) @@ -260,103 +262,159 @@ def findvideos(item): return itemlist -def bloque_enlaces(data, filtro_idioma, dict_idiomas, type, item): - logger.info() - lista_enlaces = [] - matches = [] - if type == "online": t_tipo = "Ver Online" - if type == "descarga": t_tipo = "Descargar" - data = data.replace("\n", "") - if type == "online": - patron = '(?is)class="playex.*?sheader' - bloque1 = scrapertools.find_single_match(data, patron) - patron = '(?is)#(option-[^"]+).*?png">([^<]+)' - match = scrapertools.find_multiple_matches(data, patron) - for scrapedoption, language in match: - scrapedserver = "" - lazy = "" - if "lazy" in bloque1: - lazy = "lazy-" - patron = '(?s)id="%s".*?metaframe.*?%ssrc="([^"]+)' % (scrapedoption, lazy) - url = scrapertools.find_single_match(bloque1, patron) - if "goo.gl" in url: - url = httptools.downloadpage(url, follow_redirects=False, only_headers=True).headers.get("location", "") - if "drive.php" in url: - scrapedserver = "gvideo" - if "player" in url: - scrapedserver = scrapertools.find_single_match(url, 'player/(\w+)') - if "ok" in scrapedserver: scrapedserver = "okru" - matches.append([url, scrapedserver, "", language.strip(), t_tipo]) - bloque2 = scrapertools.find_single_match(data, '(?s)box_links.*?dt_social_single') - bloque2 = bloque2.replace("\t", "").replace("\r", "") - patron = '(?s)optn" href="([^"]+)' - patron += '.*?alt="([^\.]+)' - patron += '.*?src.*?src="[^>]+"?/>([^<]+)' - patron += '.*?src="[^>]+"?/>([^<]+)' - patron += '.*?/span>([^<]+)' - matches.extend(scrapertools.find_multiple_matches(bloque2, patron)) - filtrados = [] - for match in matches: - scrapedurl = match[0] - scrapedserver = match[1] - scrapedcalidad = match[2] - language = match[3] - scrapedtipo = match[4] - if t_tipo.upper() not in scrapedtipo.upper(): - continue - title = " Mirror en %s (" + language + ")" - if len(scrapedcalidad.strip()) > 0: - title += " (Calidad " + scrapedcalidad.strip() + ")" +# def bloque_enlaces(data, filtro_idioma, dict_idiomas, type, item): +# logger.info() +# lista_enlaces = [] +# matches = [] +# if type == "online": t_tipo = "Ver Online" +# if type == "descarga": t_tipo = "Descargar" +# data = data.replace("\n", "") +# if type == "online": +# patron = '(?is)class="playex.*?sheader' +# bloque1 = scrapertools.find_single_match(data, patron) +# patron = '(?is)#(option-[^"]+).*?png">([^<]+)' +# match = scrapertools.find_multiple_matches(data, patron) +# for scrapedoption, language in match: +# scrapedserver = "" +# lazy = "" +# if "lazy" in bloque1: +# lazy = "lazy-" +# patron = '(?s)id="%s".*?metaframe.*?%ssrc="([^"]+)' % (scrapedoption, lazy) +# url = scrapertools.find_single_match(bloque1, patron) +# if "goo.gl" in url: +# url = httptools.downloadpage(url, follow_redirects=False, only_headers=True).headers.get("location", "") +# if "drive.php" in url: +# scrapedserver = "gvideo" +# if "player" in url: +# scrapedserver = scrapertools.find_single_match(url, 'player/(\w+)') +# if "ok" in scrapedserver: scrapedserver = "okru" +# matches.append([url, scrapedserver, "", language.strip(), t_tipo]) +# bloque2 = scrapertools.find_single_match(data, '(?s)box_links.*?dt_social_single') +# bloque2 = bloque2.replace("\t", "").replace("\r", "") +# patron = '(?s)optn" href="([^"]+)' +# patron += '.*?alt="([^\.]+)' +# patron += '.*?src.*?src="[^>]+"?/>([^<]+)' +# patron += '.*?src="[^>]+"?/>([^<]+)' +# patron += '.*?/span>([^<]+)' +# matches.extend(scrapertools.find_multiple_matches(bloque2, patron)) +# filtrados = [] +# for match in matches: +# scrapedurl = match[0] +# scrapedserver = match[1] +# scrapedcalidad = match[2] +# language = match[3] +# scrapedtipo = match[4] +# if t_tipo.upper() not in scrapedtipo.upper(): +# continue +# title = " Mirror en %s (" + language + ")" +# if len(scrapedcalidad.strip()) > 0: +# title += " (Calidad " + scrapedcalidad.strip() + ")" +# +# if filtro_idioma == 3 or item.filtro: +# lista_enlaces.append(item.clone(title=title, action="play", text_color=color2, +# url=scrapedurl, server=scrapedserver, +# extra=item.url, contentThumbnail = item.thumbnail, +# language=language)) +# else: +# idioma = dict_idiomas[language] +# if idioma == filtro_idioma: +# lista_enlaces.append(item.clone(title=title, action="play", text_color=color2, +# url=scrapedurl, server=scrapedserver, +# extra=item.url, contentThumbnail = item.thumbnail, +# language=language)) +# else: +# if language not in filtrados: +# filtrados.append(language) +# lista_enlaces = servertools.get_servers_itemlist(lista_enlaces, lambda i: i.title % i.server.capitalize()) +# if filtro_idioma != 3: +# if len(filtrados) > 0: +# title = "Mostrar también enlaces filtrados en %s" % ", ".join(filtrados) +# lista_enlaces.append(item.clone(title=title, action="findvideos", url=item.url, text_color=color3, +# filtro=True)) +# return lista_enlaces +# +# +# def play(item): +# logger.info() +# itemlist = [] +# if "api.cinetux" in item.url or item.server == "okru" or "drive.php" in item.url or "youtube" in item.url: +# data = httptools.downloadpage(item.url, headers={'Referer': item.extra}).data.replace("\\", "") +# id = scrapertools.find_single_match(data, 'img src="[^#]+#(.*?)"') +# item.url = "http://docs.google.com/get_video_info?docid=" + id +# if item.server == "okru": +# item.url = "https://ok.ru/videoembed/" + id +# if item.server == "youtube": +# item.url = "https://www.youtube.com/embed/" + id +# elif "links" in item.url or "www.cinetux.me" in item.url: +# data = httptools.downloadpage(item.url).data +# scrapedurl = scrapertools.find_single_match(data, '|\s{2,}', "", data) + return data + +def findvideos(item): + import urllib + logger.info() + + itemlist=[] + + data = get_source(item.url) + + patron = 'class="title">([^>]+).*?data-type="([^"]+)" data-post="(\d+)" data-nume="(\d+)' + matches = re.compile(patron, re.DOTALL).findall(data) + + for language, tp, pt, nm in matches: + + post = {'action':'doo_player_ajax', 'post':pt, 'nume':nm, 'type':tp} + post = urllib.urlencode(post) + new_data = httptools.downloadpage(CHANNEL_HOST+'wp-admin/admin-ajax.php', post=post, headers={'Referer':item.url}).data + if not config.get_setting('unify'): + if item.quality == '': + quality = 'SD' else: - if language not in filtrados: - filtrados.append(language) - lista_enlaces = servertools.get_servers_itemlist(lista_enlaces, lambda i: i.title % i.server.capitalize()) - if filtro_idioma != 3: - if len(filtrados) > 0: - title = "Mostrar también enlaces filtrados en %s" % ", ".join(filtrados) - lista_enlaces.append(item.clone(title=title, action="findvideos", url=item.url, text_color=color3, - filtro=True)) - return lista_enlaces + quality = item.quality + title = ' [%s][%s]' % (quality, IDIOMAS[language]) + else: + title = '' + url = scrapertools.find_single_match(new_data, "src='([^']+)'") + itemlist.append(Item(channel=item.channel, title ='%s'+title, url=url, action='play', quality=item.quality, + language=IDIOMAS[language], infoLabels=item.infoLabels)) + patron = "([^<]+)<" + matches = re.compile(patron, re.DOTALL).findall(data) -def play(item): - logger.info() - itemlist = [] - if "api.cinetux" in item.url or item.server == "okru" or "drive.php" in item.url or "youtube" in item.url: - data = httptools.downloadpage(item.url, headers={'Referer': item.extra}).data.replace("\\", "") - id = scrapertools.find_single_match(data, 'img src="[^#]+#(.*?)"') - item.url = "http://docs.google.com/get_video_info?docid=" + id - if item.server == "okru": - item.url = "https://ok.ru/videoembed/" + id - if item.server == "youtube": - item.url = "https://www.youtube.com/embed/" + id - elif "links" in item.url or "www.cinetux.me" in item.url: - data = httptools.downloadpage(item.url).data - scrapedurl = scrapertools.find_single_match(data, '