From 42abd43078faafc8ab36dda004d26c3d2824bfec Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Sat, 7 Jul 2018 14:15:18 +0200 Subject: [PATCH 1/7] =?UTF-8?q?Correcci=C3=B3n=20errores=20de=20traducci?= =?UTF-8?q?=C3=B3n=20y=20mejoras=20internas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corregido error al marcar como vista/no vista una serie o película en la Videoteca de Alfa - Añadido soporte de etiquetas de idioma tipo @xxxxx, en campo ‘enabled’ en menus de confoguración - Reparación de Videlibrary.json quitando ']' en campos ‘enabled’ Newpct1: arreglo de error en series antiguas Generictools: mejora de etiquetado de títulos --- plugin.video.alfa/channels/newpct1.py | 11 +++++++++-- plugin.video.alfa/channels/videolibrary.json | 8 ++++---- plugin.video.alfa/lib/generictools.py | 9 +++++++-- plugin.video.alfa/platformcode/xbmc_config_menu.py | 5 ++++- plugin.video.alfa/platformcode/xbmc_videolibrary.py | 12 ++++++++---- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/plugin.video.alfa/channels/newpct1.py b/plugin.video.alfa/channels/newpct1.py index 7a726cb1..f0d577f7 100644 --- a/plugin.video.alfa/channels/newpct1.py +++ b/plugin.video.alfa/channels/newpct1.py @@ -1386,8 +1386,12 @@ def episodios(item): pattern = ".*?[^>]+>.*?Temporada\s*(?P\d+)?.*?Capitulo(?:s)?\s*(?P\d+)?" \ "(?:.*?(?P\d+)?)<.+?]+>(?P.*?)?<\/span>\s*Calidad\s*]+>" \ "[\[]\s*(?P.*?)?\s*[\]]<\/span>" - if "Especial" in info: # Capitulos Especiales - pattern = ".*?[^>]+>.*?Temporada.*?\[.*?(?P\d+).*?\].*?Capitulo.*?\[\s*(?P\d+).*?\]?(?:.*?(?P\d+)?)<.+?]+>(?P.*?)?<\/span>\s*Calidad\s*]+>[\[]\s*(?P.*?)?\s*[\]]<\/span>" + if not scrapertools.find_single_match(info, pattern): + if "especial" in info.lower(): # Capitulos Especiales + pattern = ".*?[^>]+>.*?Temporada.*?\[.*?(?P\d+).*?\].*?Capitulo.*?\[\s*(?P\d+).*?\]?(?:.*?(?P\d+)?)<.+?]+>(?P.*?)?<\/span>\s*Calidad\s*]+>[\[]\s*(?P.*?)?\s*[\]]<\/span>" + elif "miniserie" in info.lower() or "completa" in info.lower(): # Series o miniseries completa + logger.debug("patron episodioNEW - MINISERIE: " + info) + info = '>%sTemporada %s Capitulo 01_99 - Español Castellano Calidad [%s]' % (item_local.contentSerieName, season, item_local.quality) if not scrapertools.find_single_match(info, pattern): #en caso de error de formato, creo uno básico logger.debug("patron episodioNEW: " + pattern) @@ -1413,6 +1417,9 @@ def episodios(item): elif "completa" in info.lower(): info = info.replace("COMPLETA", "Caps. 01_99") pattern = 'Temp.*?(?P\d+).*?Cap\w?\.\s\d?(?P\d{2})(?:.*?(?P\d{2}))?.*?\[(?P.*?)\].*?\[(?P\w+)\]?' + if not scrapertools.find_single_match(info, pattern): #en caso de error de formato, creo uno básico + logger.debug(info) + info = '%s - Temp.%s [Caps. 01_99][%s][Spanish]' % (item_local.contentSerieName, season, item_local.quality) if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'): pattern = "\[(?P.*?)\].*?\[Cap.(?P\d).*?(?P\d{2})(?:_(?P\d+)" \ "(?P\d{2}))?.*?\].*?(?:\[(?P.*?)\])?" diff --git a/plugin.video.alfa/channels/videolibrary.json b/plugin.video.alfa/channels/videolibrary.json index 49121664..a68b173f 100755 --- a/plugin.video.alfa/channels/videolibrary.json +++ b/plugin.video.alfa/channels/videolibrary.json @@ -24,7 +24,7 @@ "label": "@60606", "default": 0, "visible": true, - "enabled": "eq(-1,@60603])|eq(-1,@60605])", + "enabled": "eq(-1,@60603)|eq(-1,@60605)", "lvalues": [ "No", "@60609", @@ -39,7 +39,7 @@ "label": "@60613", "default": 1, "visible": true, - "enabled": "eq(-2,@60604])|eq(-2,@60605])", + "enabled": "eq(-2,@60604)|eq(-2,@60605)", "lvalues": [ "00:00", "04:00", @@ -53,7 +53,7 @@ "label": "@60614", "default": 0, "visible": true, - "enabled": "!eq(-3,@60615])", + "enabled": "!eq(-3,@60615)", "lvalues": [ "@60616", "@60617" @@ -64,7 +64,7 @@ "type": "list", "label": "@60618", "default": 0, - "enabled": "!eq(-4,@60615])", + "enabled": "!eq(-4,@60615)", "lvalues": [ "@60619", "@60620" diff --git a/plugin.video.alfa/lib/generictools.py b/plugin.video.alfa/lib/generictools.py index dabb44d3..52962719 100644 --- a/plugin.video.alfa/lib/generictools.py +++ b/plugin.video.alfa/lib/generictools.py @@ -647,7 +647,12 @@ def post_tmdb_findvideos(item, itemlist): title = '%sx%s' % (str(item.contentSeason), str(item.contentEpisodeNumber).zfill(2)) #Temporada y Episodio if item.infoLabels['temporada_num_episodios']: title = '%s (de %s)' % (title, str(item.infoLabels['temporada_num_episodios'])) #Total Episodios - title = '%s %s' % (title, item.infoLabels['episodio_titulo']) #Título Episodio + + #Si son episodios múltiples, y viene de Videoteca, ponemos nombre de serie + if " al " in item.title and not " al " in item.infoLabels['episodio_titulo']: + title = '%s al %s - ' % (title, scrapertools.find_single_match(item.title, 'al (\d+)')) + else: + title = '%s %s' % (title, item.infoLabels['episodio_titulo']) #Título Episodio title_gen = '%s, %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR] [%s]' % (title, item.contentSerieName, item.infoLabels['year'], rating, item.quality, str(item.language), scrapertools.find_single_match(item.title, '\s\[(\d+,?\d*?\s\w[b|B])\]')) #Rating, Calidad, Idioma, Tamaño if item.infoLabels['status'] and item.infoLabels['status'].lower() == "ended": title_gen = '[TERM.] %s' % title_gen #Marca cuando la Serie está terminada y no va a haber más producción @@ -668,7 +673,7 @@ def post_tmdb_findvideos(item, itemlist): if item.channel_alt: title_gen = '[COLOR yellow]%s [/COLOR][ALT]: %s' % (item.category.capitalize(), title_gen) - elif config.get_setting("quit_channel_name", "videolibrary") == 1 and item.contentChannel == "videolibrary": + elif (config.get_setting("quit_channel_name", "videolibrary") == 1 or item.channel == channel_py) and item.contentChannel == "videolibrary": title_gen = '%s: %s' % (item.category.capitalize(), title_gen) #Pintamos el pseudo-título con toda la información disponible del vídeo diff --git a/plugin.video.alfa/platformcode/xbmc_config_menu.py b/plugin.video.alfa/platformcode/xbmc_config_menu.py index 6990071b..25c2f807 100755 --- a/plugin.video.alfa/platformcode/xbmc_config_menu.py +++ b/plugin.video.alfa/platformcode/xbmc_config_menu.py @@ -111,7 +111,7 @@ class SettingsWindow(xbmcgui.WindowXMLDialog): ] } - Los campos 'label', 'default' y 'lvalues' pueden ser un numero precedido de '@'. En cuyo caso se + Los campos 'label', 'default', 'enabled' y 'lvalues' pueden ser un numero precedido de '@'. En cuyo caso se buscara el literal en el archivo string.xml del idioma seleccionado. Los campos 'enabled' y 'visible' admiten los comparadores eq(), gt() e it() y su funcionamiento se describe en: http://kodi.wiki/view/Add-on_settings#Different_types @@ -273,6 +273,9 @@ class SettingsWindow(xbmcgui.WindowXMLDialog): if c["type"] == "label": control_value = c["control"].getLabel() + if value.startswith('@') and unicode(value[1:]).isnumeric(): + value = config.get_localized_string(int(value[1:])) + # Operaciones lt "menor que" y gt "mayor que", requieren que las comparaciones sean numeros, sino devuelve # False if operator in ["lt", "!lt", "gt", "!gt"]: diff --git a/plugin.video.alfa/platformcode/xbmc_videolibrary.py b/plugin.video.alfa/platformcode/xbmc_videolibrary.py index 6867f5a8..079099ff 100755 --- a/plugin.video.alfa/platformcode/xbmc_videolibrary.py +++ b/plugin.video.alfa/platformcode/xbmc_videolibrary.py @@ -235,8 +235,10 @@ def mark_content_as_watched_on_kodi(item, value=1): data = get_data(payload) if 'result' in data and "movies" in data['result']: - filename = filetools.basename(item.strm_path) - head, tail = filetools.split(filetools.split(item.strm_path)[0]) + #filename = filetools.basename(item.strm_path) + #head, tail = filetools.split(filetools.split(item.strm_path)[0]) + filename = filetools.basename(item.path) + head, tail = filetools.split(filetools.split(item.path)[0]) path = filetools.join(tail, filename) for d in data['result']['movies']: @@ -258,8 +260,10 @@ def mark_content_as_watched_on_kodi(item, value=1): data = get_data(payload) if 'result' in data and "episodes" in data['result']: - filename = filetools.basename(item.strm_path) - head, tail = filetools.split(filetools.split(item.strm_path)[0]) + #filename = filetools.basename(item.strm_path) + #head, tail = filetools.split(filetools.split(item.strm_path)[0]) + filename = filetools.basename(item.path) + head, tail = filetools.split(filetools.split(item.path)[0]) path = filetools.join(tail, filename) for d in data['result']['episodes']: From d85583ca57c28c6d7c81f907d78ce73306efed4a Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Tue, 10 Jul 2018 19:25:59 +0200 Subject: [PATCH 2/7] =?UTF-8?q?Trailertools:=20reparaci=C3=B3n=20de=20erro?= =?UTF-8?q?res?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Error por problemas de decode --- plugin.video.alfa/channels/trailertools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.video.alfa/channels/trailertools.py b/plugin.video.alfa/channels/trailertools.py index 7168101e..e4336ba1 100755 --- a/plugin.video.alfa/channels/trailertools.py +++ b/plugin.video.alfa/channels/trailertools.py @@ -165,7 +165,7 @@ def youtube_search(item): patron += """url":"([^"]+)""" matches = scrapertools.find_multiple_matches(data, patron) for scrapedthumbnail, scrapedtitle, scrapedduration, scrapedurl in matches: - scrapedtitle = scrapedtitle.decode("utf-8") + scrapedtitle = scrapedtitle.decode('utf8').encode('utf8') scrapedtitle = scrapedtitle + " (" + scrapedduration + ")" if item.contextual: scrapedtitle = "[COLOR white]%s[/COLOR]" % scrapedtitle From 3d8998988155d609fac888c702f561e62a2c2a2c Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Tue, 10 Jul 2018 19:26:43 +0200 Subject: [PATCH 3/7] =?UTF-8?q?NewPct1:=20implantaci=C3=B3n=20de=20apartad?= =?UTF-8?q?o=20de=20Novedades?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/channels/newpct1.json | 29 +- plugin.video.alfa/channels/newpct1.py | 336 +++++++++++++++++++----- plugin.video.alfa/lib/generictools.py | 167 ++++++++---- 3 files changed, 405 insertions(+), 127 deletions(-) diff --git a/plugin.video.alfa/channels/newpct1.json b/plugin.video.alfa/channels/newpct1.json index a121e330..8be41cb8 100644 --- a/plugin.video.alfa/channels/newpct1.json +++ b/plugin.video.alfa/channels/newpct1.json @@ -53,7 +53,7 @@ "id": "clonenewpct1_channels_list", "type": "text", "label": "Lista de clones de NewPct1 y orden de uso", - "default": "('1', 'torrentrapid', 'http://torrentrapid.com/', 'movie, tvshow, season, episode', ''), ('1', 'torrentlocura', 'http://torrentlocura.com/', 'movie, tvshow, season, episode', ''), ('1', 'tumejortorrent', 'http://tumejortorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'tvsinpagar', 'http://www.tvsinpagar.com/', 'tvshow, season, episode', ''), ('1', 'descargas2020', 'http://descargas2020.com/', 'movie, tvshow, season, episode', ''), ('1', 'mispelisyseries', 'http://mispelisyseries.com/', 'movie', 'search')", + "default": "('1', 'torrentrapid', 'http://torrentrapid.com/', 'movie, tvshow, season, episode', 'serie_episodios'), ('1', 'torrentlocura', 'http://torrentlocura.com/', 'movie, tvshow, season, episode', ''), ('1', 'tumejortorrent', 'http://tumejortorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'tvsinpagar', 'http://www.tvsinpagar.com/', 'tvshow, season, episode', ''), ('1', 'descargas2020', 'http://descargas2020.com/', 'movie, tvshow, season, episode', ''), ('1', 'mispelisyseries', 'http://mispelisyseries.com/', 'movie', 'search, listado_busqueda')", "enabled": true, "visible": false }, @@ -560,6 +560,33 @@ "9", "10" ] + }, + { + "id": "clonenewpct1_rango_fechas_novedades", + "type": "list", + "label": "Rango de fechas para búsquedas en Novedades", + "default": 2, + "enabled": true, + "visible": true, + "lvalues": [ + "Hoy", + "Ayer", + "Semana", + "Mes", + "Siempre" + ] + }, + { + "id": "clonenewpct1_serie_episodio_novedades", + "type": "list", + "label": "Ver en Novedades las series como episodios sueltos o serie completa", + "default": 1, + "enabled": true, + "visible": true, + "lvalues": [ + "Episodios sueltos", + "Serie completa" + ] } ] } \ No newline at end of file diff --git a/plugin.video.alfa/channels/newpct1.py b/plugin.video.alfa/channels/newpct1.py index f0d577f7..5b36dfd9 100644 --- a/plugin.video.alfa/channels/newpct1.py +++ b/plugin.video.alfa/channels/newpct1.py @@ -11,6 +11,7 @@ from channelselector import get_thumb from core import httptools from core import scrapertools from core import servertools +from core import channeltools from core.item import Item from platformcode import config, logger from core import tmdb @@ -19,7 +20,12 @@ from lib import generictools channel_py = 'newpct1' #Código para permitir usar un único canal para todas las webs clones de NewPct1 -clone_list = config.get_setting('clonenewpct1_channels_list', channel_py) #Carga lista de clones +#Cargamos en .json del canal para ver las listas de valores en settings +clone_list = channeltools.get_channel_json(channel_py) +for settings in clone_list['settings']: #Se recorren todos los settings + if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting + clone_list = settings['default'] #Carga lista de clones + break clone_list = ast.literal_eval(clone_list) #la convierte en array host_index = 0 host_index = config.get_setting('clonenewpct1_channel_default', channel_py) #Clone por defecto @@ -39,6 +45,13 @@ __modo_grafico__ = config.get_setting('modo_grafico', channel_py) modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', channel_py) #Actualización sólo últ. Temporada? timeout = config.get_setting('clonenewpct1_timeout_downloadpage', channel_py) #Timeout downloadpage if timeout == 0: timeout = None +fecha_rango = config.get_setting('clonenewpct1_rango_fechas_novedades', channel_py) #Rango fechas para Novedades +if fecha_rango == 0: fecha_rango = 'Hoy' +elif fecha_rango == 1: fecha_rango = 'Ayer' +elif fecha_rango == 2: fecha_rango = 'Semana' +elif fecha_rango == 3: fecha_rango = 'Mes' +elif fecha_rango == 4: fecha_rango = 'Siempre' +episodio_serie = config.get_setting('clonenewpct1_serie_episodio_novedades', channel_py) #Episodio o serie para Novedades def mainlist(item): @@ -60,6 +73,8 @@ def mainlist(item): thumb_buscar = get_thumb("search.png") thumb_settings = get_thumb("setting_0.png") + itemlist.append(Item(channel=item.channel, action="submenu_novedades", title="Novedades", url=item.channel_host + "ultimas-descargas/", extra="novedades", thumbnail=thumb_pelis, category=item.category, channel_host=item.channel_host)) + itemlist.append(Item(channel=item.channel, action="submenu", title="Películas", url=item.channel_host, extra="peliculas", thumbnail=thumb_pelis, category=item.category, channel_host=item.channel_host)) @@ -88,6 +103,7 @@ def settingCanal(item): def submenu(item): logger.info() + itemlist = [] data = '' @@ -148,6 +164,82 @@ def submenu(item): return itemlist +def submenu_novedades(item): + logger.info() + + itemlist = [] + itemlist_alt = [] + + data = '' + timeout_search=timeout * 2 #Más tiempo para Novedades, que es una búsqueda + + #Establecer los valores del .json por si se entra directamente desde un favorito + item.channel_host = host + item.url = host + "ultimas-descargas/" + item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() + item.extra = "novedades" + + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, timeout=timeout_search).data) + except: + pass + + patron = '
.*?
' in data): + logger.error("ERROR 01: LISTADO_BUSQUEDA: La Web no responde o ha cambiado de URL: " + item_local.url + " / DATA: " + data_serie) + #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el cambio de episodio por serie + item_local, data_serie = generictools.fail_over_newpct1(item_local, pattern) + + if not data_serie: #Si no ha logrado encontrar nada, salimos + title_subs += ["ERR"] + + elif item_local.channel_alt: #Si ha habido fail-over, lo comento + scrapedurl = scrapedurl.replace(item_local.channel_alt, item_local.category.lower()) + title_subs += ["ALT"] + + try: + pattern = '
.*?

