From 8bee9bfed0f379d33a2aed226801ead653475d39 Mon Sep 17 00:00:00 2001 From: pipcat Date: Thu, 4 Oct 2018 18:57:12 +0200 Subject: [PATCH 1/6] =?UTF-8?q?M=C3=A1s=20opciones=20para=20seleccionar=20?= =?UTF-8?q?canales=20d=C3=B3nde=20buscar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/channels/search.py | 58 ++++++++++++++++++---------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/plugin.video.alfa/channels/search.py b/plugin.video.alfa/channels/search.py index 63075bbb..90ea7199 100644 --- a/plugin.video.alfa/channels/search.py +++ b/plugin.video.alfa/channels/search.py @@ -154,7 +154,7 @@ def setting_channel_new(item): # Cargar lista de opciones (canales activos del usuario y que permitan búsqueda global) # ------------------------ - lista = []; ids = []; lista_lang = [] + lista = []; ids = []; lista_lang = []; lista_ctgs = [] channels_list = channelselector.filterchannels('all') for channel in channels_list: channel_parameters = channeltools.get_channel_parameters(channel.channel) @@ -171,36 +171,52 @@ def setting_channel_new(item): lista.append(it) ids.append(channel.channel) lista_lang.append(channel_parameters['language']) + lista_ctgs.append(channel_parameters['categories']) # Diálogo para pre-seleccionar # ---------------------------- - preselecciones_std = ['Modificar selección actual', 'Modificar partiendo de Todos', 'Modificar partiendo de Ninguno', 'Modificar partiendo de Castellano', 'Modificar partiendo de Latino'] - if item.action == 'setting_channel': - # Configuración de los canales incluídos en la búsqueda - preselecciones = preselecciones_std - presel_values = [1, 2, 3, 4, 5] - else: - # Llamada desde "buscar en otros canales" (se puede saltar la selección e ir directo a la búsqueda) - preselecciones = ['Buscar con la selección actual'] + preselecciones_std - presel_values = [0, 1, 2, 3, 4, 5] + preselecciones = [ + 'Buscar con la selección actual', + 'Modificar selección actual', + 'Modificar partiendo de Todos', + 'Modificar partiendo de Ninguno', + 'Modificar partiendo de Castellano', + 'Modificar partiendo de Latino' + ] + presel_values = ['skip', 'actual', 'all', 'none', 'cast', 'lat'] + + categs = ['movie', 'tvshow', 'documentary', 'anime', 'vos', 'direct', 'torrent'] + if config.get_setting('adult_mode') > 0: categs.append('adult') + for c in categs: + preselecciones.append('Modificar partiendo de %s' % config.get_localized_category(c)) + presel_values.append(c) + + if item.action == 'setting_channel': # Configuración de los canales incluídos en la búsqueda + del preselecciones[0] + del presel_values[0] + #else: # Llamada desde "buscar en otros canales" (se puede saltar la selección e ir directo a la búsqueda) ret = platformtools.dialog_select(config.get_localized_string(59994), preselecciones) if ret == -1: return False # pedido cancel - if presel_values[ret] == 0: return True # continuar sin modificar - elif presel_values[ret] == 3: preselect = [] - elif presel_values[ret] == 2: preselect = range(len(ids)) - elif presel_values[ret] in [4, 5]: - busca = 'cast' if presel_values[ret] == 4 else 'lat' + if presel_values[ret] == 'skip': return True # continuar sin modificar + elif presel_values[ret] == 'none': preselect = [] + elif presel_values[ret] == 'all': preselect = range(len(ids)) + elif presel_values[ret] in ['cast', 'lat']: preselect = [] for i, lg in enumerate(lista_lang): - if busca in lg or '*' in lg: + if presel_values[ret] in lg or '*' in lg: preselect.append(i) - else: + elif presel_values[ret] == 'actual': preselect = [] for i, canal in enumerate(ids): channel_status = config.get_setting('include_in_global_search', canal) if channel_status: preselect.append(i) + else: + preselect = [] + for i, ctgs in enumerate(lista_ctgs): + if presel_values[ret] in ctgs: + preselect.append(i) # Diálogo para seleccionar # ------------------------ @@ -493,10 +509,10 @@ def do_search(item, categories=None): if categories: # Si no se ha seleccionado torrent no se muestra - if "torrent" not in categories and "infoPlus" not in categories: - if "torrent" in channel_parameters["categories"]: - logger.info("%s -torrent-" % basename_without_extension) - continue + #if "torrent" not in categories and "infoPlus" not in categories: + # if "torrent" in channel_parameters["categories"]: + # logger.info("%s -torrent-" % basename_without_extension) + # continue for cat in categories: if cat not in channel_parameters["categories"]: From 7b111a2be0bc8a068ce0344285e6a022e3620345 Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Wed, 10 Oct 2018 19:05:06 +0200 Subject: [PATCH 2/6] DocumaniaTV: nuevo canal de documentales --- plugin.video.alfa/channels/documaniatv.json | 79 ++ plugin.video.alfa/channels/documaniatv.py | 792 ++++++++++++++++++++ 2 files changed, 871 insertions(+) create mode 100644 plugin.video.alfa/channels/documaniatv.json create mode 100644 plugin.video.alfa/channels/documaniatv.py diff --git a/plugin.video.alfa/channels/documaniatv.json b/plugin.video.alfa/channels/documaniatv.json new file mode 100644 index 00000000..3cdda230 --- /dev/null +++ b/plugin.video.alfa/channels/documaniatv.json @@ -0,0 +1,79 @@ +{ + "id": "documaniatv", + "name": "DocumaniaTV", + "active": true, + "adult": false, + "language": ["cast"], + "banner": "", + "thumbnail": "https://www.documaniatv.com/uploads/xcustom-logo.png.pagespeed.ic.lxJKR_lQE9.webp", + "version": 1, + "categories": [ + "documentary", + "vos", + "direct", + "torrent" + ], + "settings": [ + { + "id": "include_in_global_search", + "type": "bool", + "label": "Incluir en busqueda global", + "default": true, + "enabled": true, + "visible": true + }, + { + "id": "modo_grafico", + "type": "bool", + "label": "Buscar información extra", + "default": true, + "enabled": true, + "visible": true + }, + { + "id": "filter_languages", + "type": "list", + "label": "Mostrar enlaces en idioma...", + "default": 0, + "enabled": true, + "visible": true, + "lvalues": [ + "No filtrar", + "CAST", + "LAT", + "VO", + "VOS", + "VOSE" + ] + }, + { + "id": "timeout_downloadpage", + "type": "list", + "label": "Timeout (segs.) en descarga de páginas o verificación de servidores", + "default": 5, + "enabled": true, + "visible": true, + "lvalues": [ + "None", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10" + ] + }, + { + "id": "include_in_newest_documentales", + "type": "bool", + "label": "Incluir en Novedades - Documentales", + "default": true, + "enabled": true, + "visible": true + } + ] +} diff --git a/plugin.video.alfa/channels/documaniatv.py b/plugin.video.alfa/channels/documaniatv.py new file mode 100644 index 00000000..05603135 --- /dev/null +++ b/plugin.video.alfa/channels/documaniatv.py @@ -0,0 +1,792 @@ +# -*- coding: utf-8 -*- + +import re +import sys +import urllib +import urlparse +import time + +from channelselector import get_thumb +from core import httptools +from core import scrapertools +from core import servertools +from core.item import Item +from platformcode import config, logger +from core import tmdb +from lib import generictools +from channels import filtertools +from channels import autoplay + + +#IDIOMAS = {'CAST': 'Castellano', 'LAT': 'Latino', 'VO': 'Version Original'} +IDIOMAS = {'Castellano': 'CAST', 'Latino': 'LAT', 'Version Original': 'VO'} +list_language = IDIOMAS.values() +list_quality = [] +list_servers = ['directo'] + + +host = 'https://www.documaniatv.com/' +channel = "documaniatv" + +categoria = channel.capitalize() +__modo_grafico__ = config.get_setting('modo_grafico', channel) +timeout = config.get_setting('timeout_downloadpage', channel) + + +def mainlist(item): + logger.info() + itemlist = [] + + thumb_docus = get_thumb("channels_documentary.png") + thumb_series = get_thumb("channels_tvshow.png") + thumb_buscar = get_thumb("search.png") + thumb_separador = get_thumb("next.png") + thumb_settings = get_thumb("setting_0.png") + thumb_cartelera = get_thumb("now_playing.png") + thumb_pelis_vos = get_thumb("channels_vos.png") + thumb_popular = get_thumb("popular.png") + thumb_generos = get_thumb("genres.png") + + autoplay.init(item.channel, list_servers, list_quality) + + itemlist.append(Item(channel=item.channel, title="Novedades", action="listado", url=host + "newvideos.html", thumbnail=thumb_docus, extra="novedades")) + itemlist.append(Item(channel=item.channel, title="Los Más Vistos", action="listado", url=host + "topvideos.html", thumbnail=thumb_popular, extra="populares")) + itemlist.append(Item(channel=item.channel, title="Por Géneros", action="categorias", url=host + "categorias-y-canales.html", thumbnail=thumb_generos, extra="categorias")) + itemlist.append(Item(channel=item.channel, title="Series", action="listado", url=host + "top-series-documentales.html", thumbnail=thumb_series, extra="series")) + + itemlist.append(Item(channel=item.channel, title="Buscar...", action="search", url=host + "search.php?keywords=", thumbnail=thumb_buscar, extra="search")) + + itemlist.append(Item(channel=item.channel, url=host, title="[COLOR yellow]Configuración:[/COLOR]", folder=False, thumbnail=thumb_separador)) + + itemlist.append(Item(channel=item.channel, action="configuracion", title="Configurar canal", thumbnail=thumb_settings)) + + autoplay.show_option(item.channel, itemlist) #Activamos Autoplay + + return itemlist + +def configuracion(item): + from platformcode import platformtools + ret = platformtools.show_channel_settings() + platformtools.itemlist_refresh() + return + + +def categorias(item): + logger.info() + + itemlist = [] + + data = '' + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) + data = unicode(data, "utf-8", errors="replace").encode("utf-8") + except: + pass + + patron = '' + #Verificamos si se ha cargado una página, y si además tiene la estructura correcta + if not data or not scrapertools.find_single_match(data, patron): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + for clone_inter, autoridad in item.intervencion: + thumb_intervenido = get_thumb(autoridad) + itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido)) + return itemlist #Salimos + + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url + data) + if not data: #Si no ha logrado encontrar nada, salimos + itemlist.append(item.clone(action='', title=item.category + ': ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + + matches = re.compile(patron, re.DOTALL).findall(data) + + if not matches: + logger.error("ERROR 02: SUBMENU: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: SUBMENU: Ha cambiado la estructura de la Web. Reportar el error con el log')) + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + + #logger.debug(matches) + + for scrapedurl, scrapedtitle in matches: + if 'series documentales' in scrapedtitle.lower(): + continue + itemlist.append(item.clone(action="listado", title=scrapedtitle.capitalize().strip(), url=scrapedurl)) + + return itemlist + + +def listado(item): + logger.info() + itemlist = [] + item.category = categoria + + #logger.debug(item) + + curr_page = 1 # Página inicial Web + curr_page_foot = 1 # Página inicial Alfa + last_page = 99999 # Última página inicial + last_page_foot = 1 # Última página inicial + cnt_tot = 40 # Poner el num. máximo de items por página + cnt_title = 0 # Contador de líneas insertadas en Itemlist + cnt_title_tot = 0 # Contador de líneas insertadas en Itemlist, total + if item.curr_page: + curr_page = int(item.curr_page) # Si viene de una pasada anterior, lo usamos + del item.curr_page # ... y lo borramos + if item.curr_page_foot: + curr_page_foot = int(item.curr_page_foot) # Si viene de una pasada anterior, lo usamos + del item.curr_page_foot # ... y lo borramos + if item.last_page: + last_page = int(item.last_page) # Si viene de una pasada anterior, lo usamos + del item.last_page # ... y lo borramos + if item.last_page_foot: + last_page_foot = int(item.last_page_foot) # Si viene de una pasada anterior, lo usamos + del item.last_page_foot # ... y lo borramos + if item.cnt_tot: + cnt_tot = int(item.cnt_tot) # Si viene de una pasada anterior, lo usamos + del item.cnt_tot # ... y lo borramos + if item.cnt_title_tot: + cnt_title_tot = int(item.cnt_title_tot) # Si viene de una pasada anterior, lo usamos + del item.cnt_title_tot # ... y lo borramos + + inicio = time.time() # Controlaremos que el proceso no exceda de un tiempo razonable + fin = inicio + 10 # Después de este tiempo pintamos (segundos) + timeout_search = timeout # Timeout para descargas + if item.extra == 'search': + timeout_search = timeout * 2 # Timeout un poco más largo para las búsquedas + if timeout_search < 5: + timeout_search = 5 # Timeout un poco más largo para las búsquedas + + if not item.extra2: # Si viene de Catálogo o de Alfabeto + item.extra2 = '' + + next_page_url = item.url + #Máximo num. de líneas permitidas por TMDB. Máx de 10 segundos por Itemlist para no degradar el rendimiento + while cnt_title < cnt_tot and curr_page <= last_page and fin > time.time(): + + # Descarga la página + data = '' + try: + data = re.sub(r"\n|\r|\t|\s{2}|()| ", "", httptools.downloadpage(next_page_url, timeout=timeout_search).data) + data = unicode(data, "utf-8", errors="replace").encode("utf-8") + except: + pass + + if not data: #Si la web está caída salimos sin dar error + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) + break #si no hay más datos, algo no funciona, pintamos lo que tenemos + + #Patrón para todo, menos para Series + patron = '(.*?)<\/span>.*?.*?data-echo="([^"]+)"' + + #Si viene de Series, ponemos un patrón especializado + if item.extra == 'series': + patron = '(?:(.*?)<\/span>.*?)?.*? cnt_title_tot and cnt_title_tot > 0: + matches = matches[cnt_title_tot:] + + #logger.debug("PATRON: " + patron) + #logger.debug(matches) + #logger.debug(data) + + #Buscamos la url de paginado y la última página + data_page = scrapertools.find_single_match(data, '