From 2130898fdd2126f4aaa2bc05433ad6136b118abe Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Wed, 19 Sep 2018 14:51:46 +0200 Subject: [PATCH] AutoPlay y Filtrado de Idiomas: canales Torrent DivXtotal EliteTorrent EstrenosGo GranTorrent MejorTorrent NewPct1 ZonaTorrent --- plugin.video.alfa/channels/divxtotal.json | 16 ++ plugin.video.alfa/channels/divxtotal.py | 58 +++++- plugin.video.alfa/channels/elitetorrent.json | 57 +++++- plugin.video.alfa/channels/elitetorrent.py | 117 ++++++++++-- plugin.video.alfa/channels/estrenosgo.json | 16 ++ plugin.video.alfa/channels/estrenosgo.py | 116 +++++++++--- plugin.video.alfa/channels/grantorrent.json | 47 ++++- plugin.video.alfa/channels/grantorrent.py | 130 +++++++++++--- plugin.video.alfa/channels/mejortorrent1.py | 13 +- plugin.video.alfa/channels/newpct1.json | 16 ++ plugin.video.alfa/channels/newpct1.py | 179 ++++++++++++++++--- plugin.video.alfa/channels/zonatorrent.json | 40 ++--- plugin.video.alfa/channels/zonatorrent.py | 84 +++++++-- plugin.video.alfa/lib/generictools.py | 85 +++++++-- 14 files changed, 823 insertions(+), 151 deletions(-) diff --git a/plugin.video.alfa/channels/divxtotal.json b/plugin.video.alfa/channels/divxtotal.json index bf1c4ac6..811b5e44 100644 --- a/plugin.video.alfa/channels/divxtotal.json +++ b/plugin.video.alfa/channels/divxtotal.json @@ -27,6 +27,22 @@ "type": "bool", "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", diff --git a/plugin.video.alfa/channels/divxtotal.py b/plugin.video.alfa/channels/divxtotal.py index 1a0deaf5..b5ed39f6 100644 --- a/plugin.video.alfa/channels/divxtotal.py +++ b/plugin.video.alfa/channels/divxtotal.py @@ -14,6 +14,15 @@ 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 = ['torrent'] host = 'https://www.divxtotal3.net/' channel = 'divxtotal' @@ -33,6 +42,9 @@ def mainlist(item): 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") + + autoplay.init(item.channel, list_servers, list_quality) item.url_plus = "peliculas/" itemlist.append(Item(channel=item.channel, title="Películas", action="categorias", url=host + item.url_plus, url_plus=item.url_plus, thumbnail=thumb_cartelera, extra="Películas")) @@ -49,7 +61,20 @@ def mainlist(item): itemlist.append(Item(channel=item.channel, title="Buscar...", action="search", url=host + "?s=%s", 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 submenu(item): @@ -174,7 +199,7 @@ def listado(item): cnt_tot = 40 # Poner el num. máximo de items por página cnt_title = 0 # Contador de líneas insertadas en Itemlist inicio = time.time() # Controlaremos que el proceso no exceda de un tiempo razonable - fin = inicio + 10 # Después de este tiempo pintamos (segundos) + fin = inicio + 5 # 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 @@ -287,7 +312,7 @@ def listado(item): else: url = scrapedurl #No se encuentra la Serie, se trata como Episodio suelto - cnt_title += 1 + #cnt_title += 1 item_local = item.clone() #Creamos copia de Item para trabajar if item_local.tipo: #... y limpiamos del item_local.tipo @@ -458,7 +483,13 @@ def listado(item): item_local.contentSeason_save = item_local.contentSeason del item_local.infoLabels['season'] - itemlist.append(item_local.clone()) #Pintar pantalla + #Ahora se filtra por idioma, si procede, y se pinta lo que vale + if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + itemlist = filtertools.get_link(itemlist, item_local, list_language) + else: + itemlist.append(item_local.clone()) #Si no, pintar pantalla + + cnt_title = len(itemlist) #Contador de líneas añadidas #logger.debug(item_local) @@ -483,6 +514,10 @@ def listado(item): def findvideos(item): logger.info() itemlist = [] + itemlist_t = [] #Itemlist total de enlaces + itemlist_f = [] #Itemlist de enlaces filtrados + if not item.language: + item.language = ['CAST'] #Castellano por defecto matches = [] item.category = categoria @@ -552,11 +587,26 @@ def findvideos(item): item_local.action = "play" #Visualizar vídeo item_local.server = "torrent" #Seridor Torrent - itemlist.append(item_local.clone()) #Pintar pantalla + itemlist_t.append(item_local.clone()) #Pintar pantalla, si no se filtran idiomas + + # Requerido para FilterTools + if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío #logger.debug("TORRENT: " + scrapedurl + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) #logger.debug(item_local) + if len(itemlist_f) > 0: #Si hay entradas filtradas... + itemlist.extend(itemlist_f) #Pintamos pantalla filtrada + else: + if config.get_setting('filter_languages', channel) > 0 and len(itemlist_t) > 0: #Si no hay entradas filtradas ... + thumb_separador = get_thumb("next.png") #... pintamos todo con aviso + itemlist.append(Item(channel=item.channel, url=host, title="[COLOR red][B]NO hay elementos con el idioma seleccionado[/B][/COLOR]", thumbnail=thumb_separador)) + itemlist.extend(itemlist_t) #Pintar pantalla con todo si no hay filtrado + + # Requerido para AutoPlay + autoplay.start(itemlist, item) #Lanzamos Autoplay + return itemlist diff --git a/plugin.video.alfa/channels/elitetorrent.json b/plugin.video.alfa/channels/elitetorrent.json index ec17889b..50d2e298 100644 --- a/plugin.video.alfa/channels/elitetorrent.json +++ b/plugin.video.alfa/channels/elitetorrent.json @@ -21,6 +21,59 @@ "default": false, "enabled": true, "visible": true + }, + { + "id": "modo_grafico", + "type": "bool", + "label": "Buscar información extra en TMDB", + "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": "include_in_newest_peliculas", + "type": "bool", + "label": "Incluir en Novedades - Peliculas", + "default": true, + "enabled": true, + "visible": true + }, + { + "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" + ] } - ] -} + ] +} \ No newline at end of file diff --git a/plugin.video.alfa/channels/elitetorrent.py b/plugin.video.alfa/channels/elitetorrent.py index 1a052a4a..2e2b6029 100644 --- a/plugin.video.alfa/channels/elitetorrent.py +++ b/plugin.video.alfa/channels/elitetorrent.py @@ -4,6 +4,7 @@ import re import sys import urllib import urlparse +import time from channelselector import get_thumb from core import httptools @@ -13,8 +14,22 @@ 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 = ['torrent'] host = 'http://www.elitetorrent.biz' +channel = "elitetorrent" + +categoria = channel.capitalize() +__modo_grafico__ = config.get_setting('modo_grafico', channel) +timeout = config.get_setting('timeout_downloadpage', channel) def mainlist(item): @@ -26,19 +41,37 @@ def mainlist(item): thumb_series = get_thumb("channels_tvshow.png") thumb_series_hd = get_thumb("channels_tvshow_hd.png") thumb_buscar = get_thumb("search.png") + thumb_separador = get_thumb("next.png") + thumb_settings = get_thumb("setting_0.png") + + autoplay.init(item.channel, list_servers, list_quality) itemlist.append(Item(channel=item.channel, action="submenu", title="Películas", url=host, extra="peliculas", thumbnail=thumb_pelis)) itemlist.append(Item(channel=item.channel, action="submenu", title="Series", url=host, extra="series", thumbnail=thumb_series)) - itemlist.append(Item(channel=item.channel, action="search", title="Buscar", url=host, thumbnail=thumb_buscar)) + itemlist.append(Item(channel=item.channel, action="search", title="Buscar", url=host, thumbnail=thumb_buscar, filter_lang=True)) + + 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 submenu(item): logger.info() itemlist = [] + item.filter_lang = True data = '' try: @@ -84,10 +117,13 @@ def submenu(item): if "/serie" in scrapedurl: continue + if 'subtitulado' in scrapedtitle.lower() or 'latino' in scrapedtitle.lower() or 'original' in scrapedtitle.lower(): + item.filter_lang = False + itemlist.append(item.clone(action="listado", title=scrapedtitle, url=scrapedurl)) if item.extra == "series": #Añadimos Series VOSE que está fuera del menú principal - itemlist.append(item.clone(action="listado", title="Series VOSE", url=host + "/series-vose/")) + itemlist.append(item.clone(action="listado", title="Series VOSE", url=host + "/series-vose/", filter_lang=False)) return itemlist @@ -96,10 +132,18 @@ def listado(item): logger.info() itemlist = [] + inicio = time.time() # Controlaremos que el proceso no exceda de un tiempo razonable + fin = inicio + 5 # 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 + # Descarga la página data = '' try: - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout_search).data) except: pass @@ -168,6 +212,9 @@ def listado(item): item_local.language += ["VO"] if "dual" in scrapedcategory.lower() or "dual" in title.lower(): item_local.language[0:0] = ["DUAL"] + + if item_local.language == []: + item_local.language = ['CAST'] #Por defecto #Limpiamos el título de la basura innecesaria title = title.replace("Dual", "").replace("dual", "").replace("Subtitulada", "").replace("subtitulada", "").replace("Subt", "").replace("subt", "").replace("Sub", "").replace("sub", "").replace("(Proper)", "").replace("(proper)", "").replace("Proper", "").replace("proper", "").replace("#", "").replace("(Latino)", "").replace("Latino", "") @@ -215,10 +262,14 @@ def listado(item): item_local.infoLabels['year'] = "-" #Pasamos a TMDB cada Item, para evitar el efecto memoria de tmdb - if item.category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global, pasamos - tmdb.set_infoLabels(item_local, True) + #if item.category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global, pasamos + # tmdb.set_infoLabels(item_local, True) - itemlist.append(item_local.clone()) #Pintar pantalla + #Ahora se filtra por idioma, si procede, y se pinta lo que vale + if config.get_setting('filter_languages', channel) > 0 and item.filter_lang: #Si hay idioma seleccionado, se filtra + itemlist = filtertools.get_link(itemlist, item_local, list_language) + else: + itemlist.append(item_local.clone()) #Si no, pintar pantalla #if not item.category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global # return itemlist #Retornamos sin pasar por la fase de maquillaje para ahorra tiempo @@ -250,7 +301,7 @@ def listado(item): else: title = '[COLOR gold]Página siguiente >>[/COLOR] %s' % (int(matches[1]) - 1) - itemlist.append(Item(channel=item.channel, action="listado", title=title, url=scrapedurl, extra=item.extra)) + itemlist.append(Item(channel=item.channel, action="listado", title=title, url=scrapedurl, extra=item.extra, filter_lang=item.filter_lang)) return itemlist @@ -258,11 +309,15 @@ def listado(item): def findvideos(item): logger.info() itemlist = [] + itemlist_t = [] #Itemlist total de enlaces + itemlist_f = [] #Itemlist de enlaces filtrados + if not item.language: + item.language = ['CAST'] #Castellano por defecto #Bajamos los datos de la página data = '' try: - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) except: pass @@ -308,12 +363,12 @@ def findvideos(item): if size: item.quality = '%s [%s]' % (item.quality, size) #Agregamos size al final de calidad item.quality = item.quality.replace("GB", "G B").replace("MB", "M B") #Se evita la palabra reservada en Unify - - #Generamos una copia de Item para trabajar sobre ella - item_local = item.clone() #Ahora pintamos el link del Torrent, si lo hay - if link_torrent: # Hay Torrent ? + if link_torrent: # Hay Torrent ? + #Generamos una copia de Item para trabajar sobre ella + item_local = item.clone() + if item_local.quality: item_local.quality += " " item_local.quality += "[Torrent]" @@ -332,10 +387,27 @@ def findvideos(item): item_local.action = "play" #Visualizar vídeo item_local.server = "torrent" #Seridor Torrent - itemlist.append(item_local.clone()) #Pintar pantalla + itemlist_t.append(item_local.clone()) #Pintar pantalla, si no se filtran idiomas + + # Requerido para FilterTools + if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío + + if len(itemlist_f) > 0: #Si hay entradas filtradas... + itemlist.extend(itemlist_f) #Pintamos pantalla filtrada + else: + if config.get_setting('filter_languages', channel) > 0 and len(itemlist_t) > 0: #Si no hay entradas filtradas ... + thumb_separador = get_thumb("next.png") #... pintamos todo con aviso + itemlist.append(Item(channel=item.channel, url=host, title="[COLOR red][B]NO hay elementos con el idioma seleccionado[/B][/COLOR]", thumbnail=thumb_separador)) + itemlist.extend(itemlist_t) #Pintar pantalla con todo si no hay filtrado #Ahora pintamos el link del Magnet, si lo hay + itemlist_t = [] #Itemlist total de enlaces + itemlist_f = [] #Itemlist de enlaces filtrados if link_magnet: # Hay Magnet ? + #Generamos una copia de Item para trabajar sobre ella + item_local = item.clone() + if item_local.quality: item_local.quality += " " item_local.quality = item_local.quality.replace("[Torrent]", "") + "[Magnet]" @@ -347,11 +419,26 @@ def findvideos(item): item_local.action = "play" #Visualizar vídeo item_local.server = "torrent" #Seridor Torrent - itemlist.append(item_local.clone()) #Pintar pantalla + itemlist_t.append(item_local.clone()) #Pintar pantalla, si no se filtran idiomas + + # Requerido para FilterTools + if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío + + if len(itemlist_f) > 0: #Si hay entradas filtradas... + itemlist.extend(itemlist_f) #Pintamos pantalla filtrada + else: + if config.get_setting('filter_languages', channel) > 0 and len(itemlist_t) > 0: #Si no hay entradas filtradas ... + thumb_separador = get_thumb("next.png") #... pintamos todo con aviso + itemlist.append(Item(channel=item.channel, url=host, title="[COLOR red][B]NO hay elementos con el idioma seleccionado[/B][/COLOR]", thumbnail=thumb_separador)) + itemlist.extend(itemlist_t) #Pintar pantalla con todo si no hay filtrado #logger.debug("TORRENT: " + link_torrent + "MAGNET: " + link_magnet + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) #logger.debug(item_local) + # Requerido para AutoPlay + autoplay.start(itemlist, item) #Lanzamos Autoplay + return itemlist @@ -387,7 +474,7 @@ def newest(categoria): itemlist = [] item = Item() try: - if categoria == 'torrent': + if categoria == 'peliculas': item.url = host item.extra = "peliculas" item.category_new= 'newest' diff --git a/plugin.video.alfa/channels/estrenosgo.json b/plugin.video.alfa/channels/estrenosgo.json index bf922a70..5ebbbafc 100755 --- a/plugin.video.alfa/channels/estrenosgo.json +++ b/plugin.video.alfa/channels/estrenosgo.json @@ -31,6 +31,22 @@ "type": "bool", "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", diff --git a/plugin.video.alfa/channels/estrenosgo.py b/plugin.video.alfa/channels/estrenosgo.py index 52b00848..796c77e6 100644 --- a/plugin.video.alfa/channels/estrenosgo.py +++ b/plugin.video.alfa/channels/estrenosgo.py @@ -14,12 +14,23 @@ from core.item import Item from platformcode import config, logger, platformtools 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 = ['torrent'] host = 'http://estrenosby.net/' # 'http://estrenosli.org/' +channel = "estrenosgo" + color1, color2, color3 = ['0xFF58D3F7', '0xFF2E64FE', '0xFF0404B4'] -__modo_grafico__ = config.get_setting('modo_grafico', 'estrenosgo') -modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', 'estrenosgo') #Actualización sólo últ. Temporada? -timeout = config.get_setting('timeout_downloadpage', 'estrenosgo') +__modo_grafico__ = config.get_setting('modo_grafico', channel) +modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', channel) #Actualización sólo últ. Temporada? +timeout = config.get_setting('timeout_downloadpage', channel) def mainlist(item): @@ -37,28 +48,41 @@ def mainlist(item): thumb_buscar = get_thumb("search.png") thumb_separador = get_thumb("next.png") thumb_cabecera = get_thumb("nofolder.png") + thumb_settings = get_thumb("setting_0.png") + + autoplay.init(item.channel, list_servers, list_quality) itemlist.append(Item(channel=item.channel, url=host, title="PELÍCULAS: ", folder=False, thumbnail=thumb_pelis)) - itemlist.append(Item(channel=item.channel, title=" - Cartelera", action="categorias", url=item.url + "descarga-0-58126", thumbnail=thumb_cartelera, extra="cartelera")) - itemlist.append(Item(channel=item.channel, title=" - DVD-RIP", action="categorias", url=item.url + "descarga-0-581210", thumbnail=thumb_pelis, extra="DVD-RIP")) - itemlist.append(Item(channel=item.channel, title=" - HD-RIP", action="categorias", url=item.url + "descarga-0-58128", thumbnail=thumb_pelis_hd, extra="HD-RIP")) - itemlist.append(Item(channel=item.channel, title=" - Subtituladas", action="categorias", url=item.url + "descarga-0-58127", thumbnail=thumb_pelis_VO, extra="VOSE")) - itemlist.append(Item(channel=item.channel, title=" - Versión Original", action="categorias", url=item.url + "descarga-0-5812255", thumbnail=thumb_pelis_VO, extra="VO")) - - itemlist.append(Item(channel=item.channel, url=host, title="", folder=False, thumbnail=thumb_separador)) + itemlist.append(Item(channel=item.channel, title=" - Cartelera", action="categorias", url=item.url + "descarga-0-58126", thumbnail=thumb_cartelera, extra="cartelera", filter_lang=True)) + itemlist.append(Item(channel=item.channel, title=" - DVD-RIP", action="categorias", url=item.url + "descarga-0-581210", thumbnail=thumb_pelis, extra="DVD-RIP", filter_lang=True)) + itemlist.append(Item(channel=item.channel, title=" - HD-RIP", action="categorias", url=item.url + "descarga-0-58128", thumbnail=thumb_pelis_hd, extra="HD-RIP", filter_lang=True)) + itemlist.append(Item(channel=item.channel, title=" - Subtituladas", action="categorias", url=item.url + "descarga-0-58127", thumbnail=thumb_pelis_VO, extra="VOSE", filter_lang=False)) + itemlist.append(Item(channel=item.channel, title=" - Versión Original", action="categorias", url=item.url + "descarga-0-5812255", thumbnail=thumb_pelis_VO, extra="VO", filter_lang=False)) itemlist.append(Item(channel=item.channel, url=host, title="Series", action="submenu", thumbnail=thumb_series, extra="series")) - - itemlist.append(Item(channel=item.channel, url=host, title="", folder=False, thumbnail=thumb_separador)) itemlist.append(Item(channel=item.channel, title="Buscar...", action="search", url=host + "descarga-0-0-0-0-fx-1-%s-sch-titulo-", 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 submenu(item): logger.info() itemlist = [] + item.filter_lang = True thumb_cartelera = get_thumb("now_playing.png") thumb_pelis = get_thumb("channels_movie.png") @@ -183,7 +207,7 @@ def listado(item): cnt_tot = 40 # Poner el num. máximo de items por página cnt_title = 0 # Contador de líneas insertadas en Itemlist inicio = time.time() # Controlaremos que el proceso no exceda de un tiempo razonable - fin = inicio + 10 # Después de este tiempo pintamos (segundos) + fin = inicio + 5 # 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 @@ -306,7 +330,7 @@ def listado(item): elif "Archivo Torrent" not in scrapedenlace and "Video Online" not in scrapedenlace: #Si no tiene enlaces pasamos continue - cnt_title += 1 + #cnt_title += 1 item_local = item.clone() #Creamos copia de Item para trabajar if item_local.tipo: #... y limpiamos del item_local.tipo @@ -326,6 +350,8 @@ def listado(item): del item_local.text_bold item_local.text_color = True del item_local.text_color + item_local.filter_lang = True + del item_local.filter_lang title_subs = [] #creamos una lista para guardar info importante item_local.language = [] #creamos lista para los idiomas @@ -473,7 +499,13 @@ def listado(item): item_local.contentSeason_save = item_local.contentSeason del item_local.infoLabels['season'] - itemlist.append(item_local.clone()) #Pintar pantalla + #Ahora se filtra por idioma, si procede, y se pinta lo que vale + if config.get_setting('filter_languages', channel) > 0 and item.filter_lang: #Si hay idioma seleccionado, se filtra + itemlist = filtertools.get_link(itemlist, item_local, list_language) + else: + itemlist.append(item_local.clone()) #Si no, pintar pantalla + + cnt_title = len(itemlist) #Contador de líneas añadidas #logger.debug(item_local) @@ -490,7 +522,7 @@ def listado(item): else: title = '%s' % curr_page-1 - itemlist.append(Item(channel=item.channel, action="listado", title=">> Página siguiente " + title, title_lista=title_lista, url=item.url, extra=item.extra, extra2=item.extra2, last_page=str(last_page), curr_page=str(curr_page))) + itemlist.append(Item(channel=item.channel, action="listado", title=">> Página siguiente " + title, title_lista=title_lista, url=item.url, extra=item.extra, extra2=item.extra2, last_page=str(last_page), curr_page=str(curr_page), filter_lang=item.filter_lang)) return itemlist @@ -572,8 +604,12 @@ def listado_series(item): item_local.title = title.strip().lower().title() item_local.from_title = title.strip().lower().title() - itemlist.append(item_local.clone()) #Pintar pantalla - + #Ahora se filtra por idioma, si procede, y se pinta lo que vale + if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + itemlist = filtertools.get_link(itemlist, item_local, list_language) + else: + itemlist.append(item_local.clone()) #Si no, pintar pantalla + #logger.debug(item_local) #if not item.category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global @@ -598,6 +634,10 @@ def listado_series(item): def findvideos(item): logger.info() itemlist = [] + itemlist_t = [] #Itemlist total de enlaces + itemlist_f = [] #Itemlist de enlaces filtrados + if not item.language: + item.language = ['CAST'] #Castellano por defecto #logger.debug(item) @@ -682,7 +722,7 @@ def findvideos(item): #Ahora tratamos los enlaces .torrent itemlist_alt = [] #Usamos una lista intermedia para poder ordenar los episodios if matches_torrent: - for scrapedurl, scrapedquality, scrapedlang in matches_torrent: #leemos los torrents con la diferentes calidades + for scrapedurl, scrapedquality, scrapedlang in matches_torrent: #leemos los torrents con la diferentes calidades #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() @@ -695,7 +735,7 @@ def findvideos(item): if not item_local.quality: item_local.quality = item.quality elif scrapertools.find_single_match(item.quality, '(\[\d+:\d+ h\])'): #Salvamos la duración - item_local.quality += ' [/COLOR][COLOR white]%s' % scrapertools.find_single_match(item.quality, '(\[\d+:\d+ h\])') #Copiamos duración + item_local.quality += ' [/COLOR][COLOR white]%s' % scrapertools.find_single_match(item.quality, '(\[\d+:\d+ h\])') #Copiamos duración if scrapedlang in IDIOMAS: #Salvamos el idioma, si lo hay item_local.language = ["%s" % IDIOMAS[scrapedlang]] @@ -718,6 +758,7 @@ def findvideos(item): #logger.debug(data) for scrapedtorrent, scrapedtitle in matches: + item_local = item_local.clone() quality = item_local.quality qualityscraped = '' if not item_local.contentEpisodeNumber and item_local.contentType == 'episode': @@ -773,11 +814,23 @@ def findvideos(item): item_local.action = "play" #Visualizar vídeo item_local.server = "torrent" #Seridor Torrent - itemlist_alt.append(item_local.clone(quality=quality)) #Pintar pantalla + itemlist_t.append(item_local.clone(quality=quality)) #Pintar pantalla, si no se filtran idiomas + + # Requerido para FilterTools + if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío #logger.debug("TORRENT: " + scrapedtorrent + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + scrapedsize + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) #logger.debug(item_local) + if len(itemlist_f) > 0: #Si hay entradas filtradas... + itemlist_alt.extend(itemlist_f) #Pintamos pantalla filtrada + else: + if config.get_setting('filter_languages', channel) > 0 and len(itemlist_t) > 0: #Si no hay entradas filtradas ... + thumb_separador = get_thumb("next.png") #... pintamos todo con aviso + itemlist.append(Item(channel=item.channel, url=host, title="[COLOR red][B]NO hay elementos con el idioma seleccionado[/B][/COLOR]", thumbnail=thumb_separador)) + itemlist_alt.extend(itemlist_t) #Pintar pantalla con todo si no hay filtrado + #Si son múltiples episodios, ordenamos if len(itemlist_alt) > 1 and (item.contentType == 'episode' or item.contentType == 'season'): itemlist_alt = sorted(itemlist_alt, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) #clasificamos @@ -786,6 +839,8 @@ def findvideos(item): #Ahora tratamos los servidores directo itemlist_alt = [] + itemlist_t = [] #Itemlist total de enlaces + itemlist_f = [] #Itemlist de enlaces filtrados if matches_directo: for scrapedurl, scrapedquality, scrapedlang in matches_directo: #leemos los torrents con la diferentes calidades #Generamos una copia de Item para trabajar sobre ella @@ -824,6 +879,8 @@ def findvideos(item): #logger.debug(data) for scrapedtitle, scrapedenlace in matches: + item_local = item_local.clone() + enlace = '' devuelve = '' mostrar_server = '' @@ -918,18 +975,33 @@ def findvideos(item): item_local.action = "play" #Visualizar vídeo item_local.server = servidor #Seridor Directo - itemlist_alt.append(item_local.clone(quality=quality)) #Pintar pantalla + itemlist_t.append(item_local.clone(quality=quality)) #Pintar pantalla, si no se filtran idiomas + + # Requerido para FilterTools + if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío except: logger.error('ERROR al procesar enlaces DIRECTOS: ' + servidor + ' / ' + scrapedenlace) #logger.debug("DIRECTO: " + scrapedenlace + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + scrapedsize + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) #logger.debug(item_local) + if len(itemlist_f) > 0: #Si hay entradas filtradas... + itemlist_alt.extend(itemlist_f) #Pintamos pantalla filtrada + else: + if config.get_setting('filter_languages', channel) > 0 and len(itemlist_t) > 0: #Si no hay entradas filtradas ... + thumb_separador = get_thumb("next.png") #... pintamos todo con aviso + itemlist.append(Item(channel=item.channel, url=host, title="[COLOR red][B]NO hay elementos con el idioma seleccionado[/B][/COLOR]", thumbnail=thumb_separador)) + itemlist_alt.extend(itemlist_t) #Pintar pantalla con todo si no hay filtrado + #Si son múltiples episodios, ordenamos if len(itemlist_alt) > 1 and (item.contentType == 'episode' or item.contentType == 'season'): itemlist_alt = sorted(itemlist_alt, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) #clasificamos tmdb.set_infoLabels(itemlist_alt, True) #TMDB de la lista de episodios itemlist.extend(itemlist_alt) + + # Requerido para AutoPlay + autoplay.start(itemlist, item) #Lanzamos Autoplay return itemlist diff --git a/plugin.video.alfa/channels/grantorrent.json b/plugin.video.alfa/channels/grantorrent.json index e3f8591e..37483759 100644 --- a/plugin.video.alfa/channels/grantorrent.json +++ b/plugin.video.alfa/channels/grantorrent.json @@ -22,6 +22,30 @@ "enabled": true, "visible": true }, + { + "id": "modo_grafico", + "type": "bool", + "label": "Buscar información extra (TMDB)", + "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": "seleccionar_serie_temporada", "type": "list", @@ -43,12 +67,25 @@ "visible": true }, { - "id": "modo_grafico", - "type": "bool", - "label": "Buscar información extra (TMDB)", - "default": true, + "id": "timeout_downloadpage", + "type": "list", + "label": "Timeout (segs.) en descarga de páginas o verificación de servidores", + "default": 5, "enabled": true, - "visible": true + "visible": true, + "lvalues": [ + "None", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10" + ] } ] } diff --git a/plugin.video.alfa/channels/grantorrent.py b/plugin.video.alfa/channels/grantorrent.py index 072f81fb..1a4a7df3 100644 --- a/plugin.video.alfa/channels/grantorrent.py +++ b/plugin.video.alfa/channels/grantorrent.py @@ -4,6 +4,7 @@ import re import sys import urllib import urlparse +import time from channelselector import get_thumb from core import httptools @@ -13,13 +14,24 @@ 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 = ['torrent'] host = "https://grantorrent.net/" +channel = "grantorrent" dict_url_seasons = dict() -__modo_grafico__ = config.get_setting('modo_grafico', 'grantorrent') -modo_serie_temp = config.get_setting('seleccionar_serie_temporada', 'grantorrent') -modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', 'grantorrent') +__modo_grafico__ = config.get_setting('modo_grafico', channel) +timeout = config.get_setting('timeout_downloadpage', channel) +modo_serie_temp = config.get_setting('seleccionar_serie_temporada', channel) +modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', channel) def mainlist(item): @@ -32,7 +44,10 @@ def mainlist(item): thumb_series = get_thumb("channels_tvshow.png") thumb_series_hd = get_thumb("channels_tvshow_hd.png") thumb_buscar = get_thumb("search.png") + thumb_separador = get_thumb("next.png") thumb_settings = get_thumb("setting_0.png") + + autoplay.init(item.channel, list_servers, list_quality) itemlist.append(Item(channel=item.channel, action="submenu", title="Películas", url=host, extra="peliculas", thumbnail=thumb_pelis)) @@ -43,11 +58,12 @@ def mainlist(item): #Buscar series itemlist.append(Item(channel=item.channel, action="search", title="Buscar en Series >>", url=host + "series/", extra="series", thumbnail=thumb_buscar)) + + 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="", title="[COLOR yellow]Configuración del Canal:[/COLOR]", url="", thumbnail=thumb_settings)) - itemlist.append( - Item(channel=item.channel, action="settingCanal", title="Opciones de Videoteca y TMDB", url="", thumbnail=thumb_settings)) + itemlist.append(Item(channel=item.channel, action="settingCanal", title="Configurar canal", thumbnail=thumb_settings)) + + autoplay.show_option(item.channel, itemlist) #Activamos Autoplay return itemlist @@ -120,6 +136,8 @@ def listado(item): cnt_tot = 40 # Poner el num. máximo de items por página cnt_title = 0 # Contador de líneas insertadas en Itemlist result_mode = config.get_setting("result_mode", channel="search") # Búsquedas globales: listado completo o no + if not item.extra2: + item.extra2 = '' #Sistema de paginado para evitar páginas vacías o semi-vacías en casos de búsquedas con series con muchos episodios title_lista = [] # Guarda la lista de series que ya están en Itemlist, para no duplicar lineas @@ -133,18 +151,25 @@ def listado(item): cnt_top = 10 #max. num de páginas web a leer antes de pintar total_pag = 1 post_num = 1 #num pagina actual + inicio = time.time() # Controlaremos que el proceso no exceda de un tiempo razonable + fin = inicio + 5 # 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 #Máximo num. de líneas permitidas por TMDB (40). Máx de 5 páginas por Itemlist para no degradar el rendimiento. #Si itemlist sigue vacío después de leer 5 páginas, se pueden llegar a leer hasta 10 páginas para encontrar algo - while cnt_title <= cnt_tot and cnt_next < cnt_top: + while cnt_title <= cnt_tot and cnt_next < cnt_top and fin > time.time(): # Descarga la página data = '' try: if not item.post: item.post = item.url video_section = '' - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.post).data) + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.post, timeout=timeout_search).data) video_section = scrapertools.find_single_match(data, '