.*?= "1900" and year <= "2040" and year != "2020": title_subs += [year] item_local.infoLabels['year'] = '-' @@ -830,11 +1001,11 @@ def listado_busqueda(item): item_local.title_subs = title_subs # Codigo para rescatar lo que se pueda en pelisy.series.com de Series para la Videoteca. la URL apunta al capítulo y no a la Serie. Nombre de Serie frecuentemente en blanco. Se obtiene de Thumb, así como el id de la serie - if ("/serie" in item_local.url or "-serie" in item_local.url) and "pelisyseries.com" in host: + if ("/serie" in item_local.url or "-serie" in item_local.url) and "pelisyseries.com" in item_local.channel_host: #Extraer la calidad de la serie basados en la info de la url - if "seriehd" in url: + if "seriehd" in item_local.url: calidad_mps = "series-hd/" - elif "serievo" in url or "serie-vo" in url: + elif "serievo" in item_local.url or "serie-vo" in item_local.url: calidad_mps = "series-vo/" else: calidad_mps = "series/" @@ -847,7 +1018,7 @@ def listado_busqueda(item): #Extraer el ID de la serie desde Thumbs (4 dígitos). Si no hay, nulo if "/0_" not in scrapedthumbnail and not "no_image" in scrapedthumbnail: - serieid = scrapertools.find_single_match(scrapedthumbnail, r'.*?\/\w\/(?P\d+).*?.*') + serieid = scrapertools.find_single_match(scrapedthumbnail, r'\/\w\/(?P\d+)') if len(serieid) > 5: serieid = "" else: @@ -879,13 +1050,14 @@ def listado_busqueda(item): #logger.debug("url: " + item_local.url + " / title o/n: " + item_local.title + " / " + real_title_mps + " / calidad_mps : " + calidad_mps + " / contentType : " + item_local.contentType) - item_local.title = real_title_mps #Esperemos que el nuevo título esté bien + item_local.title = real_title_mps.replace('-', ' ').title().strip() #Esperemos que el nuevo título esté bien + item_local.contentSerieName = item_local.title #Agrega el item local a la lista itemlist itemlist.append(item_local.clone()) - 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 + if not item.category_new: #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 #Pasamos a TMDB la lista completa Itemlist tmdb.set_infoLabels(itemlist, __modo_grafico__) @@ -901,12 +1073,11 @@ def listado_busqueda(item): return itemlist def findvideos(item): - from core import channeltools logger.info() #Renombramos el canal al nombre de clone elegido. Actualizados URL host = scrapertools.find_single_match(item.url, '(http.?\:\/\/(?:www.)?\w+\.\w+\/)') - #item.channel = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/') + item.channel_host = host item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() itemlist = [] @@ -1266,10 +1437,16 @@ def episodios(item): #Renombramos el canal al nombre de clone elegido. Actualizados URL host = scrapertools.find_single_match(item.url, '(http.?\:\/\/(?:www.)?\w+\.\w+\/)') - #item.channel = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/') + item.channel_host = host item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() itemlist = [] + + #Limpiamos num. Temporada y Episodio que ha podido quedar por Novedades + if item.contentSeason: + del item.infoLabels['season'] + if item.contentEpisodeNumber: + del item.infoLabels['episode'] # Obtener la información actualizada de la Serie. TMDB es imprescindible para Videoteca if not item.infoLabels['tmdb_id']: @@ -1287,10 +1464,14 @@ def episodios(item): max_temp = max(y) data = '' + data_alt = '' try: + if "pelisyseries.com" in item.url: + patron = '
    (.*?)
' % "chapters" # item.pattern + else: + patron = '
    (.*?)
' % "buscar-list" # item.pattern + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, timeout=timeout).data) - patron = '
    (.*?)
' % "buscar-list" # item.pattern - data_alt = '' if data: data_alt = scrapertools.get_match(data, patron) except: #Algún error de proceso pass @@ -1303,6 +1484,7 @@ def episodios(item): #Verificamos si se ha cargado una página, y si además tiene la estructura correcta if not data_alt or not scrapertools.find_single_match(data_alt, pattern): logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea: " + item.url) + logger.error(pattern + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el vídeo item, data = generictools.fail_over_newpct1(item, patron, pattern) @@ -1472,9 +1654,10 @@ def episodios(item): item_local.infoLabels['episodio_titulo'] = match['lang'] item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo'] - item_local.contentEpisodeNumber = match['episode'] if match['episode'] == 0: match['episode'] = 1 #Evitar errores en Videoteca + item_local.contentEpisodeNumber = match['episode'] + if match["episode2"]: #Hay episodio dos? es una entrada múltiple? item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios else: #Si es un solo episodio, se formatea ya @@ -1543,6 +1726,7 @@ def search(item, texto): # texto = texto.replace(" ", "+") try: + item.url = host + "buscar" item.post = "q=%s" % texto item.pattern = "buscar-list" itemlist = listado_busqueda(item) @@ -1563,51 +1747,57 @@ def newest(categoria): item.title = "newest" item.category = "newest" - item.action = "listado" - item.channel = scrapertools.find_single_match(host, r'(\w+)\.com\/') + item.channel = channel_py try: if categoria == 'peliculas': - item.url = host+'peliculas/' + item.url = host + 'ultimas-descargas/' + value = 757 + item.post = "categoryIDR=%s&date=%s" % (value, fecha_rango) + item.extra = "novedades" + item.action = "listado_busqueda" + itemlist = listado_busqueda(item) + + elif categoria == 'series': + item.url = host + 'ultimas-descargas/' + value = 767 + item.post = "categoryIDR=%s&date=%s" % (value, fecha_rango) + item.extra = "novedades" + item.action = "listado_busqueda" + itemlist = listado_busqueda(item) + + elif categoria == '4k': + item.url = host + 'ultimas-descargas/' + value = 1027 + item.post = "categoryIDR=%s&date=%s" % (value, fecha_rango) + item.extra = "novedades" + item.action = "listado_busqueda" + itemlist = listado_busqueda(item) + + elif categoria == 'anime': + item.url = host + 'anime/' item.extra = "peliculas" + item.action = "listado" itemlist = listado(item) - if ">> Página siguiente" in itemlist[-1].title: - itemlist.pop() - - if categoria == 'series': - item.url = host+'series/' - item.extra = "series" - itemlist.extend(listado(item)) - if ">> Página siguiente" in itemlist[-1].title: - itemlist.pop() - - if categoria == '4k': - item.url = host+'peliculas-hd/4kultrahd/' - item.extra = "peliculas" - itemlist.extend(listado(item)) - if ">> Página siguiente" in itemlist[-1].title: - itemlist.pop() - - if categoria == 'anime': - item.url = host+'anime/' - item.extra = "peliculas" - itemlist.extend(listado(item)) - if ">> Página siguiente" in itemlist[-1].title: - itemlist.pop() - if categoria == 'documentales': - item.url = host+'documentales/' - item.extra = "varios" - itemlist.extend(listado(item)) - if ">> Página siguiente" in itemlist[-1].title: - itemlist.pop() + elif categoria == 'documentales': + item.url = host + 'ultimas-descargas/' + value = 780 + item.post = "categoryIDR=%s&date=%s" % (value, fecha_rango) + item.extra = "novedades" + item.action = "listado_busqueda" + itemlist = listado_busqueda(item) - if categoria == 'latino': - item.url = host+'peliculas-latino/' - item.extra = "peliculas" - itemlist.extend(listado(item)) - if ">> Página siguiente" in itemlist[-1].title: - itemlist.pop() + elif categoria == 'latino': + item.url = host + 'ultimas-descargas/' + value = 1527 + item.post = "categoryIDR=%s&date=%s" % (value, fecha_rango) + item.extra = "novedades" + item.action = "listado_busqueda" + itemlist = listado_busqueda(item) + + if ">> Página siguiente" in itemlist[-1].title or "Pagina siguiente >>" in itemlist[-1].title: + itemlist.pop() # Se captura la excepción, para no interrumpir al canal novedades si un canal falla except: diff --git a/plugin.video.alfa/lib/generictools.py b/plugin.video.alfa/lib/generictools.py index 52962719..15007ee2 100644 --- a/plugin.video.alfa/lib/generictools.py +++ b/plugin.video.alfa/lib/generictools.py @@ -17,6 +17,7 @@ from channelselector import get_thumb from core import httptools from core import scrapertools from core import servertools +from core import channeltools from core.item import Item from platformcode import config, logger from core import tmdb @@ -57,6 +58,7 @@ def update_title(item): Si lo hace en "Completar Información", cambia al nuevo título, pero no busca en TMDB. Hay que hacerlo de nuevo Si se cancela la segunda pantalla, la variable "scraper_return" estará en False. El usuario no quiere seguir """ + #logger.debug(item) #Restauramos y borramos las etiquetas intermedias (si se ha llamado desde el canal) if item.from_action: @@ -65,14 +67,16 @@ def update_title(item): if item.from_title: item.title = item.from_title del item.from_title - else: - if item.contentType != "movie": - item.add_videolibrary = True #Estamos Añadiendo a la Videoteca. Indicador para control de uso de los Canales - else: - if item.channel == channel_py: #Si es una peli de NewPct1, ponemos el nombre del clone - item.channel = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/') + elif item.contentType != "movie": + item.add_videolibrary = True #Estamos Añadiendo a la Videoteca. Indicador para control de uso de los Canales + if item.contentType == "movie": + if item.channel == channel_py: #Si es una peli de NewPct1, ponemos el nombre del clone + item.channel = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/') if item.channel_host: #Borramos ya el indicador para que no se guarde en la Videoteca del item.channel_host + if item.contentTitle: + item.contentTitle = re.sub(r' -%s-' % item.category, '', item.contentTitle) + item.title = re.sub(r' -%s-' % item.category, '', item.title) #Sólo ejecutamos este código si no se ha hecho antes en el Canal. Por ejemplo, si se ha llamado desde Episodios, #ya no se ejecutará al Añadia a Videoteca, aunque desde el canal se podrá llamar tantas veces como se quiera, @@ -114,29 +118,31 @@ def update_title(item): item.tmdb_stat = True #Marcamos Item como procesado correctamente por TMDB (pasada 1) #Si el usuario ha seleccionado una opción distinta o cambiado algo, ajustamos los títulos - if new_item.contentSerieName: #Si es serie... - item.title = item.title.replace(new_item.contentSerieName, item.contentTitle) - item.contentSerieName = item.contentTitle - if new_item.contentSeason: item.contentSeason = new_item.contentSeason #Restauramos Temporada - if item.infoLabels['title']: del item.infoLabels['title'] #Borramos título de peli (es serie) - else: #Si es película... - item.title = item.title.replace(new_item.contentTitle, item.contentTitle) - if new_item.infoLabels['year']: #Actualizamos el Año en el título - item.title = item.title.replace(str(new_item.infoLabels['year']), str(item.infoLabels['year'])) - if new_item.infoLabels['rating']: #Actualizamos en Rating en el título - rating_old = '' - if new_item.infoLabels['rating'] and new_item.infoLabels['rating'] != '0.0': - rating_old = float(new_item.infoLabels['rating']) - rating_old = round(rating_old, 1) - rating_new = '' - if item.infoLabels['rating'] and item.infoLabels['rating'] != '0.0': - rating_new = float(item.infoLabels['rating']) - rating_new = round(rating_new, 1) - item.title = item.title.replace("[" + str(rating_old) + "]", "[" + str(rating_new) + "]") - if item.wanted: #Actualizamos Wanted, si existe - item.wanted = item.contentTitle - if new_item.contentSeason: #Restauramos el núm. de Temporada después de TMDB - item.contentSeason = new_item.contentSeason + if item.tmdb_stat == True: + if new_item.contentSerieName: #Si es serie... + item.title_from_channel = new_item.contentSerieName #Guardo el título incial para Filtertools + item.title = item.title.replace(new_item.contentSerieName, item.contentTitle) + item.contentSerieName = item.contentTitle + if new_item.contentSeason: item.contentSeason = new_item.contentSeason #Restauramos Temporada + if item.infoLabels['title']: del item.infoLabels['title'] #Borramos título de peli (es serie) + else: #Si es película... + item.title = item.title.replace(new_item.contentTitle, item.contentTitle) + if new_item.infoLabels['year']: #Actualizamos el Año en el título + item.title = item.title.replace(str(new_item.infoLabels['year']), str(item.infoLabels['year'])) + if new_item.infoLabels['rating']: #Actualizamos en Rating en el título + rating_old = '' + if new_item.infoLabels['rating'] and new_item.infoLabels['rating'] != '0.0': + rating_old = float(new_item.infoLabels['rating']) + rating_old = round(rating_old, 1) + rating_new = '' + if item.infoLabels['rating'] and item.infoLabels['rating'] != '0.0': + rating_new = float(item.infoLabels['rating']) + rating_new = round(rating_new, 1) + item.title = item.title.replace("[" + str(rating_old) + "]", "[" + str(rating_new) + "]") + if item.wanted: #Actualizamos Wanted, si existe + item.wanted = item.contentTitle + if new_item.contentSeason: #Restauramos el núm. de Temporada después de TMDB + item.contentSeason = new_item.contentSeason #Para evitar el "efecto memoria" de TMDB, se le llama con un título ficticio para que resetee los buffers if item.contentSerieName: @@ -172,6 +178,7 @@ def post_tmdb_listado(item, itemlist): item, itemlist = generictools.post_tmdb_listado(item, itemlist) """ + #logger.debug(item) #Borramos valores si ha habido fail-over channel_alt = '' @@ -181,12 +188,14 @@ def post_tmdb_listado(item, itemlist): if item.url_alt: del item.url_alt #Ajustamos el nombre de la categoría - if item.category != "newest": - item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() + if not item.category_new: + item.category_new = '' + item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() for item_local in itemlist: #Recorremos el Itenlist generado por el canal title = item_local.title - + #logger.debug(item_local) + if item_local.contentSeason_save: #Restauramos el num. de Temporada item_local.contentSeason = item_local.contentSeason_save @@ -197,8 +206,7 @@ def post_tmdb_listado(item, itemlist): del item_local.url_alt #Ajustamos el nombre de la categoría - if item_local.category != "newest": - item_local.category = scrapertools.find_single_match(item_local.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() + item_local.category = scrapertools.find_single_match(item_local.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() #Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item title_add = ' ' @@ -211,9 +219,9 @@ def post_tmdb_listado(item, itemlist): if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-": item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})') continue - + title_add = title_add.rstrip() - title_add += '%s -%s-' % (title_add, title_subs) #se agregan el resto de etiquetas salvadas + title_add = '%s -%s-' % (title_add, title_subs) #se agregan el resto de etiquetas salvadas item_local.title_subs = [] del item_local.title_subs @@ -233,7 +241,7 @@ def post_tmdb_listado(item, itemlist): # Para Episodios, tomo el año de exposición y no el de inicio de la serie elif item_local.infoLabels['aired']: item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})') - + # Preparamos el título para series, con los núm. de temporadas, si las hay if item_local.contentType in ['season', 'tvshow', 'episode']: if item_local.infoLabels['title']: del item_local.infoLabels['title'] @@ -252,8 +260,14 @@ def post_tmdb_listado(item, itemlist): item_local.infoLabels['episodio_titulo'] = '%s, %s [%s] [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.contentSerieName, item_local.infoLabels['year'], rating) else: #Si no hay título de episodio, ponermos el nombre de la serie - title = '%s %s' % (title, item_local.contentSerieName) + if item_local.contentSerieName not in title: + title = '%s %s' % (title, item_local.contentSerieName) item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.contentSerieName, item_local.infoLabels['year'], rating) + + if not item_local.contentSeason or not item_local.contentEpisodeNumber: + if "Episodio" in title_add: + item_local.contentSeason, item_local.contentEpisodeNumber = scrapertools.find_single_match(title_add, 'Episodio (\d+)x(\d+)') + title = '%s [%s] [%s]' % (title, item_local.infoLabels['year'], rating) elif item_local.contentType == "season": if not item_local.contentSeason: @@ -271,7 +285,7 @@ def post_tmdb_listado(item, itemlist): elif item.action == "search": title += " -Serie-" - elif item_local.extra == "varios" and item.action == "search": + elif item_local.extra == "varios" and (item.action == "search" or item.action == "listado_busqueda"): title += " -Varios-" item_local.contentTitle += " -Varios-" @@ -282,7 +296,7 @@ def post_tmdb_listado(item, itemlist): title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language)) else: #Si Titulos Inteligentes SÍ seleccionados: - title = title.replace("[", "-").replace("]", "-") + title = title.replace("[", "-").replace("]", "-").replace(".", ",") #Limpiamos las etiquetas vacías if item_local.infoLabels['episodio_titulo']: @@ -291,10 +305,13 @@ def post_tmdb_listado(item, itemlist): title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip() title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip() - if item.category == "newest": #Viene de Novedades. Marcamos el título con el nombre del canal + if item.category_new == "newest": #Viene de Novedades. Marcamos el título con el nombre del canal title += ' -%s-' % scrapertools.find_single_match(item_local.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() if item_local.contentType == "movie": item_local.contentTitle += ' -%s-' % scrapertools.find_single_match(item_local.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() + elif "Episodio " in title: + if not item_local.contentSeason or not item_local.contentEpisodeNumber: + item_local.contentSeason, item_local.contentEpisodeNumber = scrapertools.find_single_match(title_add, 'Episodio (\d+)x(\d+)') item_local.title = title @@ -303,10 +320,12 @@ def post_tmdb_listado(item, itemlist): #logger.debug(item_local) #Si ha habido fail-over, lo comento - if channel_alt: + if channel_alt and item.category_new != "newest": itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR] [ALT ] en uso')) itemlist.append(item.clone(action='', title="[COLOR yellow]" + channel_alt.capitalize() + '[/COLOR] inaccesible')) + del item.category_new + return (item, itemlist) @@ -329,6 +348,7 @@ def post_tmdb_episodios(item, itemlist): item, itemlist = generictools.post_tmdb_episodios(item, itemlist) """ + #logger.debug(item) modo_serie_temp = '' if config.get_setting('seleccionar_serie_temporada', item.channel) >= 0: @@ -371,6 +391,8 @@ def post_tmdb_episodios(item, itemlist): if item.url_alt: item.url = item.url_alt del item.url_alt + if item.title_from_channel: + del item.title_from_channel for item_local in itemlist: #Recorremos el Itenlist generado por el canal if item_local.add_videolibrary: @@ -379,6 +401,8 @@ def post_tmdb_episodios(item, itemlist): del item_local.add_menu if item_local.contentSeason_save: del item_local.contentSeason_save + if item_local.title_from_channel: + del item_local.title_from_channel #Ajustamos el nombre de la categoría si es un clone de NewPct1 item_local.category = scrapertools.find_single_match(item_local.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() @@ -538,20 +562,20 @@ def post_tmdb_episodios(item, itemlist): videolibrarytools.save_tvshow(item, itemlist_fake) #Se actualiza el .nfo except: logger.error("ERROR 08: EPISODIOS: No se ha podido actualizar la URL a la nueva Temporada") - itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a la Videoteca[/COLOR]" + title, action="add_serie_to_library")) + itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a Videoteca-[/COLOR]" + title, action="add_serie_to_library")) elif modo_serie_temp == 1: #si es Serie damos la opción de guardar la última temporada o la serie completa - itemlist.append(item.clone(title="[COLOR yellow]Añadir última Temp. a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="season", contentSeason=contentSeason, url=item_local.url, add_menu=True)) - itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="tvshow", add_menu=True)) + itemlist.append(item.clone(title="[COLOR yellow]Añadir última Temp. a Videoteca-[/COLOR]" + title, action="add_serie_to_library", contentType="season", contentSeason=contentSeason, url=item_local.url, add_menu=True)) + itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a Videoteca-[/COLOR]" + title, action="add_serie_to_library", contentType="tvshow", add_menu=True)) else: #si no, damos la opción de guardar la temporada actual o la serie completa - itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="tvshow", add_menu=True)) + itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a Videoteca-[/COLOR]" + title, action="add_serie_to_library", contentType="tvshow", add_menu=True)) if item.add_videolibrary and not item.add_menu: item.contentSeason = contentSeason - itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Temp. a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="season", contentSeason=contentSeason, add_menu=True)) + itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Temp. a Videoteca-[/COLOR]" + title, action="add_serie_to_library", contentType="season", contentSeason=contentSeason, add_menu=True)) else: #Es un canal estándar, sólo una linea de Añadir a Videoteca - itemlist.append(item.clone(title="[COLOR yellow]Añadir esta serie a la videoteca[/COLOR]" + title, action="add_serie_to_library", extra="episodios", add_menu=True)) + itemlist.append(item.clone(title="[COLOR yellow]Añadir esta serie a videoteca-[/COLOR]" + title, action="add_serie_to_library", extra="episodios", add_menu=True)) #Si ha habido fail-over, lo comento if channel_alt: @@ -618,7 +642,12 @@ def post_tmdb_findvideos(item, itemlist): item.infoLabels['temporada_num_episodios'] = num_episodios except: pass - + + #Quitamos el la categoría o nombre del título, si lo tiene + if item.contentTitle: + item.contentTitle = re.sub(r' -%s-' % item.category, '', item.contentTitle) + item.title = re.sub(r' -%s-' % item.category, '', item.title) + #Limpiamos de año y rating de episodios if item.infoLabels['episodio_titulo']: item.infoLabels['episodio_titulo'] = re.sub(r'\s?\[.*?\]', '', item.infoLabels['episodio_titulo']) @@ -665,6 +694,7 @@ def post_tmdb_findvideos(item, itemlist): title_gen = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title_gen).strip() #Quitamos etiquetas vacías title_gen = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title_gen).strip() #Quitamos colores vacíos title_gen = title_gen.replace(" []", "").strip() #Quitamos etiquetas vacías + title_videoteca = title_gen #Salvamos el título para Videoteca if not item.unify: #Si Titulos Inteligentes NO seleccionados: title_gen = '**- [COLOR gold]Enlaces Ver: [/COLOR]%s[COLOR gold] -**[/COLOR]' % (title_gen) @@ -681,6 +711,14 @@ def post_tmdb_findvideos(item, itemlist): item.server = "" itemlist.append(item.clone(title=title_gen)) #Título con todos los datos del vídeo + #agregamos la opción de Añadir a Videoteca para péliculas (no series) + if item.contentType == 'movie' and item.contentChannel != "videolibrary": + itemlist.append(item.clone(title="**-[COLOR yellow] Añadir a la videoteca [/COLOR]-**", action="add_pelicula_to_library", extra="películas", from_title=title_videoteca)) + + #Añadimos la opción de ver trailers + if item.contentChannel != "videolibrary": + itemlist.append(item.clone(channel="trailertools", title="**-[COLOR magenta] Buscar Trailer [/COLOR]-**", action="buscartrailer", context="")) + #logger.debug(item) return (item, itemlist) @@ -713,16 +751,28 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None): - Saida: data: devuelve los datos del la nueva web. Si vuelve vacía es que no se ha encontrado alternativa """ + #logger.debug(item) if timeout == None: timeout = config.get_setting('clonenewpct1_timeout_downloadpage', channel_py) #Timeout downloadpage if timeout == 0: timeout = None + if item.action == "search" or item.action == "listado_busqueda": timeout = timeout * 2 #Mas tiempo para búsquedas data = '' channel_failed = '' + if not item.category: + item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() + if not item.extra2: + item.extra2 = 'z9z8z7z6z5' #Array con los datos de los canales alternativos - fail_over_list = config.get_setting('clonenewpct1_channels_list', channel_py) + #Cargamos en .json del canal para ver las listas de valores en settings + fail_over_list = channeltools.get_channel_json(channel_py) + for settings in fail_over_list['settings']: #Se recorren todos los settings + if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting + fail_over_list = settings['default'] #Carga lista de clones + break + #fail_over_list = config.get_setting('clonenewpct1_channels_list', channel_py) fail_over_list = ast.literal_eval(fail_over_list) #Recorremos el Array identificando el canal que falla @@ -738,17 +788,18 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None): channel_url_failed = item.url #salvamos la url if (item.action == 'episodios' or item.action == 'findvideos') and item.contentType not in contentType: #soporta el fail_over de este contenido? data = '' + logger.error("ERROR 99: " + item.action.upper() + ": Acción no soportada para Fail-Over en canal: " + item.url) return (item, data) #no soporta el fail_over de este contenido, no podemos hacer nada break if not channel_failed: - logger.debug(item) + logger.error(item) return (item, data) #Algo no ha funcionado, no podemos hacer nada #Recorremos el Array identificando canales activos que funcionen, distintos del caído, que soporten el contenido for active, channel, channel_host, contentType, action_excluded in fail_over_list: data_alt = '' - if channel == channel_failed or active == '0' or item.action in action_excluded: #es válido el nuevo canal? + if channel == channel_failed or active == '0' or item.action in action_excluded or item.extra2 in action_excluded: #es válido el nuevo canal? continue if (item.action == 'episodios' or item.action == 'findvideos') and item.contentType not in contentType: #soporta el contenido? continue @@ -787,6 +838,7 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None): data_alt = scrapertools.find_single_match(data_alt, patron2) if not data_alt: #no ha habido suerte, probamos con el siguiente canal logger.error("ERROR 02: " + item.action + ": Ha cambiado la estructura de la Web: " + item.url + " / Patron: " + patron) + data = '' continue else: break #por fin !!! Este canal parece que funciona @@ -795,6 +847,7 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None): data = '' continue + del item.extra2 #Borramos acción temporal excluyente if not data: #Si no ha logrado encontrar nada, salimos limpiando variables if item.channel == channel_py: if item.channel_alt: @@ -809,6 +862,8 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None): del item.url_alt item.channel_host = channel_host_failed + #logger.debug(item) + return (item, data) @@ -832,7 +887,13 @@ def redirect_clone_newpct1(item): """ #Array con los datos de los canales alternativos - fail_over_list = config.get_setting('clonenewpct1_channels_list', channel_py) + #Cargamos en .json del canal para ver las listas de valores en settings + fail_over_list = channeltools.get_channel_json(channel_py) + for settings in fail_over_list['settings']: #Se recorren todos los settings + if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting + fail_over_list = settings['default'] #Carga lista de clones + break + #fail_over_list = config.get_setting('clonenewpct1_channels_list', channel_py) channel = "'%s'" % item.channel if channel in fail_over_list: From bcd38eff4e71fff4fbbb398c368218c37eb5d4d9 Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Wed, 11 Jul 2018 17:50:17 +0200 Subject: [PATCH 4/7] Clones de Newpct1: Borrado --- plugin.video.alfa/channels/descargas2020.json | 471 ----- plugin.video.alfa/channels/descargas2020.py | 1625 ----------------- .../channels/mispelisyseries.json | 470 ----- plugin.video.alfa/channels/mispelisyseries.py | 1625 ----------------- plugin.video.alfa/channels/torrentlocura.json | 471 ----- plugin.video.alfa/channels/torrentlocura.py | 1625 ----------------- plugin.video.alfa/channels/torrentrapid.json | 565 ------ plugin.video.alfa/channels/torrentrapid.py | 1625 ----------------- .../channels/tumejortorrent.json | 471 ----- plugin.video.alfa/channels/tumejortorrent.py | 1625 ----------------- plugin.video.alfa/channels/tvsinpagar.json | 471 ----- plugin.video.alfa/channels/tvsinpagar.py | 1625 ----------------- plugin.video.alfa/lib/generictools.py | 9 +- .../platformcode/xbmc_videolibrary.py | 20 +- 14 files changed, 18 insertions(+), 12680 deletions(-) delete mode 100755 plugin.video.alfa/channels/descargas2020.json delete mode 100644 plugin.video.alfa/channels/descargas2020.py delete mode 100755 plugin.video.alfa/channels/mispelisyseries.json delete mode 100644 plugin.video.alfa/channels/mispelisyseries.py delete mode 100755 plugin.video.alfa/channels/torrentlocura.json delete mode 100755 plugin.video.alfa/channels/torrentlocura.py delete mode 100644 plugin.video.alfa/channels/torrentrapid.json delete mode 100644 plugin.video.alfa/channels/torrentrapid.py delete mode 100644 plugin.video.alfa/channels/tumejortorrent.json delete mode 100644 plugin.video.alfa/channels/tumejortorrent.py delete mode 100644 plugin.video.alfa/channels/tvsinpagar.json delete mode 100644 plugin.video.alfa/channels/tvsinpagar.py diff --git a/plugin.video.alfa/channels/descargas2020.json b/plugin.video.alfa/channels/descargas2020.json deleted file mode 100755 index 48da7e45..00000000 --- a/plugin.video.alfa/channels/descargas2020.json +++ /dev/null @@ -1,471 +0,0 @@ -{ - "id": "descargas2020", - "name": "Descargas2020", - "active": false, - "adult": false, - "language": ["cast", "lat"], - "thumbnail": "http://descargas2020.com/d20/library/content/template/images/_logod2020.png", - "banner": "", - "categories": [ - "movie", - "tvshow", - "anime", - "torrent", - "documentary", - "vos", - "direct" - ], - "settings": [ - { - "id": "include_in_global_search", - "type": "bool", - "label": "Incluir en busqueda global", - "default": false, - "enabled": true, - "visible": true - }, - { - "id": "modo_grafico", - "type": "bool", - "label": "Buscar información extra (TMDB)", - "default": true, - "enabled": true, - "visible": true - }, - { - "id": "seleccionar_ult_temporadda_activa", - "type": "bool", - "label": "Seleccionar para Videoteca si estará activa solo la última Temporada", - "default": true, - "enabled": true, - "visible": true - }, - { - "id": "clonenewpct1_ver_enlaces_veronline", - "type": "list", - "label": "Mostrar enlaces Ver Online", - "default": 1, - "enabled": true, - "visible": true, - "lvalues": [ - "No", - "Todos", - "1", - "5", - "10", - "20" - ] - }, - { - "id": "clonenewpct1_verificar_enlaces_veronline", - "type": "list", - "label": "Verificar enlaces Ver Online", - "default": 1, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Todos", - "1", - "5", - "10", - "20" - ] - }, - { - "id": "clonenewpct1_verificar_enlaces_veronline_validos", - "type": "bool", - "label": "¿Contar sólo enlaces 'verificados' en Ver Online?", - "default": true, - "enabled": true, - "visible": "!eq(-1,'No') + !eq(-2,'No')" - }, - { - "id": "clonenewpct1_excluir1_enlaces_veronline", - "type": "list", - "label": "Excluir Servidores para Ver Online", - "default": 9, - "max_excl": 5, - "enabled": true, - "visible": "!eq(-3,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - }, - { - "id": "clonenewpct1_excluir2_enlaces_veronline", - "type": "list", - "label": "Excluir Servidores para Ver Online", - "default": 12, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - }, - { - "id": "clonenewpct1_excluir3_enlaces_veronline", - "type": "list", - "label": "Excluir Servidores para Ver Online", - "default": 20, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - }, - { - "id": "clonenewpct1_excluir4_enlaces_veronline", - "type": "list", - "label": "Excluir Servidores para Ver Online", - "default": 0, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - }, - { - "id": "clonenewpct1_excluir5_enlaces_veronline", - "type": "list", - "label": "Excluir Servidores para Ver Online", - "default": 0, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - }, - { - "id": "clonenewpct1_ver_enlaces_descargas", - "type": "list", - "label": "Mostrar enlaces Descargas", - "default": 0, - "enabled": true, - "visible": true, - "lvalues": [ - "No", - "Todos", - "1", - "5", - "10", - "20", - "30", - "50", - "100" - ] - }, - { - "id": "clonenewpct1_verificar_enlaces_descargas", - "type": "list", - "label": "Verificar enlaces Descargas", - "default": 1, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Todos", - "1", - "5", - "10", - "20", - "30", - "50", - "100" - ] - }, - { - "id": "clonenewpct1_verificar_enlaces_descargas_validos", - "type": "bool", - "label": "¿Contar sólo enlaces 'verificados' en Descargar?", - "default": true, - "enabled": true, - "visible": "!eq(-1,'No') + !eq(-2,'No')" - }, - { - "id": "clonenewpct1_excluir1_enlaces_descargas", - "type": "list", - "label": "Excluir Servidores para Ver Descargas", - "default": 0, - "enabled": true, - "visible": "!eq(-3,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - }, - { - "id": "clonenewpct1_excluir2_enlaces_descargas", - "type": "list", - "label": "Excluir Servidores para Ver Descargas", - "default": 0, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - }, - { - "id": "clonenewpct1_excluir3_enlaces_descargas", - "type": "list", - "label": "Excluir Servidores para Descargas", - "default": 0, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - }, - { - "id": "clonenewpct1_excluir4_enlaces_descargas", - "type": "list", - "label": "Excluir Servidores para Descargas", - "default": 0, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - }, - { - "id": "clonenewpct1_excluir5_enlaces_descargas", - "type": "list", - "label": "Excluir Servidores para Descargas", - "default": 0, - "enabled": true, - "visible": "!eq(-1,'No')", - "lvalues": [ - "No", - "Bankupload", - "Clipwatching", - "Flashx", - "Katfile", - "Mega", - "Mexashare", - "Movshare", - "Mowvideo", - "Openload", - "Powvideo", - "Rapidgator", - "Streamango", - "Streamcloud", - "Streame", - "Streaminto", - "Streamplay", - "Thevideo", - "Turbobit", - "Uploadedto", - "Uptobox", - "Userscloud", - "Vidabc", - "Vidspot" - ] - } - ] -} \ No newline at end of file diff --git a/plugin.video.alfa/channels/descargas2020.py b/plugin.video.alfa/channels/descargas2020.py deleted file mode 100644 index e1aac3ab..00000000 --- a/plugin.video.alfa/channels/descargas2020.py +++ /dev/null @@ -1,1625 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -import sys -import urllib -import urlparse -import datetime -import ast - -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, platformtools -from core import tmdb -from lib import generictools - -channel_py = 'newpct1' - -#Código para permitir usar un único canal para todas las webs clones de NewPct1 -clone_list = config.get_setting('clonenewpct1_channels_list', channel_py) #Carga lista de clones -clone_list = ast.literal_eval(clone_list) #la convierte en array -host_index = 0 -host_index = config.get_setting('clonenewpct1_channel_default', channel_py) #Clone por defecto -i = 0 -for active_clone, channel_clone, host_clone, contentType_clone, info_clone in clone_list: - if i == host_index: - channel_clone_name = channel_clone #Nombre del Canal elegido - host = host_clone #URL del Canal elegido - break - i += 1 -item = Item() -item.channel_host = host -if item.channel != channel_py: - item.channel = channel_py -item.category = channel_clone_name.capitalize() - -#Carga de opciones del canal -__modo_grafico__ = config.get_setting('modo_grafico', channel_py) #TMDB? -modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', channel_py) #Actualización sólo últ. Temporada? -timeout = config.get_setting('clonenewpct1_timeout_downloadpage', channel_py) #Timeout downloadpage -if timeout == 0: timeout = None - -platformtools.dialog_notification("NewPct1, ¡¡¡he vuelto como canal VIRTUAL!!!", "Hemos centralizado la gestión de los clones de NewPct1 en NewPct1 como canal virtual. Los clones desaparecerán en breve. Para más información lee el tutorial: https://alfa-addon.com /threads/newpct1-implantando-alta-disponibilidad.1200/", time=30000) - -#Vayamos a la siguiente acción en el canal Newpct1 -from platformcode import launcher -channel_clone_name = "descargas2020" #Nombre del Canal elegido -channel_py = channel_clone_name -host = "http://descargas2020.com/" -item.category = channel_clone_name.capitalize() -item.action = "mainlist" -item.channel_host = host -#launcher.run(item) - - -def mainlist(item): - logger.info() - #if item.channel != channel_py: - # return - - itemlist = [] - - if not item.channel_host: - item.channel_host = host - item.category = channel_clone_name.capitalize() - - thumb_pelis = get_thumb("channels_movie.png") - thumb_pelis_hd = get_thumb("channels_movie_hd.png") - thumb_series = get_thumb("channels_tvshow.png") - thumb_series_hd = get_thumb("channels_tvshow_hd.png") - thumb_series_az = get_thumb("channels_tvshow_az.png") - thumb_docus = get_thumb("channels_documentary.png") - thumb_buscar = get_thumb("search.png") - thumb_settings = get_thumb("setting_0.png") - - itemlist.append(Item(channel=item.channel, action="submenu", title="Películas", url=host, - extra="peliculas", thumbnail=thumb_pelis, category=item.category, channel_host=item.channel_host)) - - itemlist.append(Item(channel=item.channel, action="submenu", title="Series", url=host, extra="series", - thumbnail=thumb_series, category=item.category, channel_host=item.channel_host)) - - itemlist.append(Item(channel=item.channel, action="submenu", title="Documentales", url=host, extra="varios", - thumbnail=thumb_docus, category=item.category, channel_host=item.channel_host)) - itemlist.append( - Item(channel=item.channel, action="search", title="Buscar", url=host + "buscar", thumbnail=thumb_buscar, category=item.category, channel_host=item.channel_host)) - - itemlist.append( - Item(channel=item.channel, action="", title="[COLOR yellow]Configuración de Servidores:[/COLOR]", url="", thumbnail=thumb_settings, category=item.category, channel_host=item.channel_host)) - itemlist.append( - Item(channel=item.channel, action="settingCanal", title="Servidores para Ver Online y Descargas", url="", thumbnail=thumb_settings, category=item.category, channel_host=item.channel_host)) - - return itemlist - - -def settingCanal(item): - from platformcode import platformtools - return platformtools.show_channel_settings() - - -def submenu(item): - logger.info() - itemlist = [] - - data = '' - try: - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) - except: - pass - - patron = '
  • <\/i>.*Inicio<\/a><\/li>(.+)<\/ul>\s?<\/nav>' - #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): - logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url + data) - #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú - item, data = generictools.fail_over_newpct1(item, patron) - - if not data: #Si no ha logrado encontrar nada, salimos - itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR]: Ningún canal NewPct1 activo')) - 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 - elif item.channel_alt: #Si ha habido fail-over, lo comento - itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR] [ALT ] en uso')) - itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.channel_alt.capitalize() + '[/COLOR] inaccesible')) - - if item.url_alt: del item.url_alt - del item.channel_alt - - data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") - data = data.replace("'", '"').replace('/series"', '/series/"') #Compatibilidad con mispelisy.series.com - if "pelisyseries.com" in item.channel_host and item.extra == "varios": #compatibilidad con mispelisy.series.com - data = '
  • Documentales
  • ' - else: - data = scrapertools.get_match(data, patron) #Seleccionamos el trozo que nos interesa - if not data: - 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 - - patron = '
  • ([^>]+)<\/a><\/li>' - 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 - - for scrapedurl, scrapedtitle in matches: - title = scrapedtitle.strip() - - #Preguntamos por las entradas que no corresponden al "extra" - if item.extra in scrapedtitle.lower() or (item.extra == "peliculas" and ("cine" in scrapedurl or "anime" in scrapedurl)) or (item.extra == "varios" and ("documentales" in scrapedurl or "varios" in scrapedurl)): - itemlist.append(item.clone(action="listado", title=title, url=scrapedurl)) - itemlist.append(item.clone(action="alfabeto", title=title + " [A-Z]", url=scrapedurl)) - - if item.extra == "peliculas": - itemlist.append(item.clone(action="listado", title="Películas 4K", url=item.channel_host + "peliculas-hd/4kultrahd/")) - itemlist.append(item.clone(action="alfabeto", title="Películas 4K" + " [A-Z]", url=item.channel_host + "peliculas-hd/4kultrahd/")) - - return itemlist - - -def alfabeto(item): - logger.info() - itemlist = [] - - data = '' - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) - data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") - - patron = '
      (.*?)
    ' - if not data or not scrapertools.find_single_match(data, patron): - logger.error("ERROR 01: ALFABETO: La Web no responde o ha cambiado de URL: " + item.url + data) - #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú - item, data = generictools.fail_over_newpct1(item, patron) - - if not data: #Si no ha logrado encontrar nada, salimos - itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR]: Ningún canal NewPct1 activo')) - itemlist.append(item.clone(action='', title=item.category + ': ERROR 01: ALFABETO: 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 - elif item.channel_alt: #Si ha habido fail-over, lo comento - itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR] [ALT ] en uso')) - itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.channel_alt.capitalize() + '[/COLOR] inaccesible')) - - if item.url_alt: del item.url_alt - del item.channel_alt - - data = scrapertools.get_match(data, patron) - - patron = ']+>([^>]+)' - - matches = re.compile(patron, re.DOTALL).findall(data) - if not matches: - logger.error("ERROR 02: ALFABETO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) - itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: ALFABETO: 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 - - for scrapedurl, scrapedtitle in matches: - title = scrapedtitle.upper() - - itemlist.append(item.clone(action="listado", title=title, url=scrapedurl)) - - return itemlist - - -def listado(item): - logger.info() - itemlist = [] - clase = "pelilist" # etiqueta para localizar zona de listado de contenidos - url_next_page ='' # Controlde paginación - cnt_tot = 30 # Poner el num. máximo de items por página - - if item.totalItems: - del item.totalItems - - data = '' - try: - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) - except: - pass - - patron = '
      (.*?)
    ' #seleccionamos el bloque que nos interesa - if not data or (not scrapertools.find_single_match(data, patron) and not '

    ( 0 ) Resultados encontrados ' in data): - logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data) - #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú - item, data = generictools.fail_over_newpct1(item, patron) - - if not data: #Si no ha logrado encontrar nada, salimos - itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.channel.capitalize() + '[/COLOR]: Ningún canal NewPct1 activo')) - itemlist.append(item.clone(action='', title=item.category + ': ERROR 01: LISTADO: 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 - - #Establecemos los valores básicos en función del tipo de contenido - if item.extra == "peliculas": - item.action = "findvideos" - item.contentType = "movie" - pag = True #Sí hay paginación - elif item.extra == "series" and not "/miniseries" in item.url: - item.action = "episodios" - item.contentType = "tvshow" - pag = True - elif item.extra == "varios" or "/miniseries" in item.url: - item.action = "findvideos" - item.contentType = "movie" - pag = True - - #Selecciona el tramo de la página con el listado de contenidos - patron = '
      (.*?)
    ' - if data: - fichas = scrapertools.get_match(data, patron) - if not fichas and not '

    ( 0 ) Resultados encontrados ' in data: #error - logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) - itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: LISTADO: 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 - elif '

    ( 0 ) Resultados encontrados ' in data: #no hay vídeos - return itemlist - else: - return itemlist - page_extra = clase - - #Scrapea los datos de cada vídeo. Título alternativo se mantiene, aunque no se usa de momento - patron = ' cnt_pag + cnt_tot: - url_next_page = item.url - matches = matches[cnt_pag:cnt_pag+cnt_tot] - next_page = '' - if matches_cnt <= cnt_pag + (cnt_tot * 2): - if pag: - next_page = 'b' - modo = 'continue' - else: - matches = matches[cnt_pag:cnt_pag+cnt_tot] - next_page = 'a' - patron_next_page = 'Next<\/a>' - matches_next_page = re.compile(patron_next_page, re.DOTALL).findall(data) - modo = 'continue' - if len(matches_next_page) > 0: - url_next_page = urlparse.urljoin(item.url, matches_next_page[0]) - modo = 'next' - - # Avanzamos el contador de líneas en una página - if item.next_page: - del item.next_page - if modo == 'next': - cnt_pag = 0 - else: - cnt_pag += cnt_tot - - #Tratamos todos los contenidos, creardo una variable local de Item - for scrapedurl, scrapedtitle, scrapedthumbnail, title_alt, calidad in matches: - item_local = item.clone() - if item_local.tipo: - del item_local.tipo - if item_local.totalItems: - del item_local.totalItems - if item_local.post_num: - del item_local.post_num - if item_local.category: - del item_local.category - - item_local.title = '' - item_local.context = "['buscar_trailer']" - - # Limpiamos títulos, Sacamos datos de calidad, audio y lenguaje - title = re.sub('\r\n', '', scrapedtitle).decode('iso-8859-1').encode('utf8').strip() - title_alt = re.sub('\r\n', '', title_alt).decode('iso-8859-1').encode('utf8').strip() - title = title.replace("á", "a").replace("é", "e").replace("í", "i").replace("ó", "o").replace("ú", "u").replace("ü", "u").replace("�", "ñ").replace("ñ", "ñ").replace(".", " ") - title_alt = title_alt.replace("á", "a").replace("é", "e").replace("í", "i").replace("ó", "o").replace("ú", "u").replace("ü", "u").replace("�", "ñ").replace("ñ", "ñ") - - item_local.quality = calidad - title_subs = [] - - #Determinamos y marcamos idiomas distintos del castellano - item_local.language = [] - if "[vos" in title.lower() or "v.o.s" in title.lower() or "vo" in title.lower() or ".com/pelicula/" in scrapedurl or ".com/series-vo" in scrapedurl or "-vo/" in scrapedurl or "vos" in calidad.lower() or "vose" in calidad.lower() or "v.o.s" in calidad.lower() or "sub" in calidad.lower() or ".com/peliculas-vo" in item.url: - item_local.language += ["VOS"] - title = title.replace(" [Subs. integrados]", "").replace(" [subs. Integrados]", "").replace(" [VOSE", "").replace(" [VOS", "").replace(" (V.O.S.E)", "").replace(" VO", "").replace("Subtitulos", "") - if "latino" in title.lower() or "argentina" in title.lower() or "-latino/" in scrapedurl or "latino" in calidad.lower() or "argentina" in calidad.lower(): - item_local.language += ["LAT"] - - #Guardamos info de 3D en calidad y limpiamos - if "3d" in title.lower(): - if not "3d" in item_local.quality.lower(): - item_local.quality = item_local.quality + " 3D" - calidad3D = scrapertools.find_single_match(title, r'\s(3[d|D]\s\w+)') - if calidad3D: - item_local.quality = item_local.quality.replace("3D", calidad3D) - title = re.sub(r'\s3[d|D]\s\w+', '', title) - title = re.sub(r'\s3[d|D]', '', title) - title_alt = re.sub(r'\s3[d|D]\s\w+', '', title_alt) - title_alt = re.sub(r'\s3[d|D]', '', title_alt) - if "imax" in title.lower(): - item_local.quality = item_local.quality + " IMAX" - title = title.replace(" IMAX", "").replace(" imax", "") - title_alt = title_alt.replace(" IMAX", "").replace(" imax", "") - if "2d" in title.lower(): - title = title.replace("(2D)", "").replace("(2d)", "").replace("2D", "").replace("2d", "") - title_subs += ["[2D]"] - - #Extraemos info adicional del título y la guardamos para después de TMDB - if "temp" in title.lower() or "cap" in title.lower(): #Eliminamos Temporada, solo nos interesa la serie completa - title = re.sub(r' - [t|T]emp\w+ \d+ Comp\w+\d+[x|X]\d+', ' Completa', title) - title = re.sub(r' - [t|T]emp\w+ \d+x\d+', '', title) - title = re.sub(r' - [t|T]emp\w+ \d+', '', title) - title = re.sub(r' - [t|T]emp\w+.*?\d+', '', title) - title = re.sub(r' [t|T]emp.*?\d+x\d+', '', title) - title = re.sub(r' [t|T]emp.*?\d+', '', title) - title = re.sub(r' [c|C]ap.*?\d+', '', title) - if "audio" in title.lower(): #Reservamos info de audio para después de TMDB - title_subs += ['[%s]' % scrapertools.find_single_match(title, r'(\[[a|A]udio.*?\])')] - title = re.sub(r'\[[a|A]udio.*?\]', '', title) - if "[dual" in title.lower() or "multileng" in title.lower() or "multileng" in item_local.quality.lower() or (("espa" in title.lower() or "spani" in title.lower()) and "VOS" in item_local.language): - item_local.language[0:0] = ["DUAL"] - title = re.sub(r'\[[D|d]ual.*?\]', '', title) - title = re.sub(r'\[[M|m]ultileng.*?\]', '', title) - item_local.quality = re.sub(r'\[[M|m]ultileng.*?\]', '', item_local.quality) - if "duolog" in title.lower(): - title_subs += ["[Saga]"] - title = title.replace(" Duologia", "").replace(" duologia", "").replace(" Duolog", "").replace(" duolog", "") - if "trilog" in title.lower(): - title_subs += ["[Saga]"] - title = title.replace(" Trilogia", "").replace(" trilogia", "").replace(" Trilog", "").replace(" trilog", "") - if "extendida" in title.lower(): - title_subs += ["[V. Extendida]"] - title = title.replace(" Version Extendida", "").replace(" (Version Extendida)", "").replace(" V. Extendida", "").replace(" VExtendida", "").replace(" V Extendida", "") - if "saga" in title.lower(): - title = title.replace(" Saga Completa", "").replace(" saga sompleta", "").replace(" Saga", "").replace(" saga", "") - title_subs += ["[Saga]"] - if "colecc" in title.lower() or "completa" in title.lower(): - title = title.replace(" Coleccion", "").replace(" coleccion", "").replace(" Colecci", "").replace(" colecci", "").replace(" Completa", "").replace(" completa", "").replace(" COMPLETA", "") - if scrapertools.find_single_match(title, r'(- [m|M].*?serie ?\w+)'): - title = re.sub(r'- [m|M].*?serie ?\w+', '', title) - title_subs += ["[Miniserie]"] - - #Limpiamos restos en título - title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") - title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") - - #Limpiamos cabeceras y colas del título - title = re.sub(r'Descargar\s\w+\-\w+', '', title) - title = re.sub(r'\(COMPLE.*?\)', '', title) - title = re.sub(r'\(\d{4}\)$', '', title) - title = re.sub(r'\d{4}$', '', title) - title = re.sub(r' \d+x\d+', '', title) - title = re.sub(r' x\d+', '', title) - - title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() - - title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() - - if title.endswith("torrent gratis"): title = title[:-15] - if title.endswith("gratis"): title = title[:-7] - if title.endswith("torrent"): title = title[:-8] - if title.endswith("en HD"): title = title[:-6] - if title.endswith(" -"): title = title[:-2] - if "en espa" in title: title = title[:-11] - - item_local.quality = item_local.quality.replace("gratis ", "") - if "HDR" in title: - title = title.replace(" HDR", "") - if not "HDR" in item_local.quality: - item_local.quality += " HDR" - - title = title.strip() - title_alt = title_alt.strip() - item_local.quality = item_local.quality.strip() - - if not title: #Usamos solo el title_alt en caso de que no exista el título original - title = title_alt - if not title: - title = "SIN TITULO" - - #Limpieza final del título y guardado en las variables según su tipo de contenido - title = scrapertools.remove_htmltags(title) - item_local.title = title - if item_local.contentType == "movie": - item_local.contentTitle = title - else: - item_local.contentSerieName = title - - #Guardamos el resto de variables del vídeo - item_local.url = scrapedurl - item_local.thumbnail = scrapedthumbnail - item_local.contentThumbnail = scrapedthumbnail - - #Guardamos el año que puede venir en la url, por si luego no hay resultados desde TMDB - year = '' - if item_local.contentType == "movie": - year = scrapertools.find_single_match(scrapedurl, r'(\d{4})') - if year >= "1900" and year <= "2040" and year != "2020": - title_subs += [year] - item_local.infoLabels['year'] = '-' - - #Guarda la variable temporal que almacena la info adicional del título a ser restaurada después de TMDB - item_local.title_subs = title_subs - - #Agrega el item local a la lista itemlist - itemlist.append(item_local.clone()) - - #Pasamos a TMDB la lista completa Itemlist - tmdb.set_infoLabels(itemlist, __modo_grafico__) - - #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB - item, itemlist = generictools.post_tmdb_listado(item, itemlist) - - if len(itemlist) == 0: - itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado")) - else: - if url_next_page: - itemlist.append( - Item(channel=item.channel, action="listado", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), url=url_next_page, next_page=next_page, cnt_pag=cnt_pag, post_num=post_num, pag=pag, modo=modo, extra=item.extra)) - - #logger.debug(url_next_page + " / " + next_page + " / " + str(matches_cnt) + " / " + str(cnt_pag)+ " / " + str(total_pag) + " / " + str(pag) + " / " + modo + " / " + item.extra) - - return itemlist - -def listado_busqueda(item): - logger.info() - - #Renombramos el canal al nombre de clone elegido. Actualizados URL - host = scrapertools.find_single_match(item.url, '(http.?\:\/\/(?:www.)?\w+\.\w+\/)') - #item.channel = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/') - if item.category and item.category != "newest": - item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() - - itemlist = [] - cnt_tot = 40 # Poner el num. máximo de items por página. Dejamos que la web lo controle - cnt_title = 0 # Contador de líneas insertadas en Itemlist - cnt_pag = 0 # Contador de líneas leídas de Matches - 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 - data = '' - - if item.cnt_pag: - cnt_pag = item.cnt_pag # Se guarda en la lista de páginas anteriores en Item - del item.cnt_pag - if item.totalItems: - del item.totalItems - if item.text_bold: - del item.text_bold - if item.text_color: - del item.text_color - - #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 - if item.title_lista: # Si viene de una pasada anterior, la lista ya estará guardada - title_lista = item.title_lista # Se usa la lista de páginas anteriores en Item - title_lista_alt = [] - for url in title_lista: - title_lista_alt += [url] #hacemos una copia no vinculada de title_lista - matches = [] - cnt_next = 0 - total_pag = 1 - post_num = 1 - - #Máximo num. de líneas permitidas por TMDB. Máx de 5 páginas por Itemlist para no degradar el rendimiento - while cnt_title <= cnt_tot and cnt_next < 5: - - try: - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, post=item.post, timeout=timeout_search).data) - except: - pass - - cnt_next += 1 - pattern = '
      (.*?)
    ' % item.pattern #seleccionamos el bloque que nos interesa - if not data or (not scrapertools.find_single_match(data, pattern) and not '

    ( 0 ) Resultados encontrados ' in data): - logger.error("ERROR 01: LISTADO_BUSQUEDA: La Web no responde o ha cambiado de URL: " + item.url + item.post + " / DATA: " + data) - #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú - item, data = generictools.fail_over_newpct1(item, pattern) - - if not data: #Si no ha logrado encontrar nada, salimos - itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.channel.capitalize() + '[/COLOR]: Ningún canal NewPct1 activo')) - itemlist.append(item.clone(action='', title=item.category + ': ERROR 01: LISTADO_BUSQUEDA:. 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 - elif item.channel_alt: #Si ha habido fail-over, lo comento - host = host.replace(item.channel_alt, item.channel) - - #Obtiene la dirección de la próxima página, si la hay - try: - post_actual = item.post #Guardamos el post actual por si hay overflow de Itemlist y hay que hechar marcha atrás - get, post, total_pag = scrapertools.find_single_match(data, '