From cf4d838a9edbe9fcb65994b11f80c519530ec38e Mon Sep 17 00:00:00 2001 From: sculkurt <44222714+sculkurt@users.noreply.github.com> Date: Mon, 29 Oct 2018 16:55:45 +0100 Subject: [PATCH 01/12] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit arreglo patron género --- plugin.video.alfa/channels/sleazemovies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.video.alfa/channels/sleazemovies.py b/plugin.video.alfa/channels/sleazemovies.py index 904c6bb0..58243073 100644 --- a/plugin.video.alfa/channels/sleazemovies.py +++ b/plugin.video.alfa/channels/sleazemovies.py @@ -30,7 +30,7 @@ def genero(item): itemlist = list() data = httptools.downloadpage(host).data data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) - patron = '
  • ([^<]+)' + patron = '
  • ([^<]+)' matches = scrapertools.find_multiple_matches(data, patron) for scrapedurl, scrapedtitle in matches: From f89569d0b814e92d7cd95e2b27234f9357e78963 Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Wed, 31 Oct 2018 16:19:23 +0100 Subject: [PATCH 02/12] =?UTF-8?q?Cacheando=20los=20enlaces=20de=20las=20se?= =?UTF-8?q?ries=20y=20pel=C3=ADculas=20en=20la=20Videoteca?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cacheando los enlaces de las series y películas en la Videoteca Sábado por la noche. Me siento a ver alguno de los episodios nuevos de la semana o una película, que tengo en la Videoteca. ¿Qué pasa?, el canal está caído o da error de cambio de estructura, y no puedo ver nada de la Videoteca para ese canal!!! Entonces me acuerdo de lo bueno que es tener otro canal de reserva configurado, pero ya es tarde... Con frecuencia las web de los canales se colapsan durante el fin de semana por sobrecarga de usuarios. El diseño de nuestros canales exige que para reproducir un episodio o película desde la videoteca tengamos que acceder a la web para encontrar el enlace que apunta al episodio o película. Si la web está caída o ha cambiado la estructura no se puede encontrar el enlace. Es un proceso muy pequeño, pero imprescindible. Como los enlaces suelen ser bastante estables, ¿por qué no añadimos los enlaces del episodio o película durante la generación de la Videoteca? Si la web ha caído temporal o definitivamente, o hay un cambio de estructura, mientras se busca una alternativa, se puede seguir disfrutando de la Videoteca grabada por tiempo indefinido. Hay que pensar que los usuarios de la Videoteca de Alfa pueden llegar a tener docenas o centenares de títulos almacenados en la Videoteca. Esta es una mejora disponible en Alfa para todos los canales que usan Videoteca, pero los canales requieren un retoque para soportarla. Empezamos por el canal Newpct1. Ya iremos ampliando la lista con el tiempo. Cuando se lance Kodi por primera vez después de la actualización, automáticamente se migrarán todas las series y películas de la Videoteca para este canal. --- plugin.video.alfa/channels/newpct1.json | 16 +- plugin.video.alfa/channels/newpct1.py | 398 +++++++++++--------- plugin.video.alfa/core/videolibrarytools.py | 87 ++++- plugin.video.alfa/lib/generictools.py | 172 +++++++-- plugin.video.alfa/videolibrary_service.py | 3 + 5 files changed, 460 insertions(+), 216 deletions(-) diff --git a/plugin.video.alfa/channels/newpct1.json b/plugin.video.alfa/channels/newpct1.json index 4e620eb2..49afc414 100644 --- a/plugin.video.alfa/channels/newpct1.json +++ b/plugin.video.alfa/channels/newpct1.json @@ -48,6 +48,20 @@ "VOSE" ] }, + { + "id": "emergency_urls", + "type": "list", + "label": "Se quieren guardar Enlaces de Emergencia por si se cae la Web?", + "default": 1, + "enabled": true, + "visible": true, + "lvalues": [ + "No", + "Guardar", + "Borrar", + "Actualizar" + ] + }, { "id": "clonenewpct1_channel_default", "type": "list", @@ -77,7 +91,7 @@ "id": "intervenidos_channels_list", "type": "text", "label": "Lista de canales y clones de NewPct1 intervenidos y orden de sustitución de URLs", - "default": "('0', 'canal_org', 'canal_des', 'url_org', 'url_des', 'patron1', 'patron2', 'patron3', 'patron4', 'patron5', 'content_inc', 'content_exc', 'ow_force'), ('0', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', '(http.?:\/\/.*?\/)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)([^0-9]+-)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-\\d+-(Temporada-).html', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-(\\d+)-', '', 'tvshow, season', '', 'force'), ('0', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', '(http.?:\/\/.*?\/)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-([^.]+).html', '', '', '', 'movie', '', 'force'), ('1', 'mejortorrent', 'mejortorrent', 'http://www.mejortorrent.com/', 'http://www.mejortorrent.org/', '', '', '', '', '', '*', '', 'force'), ('1', 'plusdede', 'megadede', 'https://www.plusdede.com', 'https://www.megadede.com', '', '', '', '', '', '*', '', 'auto')", + "default": "('0', 'canal_org', 'canal_des', 'url_org', 'url_des', 'patron1', 'patron2', 'patron3', 'patron4', 'patron5', 'content_inc', 'content_exc', 'ow_force'), ('0', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', '(http.?:\/\/.*?\/)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)([^0-9]+-)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-\\d+-(Temporada-).html', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-(\\d+)-', '', 'tvshow, season', '', 'force'), ('0', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', '(http.?:\/\/.*?\/)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-([^.]+).html', '', '', '', 'movie', '', 'force'), ('0', 'mejortorrent', 'mejortorrent', 'http://www.mejortorrent.com/', 'http://www.mejortorrent.org/', '', '', '', '', '', '*', '', 'force'), ('0', 'plusdede', 'megadede', 'https://www.plusdede.com', 'https://www.megadede.com', '', '', '', '', '', '*', '', 'auto')", "enabled": true, "visible": false }, diff --git a/plugin.video.alfa/channels/newpct1.py b/plugin.video.alfa/channels/newpct1.py index ceabe4ea..ed1d74e2 100644 --- a/plugin.video.alfa/channels/newpct1.py +++ b/plugin.video.alfa/channels/newpct1.py @@ -544,15 +544,15 @@ def listado(item): if ("temp" in title.lower() or "cap" in title.lower()) and item_local.contentType != "movie": #Eliminamos Temporada de Series, 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+.?[c|C]ap\w+.?\d+.?(?:al|Al|y).?\d+', '', 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|X]\d+', '', title) - title = re.sub(r' [t|T]emp.*?\d+', '', title) - title = re.sub(r' [c|C]ap.*?\d+ al \d+', '', title) - title = re.sub(r' [c|C]ap.*?\d+', '', title) + title = re.sub(r'-?\s*[t|T]emp\w+ \d+ Comp\w+\d+[x|X]\d+', ' Completa', title) + title = re.sub(r'-?\s*[t|T]emp\w+.?\d+.?[c|C]ap\w+.?\d+.?(?:al|Al|y).?\d+', '', title) + title = re.sub(r'-?\s*[t|T]emp\w+ \d+x\d+', '', title) + title = re.sub(r'-?\s*[t|T]emp\w+ \d+', '', title) + title = re.sub(r'-?\s*[t|T]emp\w+.*?\d+', '', title) + title = re.sub(r'\s*[t|T]emp.*?\d+[x|X]\d+', '', title) + title = re.sub(r'\s*[t|T]emp.*?\d+', '', title) + title = re.sub(r'\s*[c|C]ap.*?\d+ al \d+', '', title) + title = re.sub(r'\s*[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) @@ -1026,15 +1026,15 @@ def listado_busqueda(item): #Extraemos info adicional del título y la guardamos para después de TMDB if ("temp" in title.lower() or "cap" in title.lower()) and item_local.contentType != "movie": #Eliminamos Temporada de Series, 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+.?[c|C]ap\w+.?\d+.?(?:al|Al|y).?\d+', '', 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|X]\d+', '', title) - title = re.sub(r' [t|T]emp.*?\d+', '', title) - title = re.sub(r' [c|C]ap.*?\d+ al \d+', '', title) - title = re.sub(r' [c|C]ap.*?\d+', '', title) + title = re.sub(r'-?\s*[t|T]emp\w+ \d+ Comp\w+\d+[x|X]\d+', ' Completa', title) + title = re.sub(r'-?\s*[t|T]emp\w+.?\d+.?[c|C]ap\w+.?\d+.?(?:al|Al|y).?\d+', '', title) + title = re.sub(r'-?\s*[t|T]emp\w+ \d+x\d+', '', title) + title = re.sub(r'-?\s*[t|T]emp\w+ \d+', '', title) + title = re.sub(r'-?\s*[t|T]emp\w+.*?\d+', '', title) + title = re.sub(r'\s*[t|T]emp.*?\d+[x|X]\d+', '', title) + title = re.sub(r'\s*[t|T]emp.*?\d+', '', title) + title = re.sub(r'\s*[c|C]ap.*?\d+ al \d+', '', title) + title = re.sub(r'\s*[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) @@ -1250,7 +1250,7 @@ def findvideos(item): item.channel_host = host item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() - verify_fo = True #Verificamos si el clone a usar está activo + verify_fo = True #Verificamos si el clone a usar está activo item, data = generictools.fail_over_newpct1(item, verify_fo) # Cualquiera de las tres opciones son válidas @@ -1259,113 +1259,115 @@ def findvideos(item): item.url = item.url.replace(".com/", ".com/descarga-torrent/") #Función para limitar la verificación de enlaces de Servidores para Ver online y Descargas - try: - #Inicializamos las variables por si hay un error en medio del proceso - channel_exclude = [] - ver_enlaces = [] - ver_enlaces_veronline = -1 #Ver todos los enlaces Ver Online - verificar_enlaces_veronline = -1 #Verificar todos los enlaces Ver Online - verificar_enlaces_veronline_validos = True #"¿Contar sólo enlaces 'verificados' en Ver Online?" - excluir_enlaces_veronline = [] #Lista vacía de servidores excluidos en Ver Online - ver_enlaces_descargas = 0 #Ver todos los enlaces Descargar - verificar_enlaces_descargas = -1 #Verificar todos los enlaces Descargar - verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" - excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar + if not item.videolibray_emergency_urls: #Si es un proceso nomal... + try: + #Inicializamos las variables por si hay un error en medio del proceso + channel_exclude = [] + ver_enlaces = [] + ver_enlaces_veronline = -1 #Ver todos los enlaces Ver Online + verificar_enlaces_veronline = -1 #Verificar todos los enlaces Ver Online + verificar_enlaces_veronline_validos = True #"¿Contar sólo enlaces 'verificados' en Ver Online?" + excluir_enlaces_veronline = [] #Lista vacía de servidores excluidos en Ver Online + ver_enlaces_descargas = 0 #Ver todos los enlaces Descargar + verificar_enlaces_descargas = -1 #Verificar todos los enlaces Descargar + verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" + excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar + + #Leemos las opciones de permitir Servidores para Ver Online y Descargas + #Cargamos en .json del canal para ver las listas de valores en settings + channel_exclude = channeltools.get_channel_json(item.channel) + for settings in channel_exclude['settings']: #Se recorren todos los settings + if settings['id'] == "clonenewpct1_excluir1_enlaces_veronline": #lista de enlaces a excluir + max_excl = int(settings['max_excl']) #Máximo número de servidores excluidos + channel_exclude = settings['lvalues'] #Cargamos la lista de servidores + if settings['id'] == "clonenewpct1_ver_enlaces_descargas": #Número de enlances a ver o verificar + ver_enlaces = settings['lvalues'] #Cargamos la lista de num. de enlaces - #Leemos las opciones de permitir Servidores para Ver Online y Descargas - #Cargamos en .json del canal para ver las listas de valores en settings - channel_exclude = channeltools.get_channel_json(item.channel) - for settings in channel_exclude['settings']: #Se recorren todos los settings - if settings['id'] == "clonenewpct1_excluir1_enlaces_veronline": #lista de enlaces a excluir - max_excl = int(settings['max_excl']) #Máximo número de servidores excluidos - channel_exclude = settings['lvalues'] #Cargamos la lista de servidores - if settings['id'] == "clonenewpct1_ver_enlaces_descargas": #Número de enlances a ver o verificar - ver_enlaces = settings['lvalues'] #Cargamos la lista de num. de enlaces - - #Primer loop para enlaces de Ver Online. - #Carga la variable de ver - ver_enlaces_veronline = int(config.get_setting("clonenewpct1_ver_enlaces_veronline", item.channel)) - if ver_enlaces_veronline == 1: #a "Todos" le damos valor -1. Para "No" dejamos 0 - ver_enlaces_veronline = -1 - if ver_enlaces_veronline > 1: #para los demás valores, tomamos los de la lista - ver_enlaces_veronline = int(ver_enlaces[ver_enlaces_veronline]) - - #Carga la variable de verificar - verificar_enlaces_veronline = int(config.get_setting("clonenewpct1_verificar_enlaces_veronline", item.channel)) - if verificar_enlaces_veronline == 1: #a "Todos" le damos valor -1. Para "No" dejamos 0 - verificar_enlaces_veronline = -1 - if verificar_enlaces_veronline > 1: #para los demás valores, tomamos los de la lista - verificar_enlaces_veronline = int(ver_enlaces[verificar_enlaces_veronline]) + #Primer loop para enlaces de Ver Online. + #Carga la variable de ver + ver_enlaces_veronline = int(config.get_setting("clonenewpct1_ver_enlaces_veronline", item.channel)) + if ver_enlaces_veronline == 1: #a "Todos" le damos valor -1. Para "No" dejamos 0 + ver_enlaces_veronline = -1 + if ver_enlaces_veronline > 1: #para los demás valores, tomamos los de la lista + ver_enlaces_veronline = int(ver_enlaces[ver_enlaces_veronline]) + + #Carga la variable de verificar + verificar_enlaces_veronline = int(config.get_setting("clonenewpct1_verificar_enlaces_veronline", item.channel)) + if verificar_enlaces_veronline == 1: #a "Todos" le damos valor -1. Para "No" dejamos 0 + verificar_enlaces_veronline = -1 + if verificar_enlaces_veronline > 1: #para los demás valores, tomamos los de la lista + verificar_enlaces_veronline = int(ver_enlaces[verificar_enlaces_veronline]) - #Carga la variable de contar sólo los servidores verificados - verificar_enlaces_veronline_validos = int(config.get_setting("clonenewpct1_verificar_enlaces_veronline_validos", item.channel)) + #Carga la variable de contar sólo los servidores verificados + verificar_enlaces_veronline_validos = int(config.get_setting("clonenewpct1_verificar_enlaces_veronline_validos", item.channel)) - #Carga la variable de lista de servidores excluidos - x = 1 - for x in range(1, max_excl+1): #recorremos todas las opciones de canales exluidos - valor = str(config.get_setting("clonenewpct1_excluir%s_enlaces_veronline" % x, item.channel)) - valor = int(valor) - if valor > 0: #Evitamos "No" - excluir_enlaces_veronline += [channel_exclude[valor]] #Añadimos el nombre de servidor excluido a la lista - x += 1 + #Carga la variable de lista de servidores excluidos + x = 1 + for x in range(1, max_excl+1): #recorremos todas las opciones de canales exluidos + valor = str(config.get_setting("clonenewpct1_excluir%s_enlaces_veronline" % x, item.channel)) + valor = int(valor) + if valor > 0: #Evitamos "No" + excluir_enlaces_veronline += [channel_exclude[valor]] #Añadimos el nombre de servidor excluido a la lista + x += 1 - #Segundo loop para enlaces de Descargar. - #Carga la variable de ver - ver_enlaces_descargas = int(config.get_setting("clonenewpct1_ver_enlaces_descargas", item.channel)) - if ver_enlaces_descargas == 1: #a "Todos" le damos valor -1. Para "No" dejamos 0 - ver_enlaces_descargas = -1 - if ver_enlaces_descargas > 1: #para los demás valores, tomamos los de la lista - ver_enlaces_descargas = int(ver_enlaces[ver_enlaces_descargas]) - - #Carga la variable de verificar - verificar_enlaces_descargas = int(config.get_setting("clonenewpct1_verificar_enlaces_descargas", item.channel)) - if verificar_enlaces_descargas == 1: #a "Todos" le damos valor -1. Para "No" dejamos 0 - verificar_enlaces_descargas = -1 - if verificar_enlaces_descargas > 1: #para los demás valores, tomamos los de la lista - verificar_enlaces_descargas = int(ver_enlaces[verificar_enlaces_descargas]) + #Segundo loop para enlaces de Descargar. + #Carga la variable de ver + ver_enlaces_descargas = int(config.get_setting("clonenewpct1_ver_enlaces_descargas", item.channel)) + if ver_enlaces_descargas == 1: #a "Todos" le damos valor -1. Para "No" dejamos 0 + ver_enlaces_descargas = -1 + if ver_enlaces_descargas > 1: #para los demás valores, tomamos los de la lista + ver_enlaces_descargas = int(ver_enlaces[ver_enlaces_descargas]) + + #Carga la variable de verificar + verificar_enlaces_descargas = int(config.get_setting("clonenewpct1_verificar_enlaces_descargas", item.channel)) + if verificar_enlaces_descargas == 1: #a "Todos" le damos valor -1. Para "No" dejamos 0 + verificar_enlaces_descargas = -1 + if verificar_enlaces_descargas > 1: #para los demás valores, tomamos los de la lista + verificar_enlaces_descargas = int(ver_enlaces[verificar_enlaces_descargas]) - #Carga la variable de contar sólo los servidores verificados - verificar_enlaces_descargas_validos = int(config.get_setting("clonenewpct1_verificar_enlaces_descargas_validos", item.channel)) + #Carga la variable de contar sólo los servidores verificados + verificar_enlaces_descargas_validos = int(config.get_setting("clonenewpct1_verificar_enlaces_descargas_validos", item.channel)) - #Carga la variable de lista de servidores excluidos - x = 1 - for x in range(1, max_excl+1): #recorremos todas las opciones de canales exluidos - valor = str(config.get_setting("clonenewpct1_excluir%s_enlaces_descargas" % x, item.channel)) - valor = int(valor) - if valor > 0: #Evitamos "No" - excluir_enlaces_descargas += [channel_exclude[valor]] #Añadimos el nombre de servidor excluido a la lista - x += 1 + #Carga la variable de lista de servidores excluidos + x = 1 + for x in range(1, max_excl+1): #recorremos todas las opciones de canales exluidos + valor = str(config.get_setting("clonenewpct1_excluir%s_enlaces_descargas" % x, item.channel)) + valor = int(valor) + if valor > 0: #Evitamos "No" + excluir_enlaces_descargas += [channel_exclude[valor]] #Añadimos el nombre de servidor excluido a la lista + x += 1 - except Exception, ex: #En caso de error, lo mostramos y reseteamos todas las variables - logger.error("Error en la lectura de parámentros del .json del canal: " + item.channel + " \n%s" % ex) - #Mostrar los errores - logger.error(ver_enlaces_veronline) - logger.error(verificar_enlaces_veronline) - logger.error(verificar_enlaces_veronline_validos) - logger.error(excluir_enlaces_veronline) - logger.error(ver_enlaces_descargas) - logger.error(verificar_enlaces_descargas) - logger.error(verificar_enlaces_descargas_validos) - logger.error(excluir_enlaces_descargas) - #Resetear las variables a sus valores por defecto - ver_enlaces_veronline = -1 #Ver todos los enlaces Ver Online - verificar_enlaces_veronline = -1 #Verificar todos los enlaces Ver Online - verificar_enlaces_veronline_validos = True #"¿Contar sólo enlaces 'verificados' en Ver Online?" - excluir_enlaces_veronline = [] #Lista vacía de servidores excluidos en Ver Online - ver_enlaces_descargas = 0 #Ver todos los enlaces Descargar - verificar_enlaces_descargas = -1 #Verificar todos los enlaces Descargar - verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" - excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar + except Exception, ex: #En caso de error, lo mostramos y reseteamos todas las variables + logger.error("Error en la lectura de parámentros del .json del canal: " + item.channel + " \n%s" % ex) + #Mostrar los errores + logger.error(ver_enlaces_veronline) + logger.error(verificar_enlaces_veronline) + logger.error(verificar_enlaces_veronline_validos) + logger.error(excluir_enlaces_veronline) + logger.error(ver_enlaces_descargas) + logger.error(verificar_enlaces_descargas) + logger.error(verificar_enlaces_descargas_validos) + logger.error(excluir_enlaces_descargas) + #Resetear las variables a sus valores por defecto + ver_enlaces_veronline = -1 #Ver todos los enlaces Ver Online + verificar_enlaces_veronline = -1 #Verificar todos los enlaces Ver Online + verificar_enlaces_veronline_validos = True #"¿Contar sólo enlaces 'verificados' en Ver Online?" + excluir_enlaces_veronline = [] #Lista vacía de servidores excluidos en Ver Online + ver_enlaces_descargas = 0 #Ver todos los enlaces Descargar + verificar_enlaces_descargas = -1 #Verificar todos los enlaces Descargar + verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" + excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar # Descarga la página data = '' + data_servidores = '' try: data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures") url_servidores = item.url category_servidores = item.category - data_servidores = data #salvamos data para verificar servidores, si es necesario - except: + data_servidores = data #salvamos data para verificar servidores, si es necesario + except: #La web no responde. Probemos las urls de emergencia pass patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent @@ -1375,15 +1377,20 @@ def findvideos(item): if not data or not scrapertools.find_single_match(data, patron): item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada if item.intervencion: #Sí ha sido clausurada judicialmente - item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error - return itemlist #Salimos - - logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + 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 vídeo - item, data = generictools.fail_over_newpct1(item, patron) + item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error + if item.emergency_urls: #Hay urls de emergencia? + item.url = item.emergency_urls[0] #Guardamos la url del .Torrent + enlaces_ver = item.emergency_urls[1] #Guardamos los datos iniciales de los Servidores Directos + item.armagedon = True #Marcamos la situación como catastrófica + else: + return itemlist #Salimos + else: + logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + 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 vídeo + item, data = generictools.fail_over_newpct1(item, patron) - if not data: #Si no ha logrado encontrar nada, verificamos si hay servidores + if not data: #Si no ha logrado encontrar nada, verificamos si hay servidores cnt_servidores = 0 item.category = category_servidores #restauramos valores originales item.url = url_servidores @@ -1395,8 +1402,8 @@ def findvideos(item): enlaces_ver = re.compile(patron, re.DOTALL).findall(data_servidores) enlaces_descargar = enlaces_ver - for logo, servidor, idioma, calidad, enlace, title in enlaces_ver: #buscamos enlaces de servidores de ver-online - if ver_enlaces_veronline == 0: #Si no se quiere Ver Online, se sale del bloque + for logo, servidor, idioma, calidad, enlace, title in enlaces_ver: #buscamos enlaces de servidores de ver-online + if ver_enlaces_veronline == 0: #Si no se quiere Ver Online, se sale del bloque break if "ver" in title.lower(): cnt_servidores += 1 @@ -1407,14 +1414,20 @@ def findvideos(item): #Miramos si ha servidores if not data_servidores: #Si no ha logrado encontrar nada nos vamos 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: FINDVIDEOS:. La Web no responde o la URL es erronea. 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 + if item.emergency_urls: #Hay urls de emergencia? + item.url = str(item.emergency_urls[0]).replace ("'", "").replace ("[", "").replace ("]", "") #Guardamos la url del .Torrent + enlaces_ver = item.emergency_urls[1] #Guardamos los datos iniciales de los Servidores Directos + item.armagedon = True #Marcamos la situación como catastrófica + else: + itemlist.append(item.clone(action='', title=item.category + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. 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 data = data_servidores #restauramos los datos data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures") + #buscamos el tamaño del .torrent size = scrapertools.find_single_match(data, '
    Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>') @@ -1435,57 +1448,70 @@ def findvideos(item): #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() - # obtenemos la url torrent - patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent - if not scrapertools.find_single_match(data, patron): - patron = ' 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 + # obtenemos la url torrent o usamos la de emergencia + if not item.armagedon: #Si es un proceso normal, seguimos + patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent + if not scrapertools.find_single_match(data, patron): + patron = ' 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: " + item_local.url + " / 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) - if len(itemlist_f) > 0: #Si hay entradas filtradas... - itemlist.extend(itemlist_f) #Pintamos pantalla filtrada - else: - if config.get_setting('filter_languages', channel_py) > 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 - + if len(itemlist_f) > 0: #Si hay entradas filtradas... + itemlist.extend(itemlist_f) #Pintamos pantalla filtrada + else: + if config.get_setting('filter_languages', channel_py) > 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 + - itemlist_t = [] #Itemlist total de enlaces - itemlist_f = [] #Itemlist de enlaces filtrados + itemlist_t = [] #Itemlist total de enlaces + itemlist_f = [] #Itemlist de enlaces filtrados # VER vídeos, descargar vídeos un link, o múltiples links data = scrapertools.find_single_match(data, '
    (?:)?<\/div><\/div><\/div>)') #Seleccionar el bloque para evitar duplicados @@ -1498,10 +1524,27 @@ def findvideos(item): patron += '<\/div[^<]+
    ([^<]+)?<\/div[^<]+
    2: + #Si hay más de una temporada se sigue, o se ha forzado a listar por temporadas, si no se devuelve el Itemlist original + if len(itemlist_temporadas) > 2 or config.get_setting("no_pile_on_seasons", 'videolibrary') == 0: for item_local in itemlist_temporadas: if "** Todas las Temporadas" in item_local.title: #Si es el título de TODAS las Temporadas, lo ignoramos continue @@ -708,6 +716,8 @@ def post_tmdb_episodios(item, itemlist): del item.from_action if item.from_channel: del item.from_channel + if item.library_filter_show: + del item.library_filter_show for item_local in itemlist: #Recorremos el Itemlist generado por el canal if item_local.add_videolibrary: @@ -742,6 +752,10 @@ def post_tmdb_episodios(item, itemlist): del item_local.from_action if item_local.from_channel: del item_local.from_channel + if item_local.emergency_urls and isinstance(item_local.emergency_urls, dict): + del item_local.emergency_urls + if item_local.library_filter_show: + del item_local.library_filter_show #logger.debug(item_local) #Ajustamos el nombre de la categoría si es un clone de NewPct1 @@ -977,9 +991,6 @@ def post_tmdb_findvideos(item, itemlist): """ #logger.debug(item) - #Creción de título general del vídeo a visualizar en Findvideos - itemlist = [] - # Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal, # con la función "play_from_library" item.unify = False @@ -993,6 +1004,9 @@ def post_tmdb_findvideos(item, itemlist): if item.contentSeason_save: #Restauramos el num. de Temporada item.contentSeason = item.contentSeason_save del item.contentSeason_save + + if item.library_filter_show: + del item.library_filter_show #Salvamos la información de max num. de episodios por temporada para despues de TMDB num_episodios = item.contentEpisodeNumber @@ -1022,6 +1036,9 @@ def post_tmdb_findvideos(item, itemlist): if item.channel == channel_py: item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() + if item.armagedon: #Es una situación catastrófica? + itemlist.append(item.clone(action='', title=item.category + ': [COLOR hotpink]VIDEOTECA: Usando enlaces de emergencia[/COLOR]')) + #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) @@ -1154,10 +1171,10 @@ def post_tmdb_findvideos(item, itemlist): #agregamos la opción de Añadir a Videoteca para péliculas (no series) if (item.contentType == 'movie' or item.contentType == 'season') and item.contentChannel != "videolibrary": #Permitimos la actualización de los títulos, bien para uso inmediato, o para añadir a la videoteca - itemlist.append(item.clone(title="** [COLOR yelow]Actualizar Títulos - vista previa videoteca[/COLOR] **", action="actualizar_titulos", extra="películas", tmdb_stat=False, from_action=item.action, from_title_tmdb=item.title, from_update=True)) + itemlist.append(item.clone(title="** [COLOR yelow]Actualizar Títulos - vista previa videoteca[/COLOR] **", action="actualizar_titulos", extra="peliculas", tmdb_stat=False, from_action=item.action, from_title_tmdb=item.title, from_update=True)) 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_action=item.action, from_title_tmdb=item.title)) + itemlist.append(item.clone(title="**-[COLOR yellow] Añadir a la videoteca [/COLOR]-**", action="add_pelicula_to_library", extra="peliculas", from_action=item.action, from_title_tmdb=item.title)) #Añadimos la opción de ver trailers if item.contentChannel != "videolibrary": @@ -1280,14 +1297,14 @@ def get_torrent_size(url): size = convert_size(sizet) except: - logger.error('ERROR al buscar el tamaño de un .Torrent: ' + url) + logger.error('ERROR al buscar el tamaño de un .Torrent: ' + str(url)) try: os.remove(torrents_path + "/generictools.torrent") #borramos el .torrent except: pass - #logger.debug(url + ' / ' + size) + #logger.debug(str(url) + ' / ' + str(size)) return size @@ -1552,6 +1569,20 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None): return (item, data) +def verify_channel(channel): + + #Lista con los datos de los canales alternativos + #Cargamos en .json del canal para ver las listas de valores en settings + clones = channeltools.get_channel_json(channel_py) + for settings in clones['settings']: #Se recorren todos los settings + if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting + clones = settings['default'] #Carga lista de clones + channel_alt = "'%s'" % channel + if channel_alt in clones: #Si es un clon se pone como canal newpct1, si no se deja + channel = channel_py + return channel + + def web_intervenida(item, data, desactivar=True): logger.info() @@ -1663,24 +1694,27 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F - patron4: expresión Regex aplicable a la url (opcional) - patron5: expresión Regex aplicable a la url (opcional) - content_inc: contenido al que aplica esta entrada, o * (item.contentType o item.extra) - - content_exc: contenido que se excluye de esta entrada (item.contentType) (opcional) + - content_exc: contenido que se excluye de esta entrada (item.contentType) (opcional). opción para 'emerg' - ow_force: indicador para la acción de "videolibrary_service.py". Puede crear la variable item.ow_force: - force: indica al canal que analize toda la serie y que videolibrary_service la reescriba - auto: indica a videolibrary_service que la reescriba - no: no acción para videolibrary_service, solo redirige en visionado de videolibrary - del: borra las estrucuturas de un determinado canal en videolibrary_service, quizás creadas por errores de un canal + - emerg: funcionalidad muy similar a la de "del". se general dinámicamente cada vez que entra un canal con el estado activado en el .json de "emergency_urls". Permite cargar las urls de emergencia en todos los elementos existentes de la Videoteca para canal afectado ejemplos: ('1', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', '(http.?:\/\/.*?\/)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)([^0-9]+-)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-\\d+-(Temporada-).html', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-(\\d+)-', '', 'tvshow, season', '', 'force'), ('1', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', '(http.?:\/\/.*?\/)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-([^.]+).html', '', '', '', 'movie', '', 'force')", ('1', 'torrentrapid', 'torrentlocura', 'http://torrentrapid.com/', 'http://torrentlocura.com/', '', '', '', '', '', '*', '', 'no'), ('1', 'newpct1', '', '', '', '', '', '', '', '', '*', '', 'del'), + ('1', 'torrentrapid', 'torrentrapid', '', '', '', '', '', '', '', '*', '1 ó 2', 'emerg'), La llamada recibe el parámetro Item, el .nfo y los devuleve actualizados, así como opcionalmente el parámetro "overwrite· que puede forzar la reescritura de todos los archivos de la serie, y el parámetro "path" si viene de videolibrary_service. Por último, recibe opcionalmente el parámetro "lookup" si se quiere solo averigurar si habrá migración para ese título, pero sin realizarla. """ + #logger.debug(item) + #if it != None: logger.debug(it) if not it: it = Item() - #logger.debug(item) ow_force_param = True channel_enabled = False update_stat = 0 @@ -1721,28 +1755,59 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F if channel_alt != 'videolibrary': item.category = channel_alt.capitalize() category = "'%s'" % channel_alt - channel_py_alt = '' + channel_py_alt = 'xyz123' if channel in fail_over_list : #Si es un clone de Newpct1, se actualiza el canal y la categoría item.channel = channel_py channel_py_alt = "'%s'" % channel_py if item.channel_host: #y se borran resto de pasadas anteriores del item.channel_host - #Ahora tratamos las webs intervenidas, tranformamos la url, el nfo y borramos los archivos obsoletos de la serie - if channel not in intervencion and channel_py_alt not in intervencion and category not in intervencion and channel_alt != 'videolibrary': #lookup - return (item, it, overwrite) #... el canal/clone está listado + #Analizamos si hay series o películas que migrar, debido a que se ha activado en el .json del canal la opción "guardar" + #"emergency_urls = 1", y hay que calcularla para todos los episodios y película existentes en la Videoteca. + #Si "emergency_urls" está activada para uno o más canales, se verifica en el .nfo del vídeo si ya se ha realizado + #la carga de las urls de emergencia. Sí se ha hecho, se ignora el proceso de conversión. Si no, se convierte por el + #canal en curso cuando hay item.url, o para todos los canales en item.library_urls si no hay un canal específico en curso. + #El mecanismo consiste en generar una regla temporal de migración para cada canal activado. Esta regla actua borrando + #todos los .json de la serie/película. En el caso de la serie, el proceso de actualización de la videoteca los regenerará + #automáticamente. En el caso de peliculas, se general aquí el json actualizado y se marca el .nfo como actualizado. + #Cuando en el .json se activa "Borrar", "emergency_urls = 2", se borran todos los enlaces existentes + #Cuando en el .json se activa "Actualizar", "emergency_urls = 3", se actualizan todos los enlaces existentes + + if it.emergency_urls: + item.emergency_urls = it.emergency_urls #Refrescar desde el .nfo + + if item.url: #Viene de actualización de videoteca de series + #Analizamos si el canal ya tiene las urls de emergencia: guardar o borrar + if (config.get_setting("emergency_urls", item.channel) == 1 and (not item.emergency_urls or (item.emergency_urls and not item.emergency_urls.get(channel_alt, False)))) or (config.get_setting("emergency_urls", item.channel) == 2 and item.emergency_urls.get(channel_alt, False)) or config.get_setting("emergency_urls", item.channel) == 3: + intervencion += ", ('1', '%s', '%s', '', '', '', '', '', '', '', '*', '%s', 'emerg')" % (channel_alt, channel_alt, config.get_setting("emergency_urls", item.channel)) + elif it.library_urls: #Viene de "listar peliculas´" + for canal_vid, url_vid in it.library_urls.items(): #Se recorre "item.library_urls" para buscar canales candidatos + canal_vid_alt = "'%s'" % canal_vid + if canal_vid_alt in fail_over_list: #Se busca si es un clone de newpct1 + channel_bis = channel_py + else: + channel_bis = canal_vid + #Analizamos si el canal ya tiene las urls de emergencia: guardar o borrar + if (config.get_setting("emergency_urls", channel_bis) == 1 and (not it.emergency_urls or (it.emergency_urls and not it.emergency_urls.get(canal_vid, False)))) or (config.get_setting("emergency_urls", channel_bis) == 2 and it.emergency_urls.get(canal_vid, False)) or config.get_setting("emergency_urls", channel_bis) == 3: + intervencion += ", ('1', '%s', '%s', '', '', '', '', '', '', '', '*', '%s', 'emerg')" % (canal_vid, canal_vid, config.get_setting("emergency_urls", channel_bis)) + + #Ahora tratamos las webs intervenidas, tranformamos la url, el nfo y borramos los archivos obsoletos de la serie + if channel not in intervencion and channel_py_alt not in intervencion and category not in intervencion and channel_alt != 'videolibrary': #lookup + return (item, it, overwrite) #... el canal/clone está listado + import ast intervencion_list = ast.literal_eval(intervencion) #Convertir a Array el string #logger.debug(intervencion_list) - + if lookup == True: overwrite = False #Solo avisamos si hay cambios for activo, canal_org, canal_des, url_org, url_des, patron1, patron2, patron3, patron4, patron5, content_inc, content_exc, ow_force in intervencion_list: + opt = '' #Es esta nuestra entrada? - if activo == '1' and (canal_org == channel_alt or canal_org == item.channel or channel_alt == 'videolibrary' or ow_force == 'del'): + if activo == '1' and (canal_org == channel_alt or canal_org == item.channel or channel_alt == 'videolibrary' or ow_force == 'del' or ow_force == 'emerg'): - if ow_force == 'del': #Si es un borrado de estructuras erroneas, hacemos un proceso aparte + if ow_force == 'del' or ow_force == 'emerg': #Si es un borrado de estructuras erroneas, hacemos un proceso aparte canal_des_def = canal_des #Si hay canal de sustitución para item.library_urls, lo usamos if not canal_des_def and canal_org in item.library_urls and len(item.library_urls) == 1: #Si no, lo extraemos de la url canal_des_def = scrapertools.find_single_match(item.library_urls[canal_org], 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').lower() #salvamos la url actual de la estructura a borrar @@ -1762,7 +1827,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F url_total_status = True #marcamos esta url como válida overwrite = True #Le decimos que sobreescriba todos los .jsons item.ow_force = '1' #Le decimos que revise todas las temporadas - if len(item.library_urls) > 1: + if len(item.library_urls) > 1 and ow_force == 'del': item.library_urls.pop(canal_org, None) #borramos la url del canal a borrar overwrite = True #Le decimos que sobreescriba todos los .jsons item.ow_force = '1' #Le decimos que revise todas las temporadas @@ -1783,7 +1848,8 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F if lookup == False: #si es migración completa... delete_stat += 1 #Ya hemos actualizado algo, o habrá que hacerlo... - canal_org_des_list += [(canal_org, canal_des, url_total, ow_force)] #salvamos el resultado para su proceso + if ow_force == 'emerg': opt = content_exc #Salvamos la opción de Guardar o Borrar enlaces + canal_org_des_list += [(canal_org, canal_des, url_total, opt, ow_force)] #salvamos el resultado para su proceso else: if channel_alt == 'videolibrary': #Viene de videolibrary.list_movies: IMPRESCINDIBLE @@ -1837,15 +1903,15 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F if url: url_total = url #Guardamos la suma de los resultados intermedios update_stat += 1 #Ya hemos actualizado algo - canal_org_des_list += [(canal_org, canal_des, url_total, ow_force)] #salvamos el resultado para su proceso + canal_org_des_list += [(canal_org, canal_des, url_total, opt, ow_force)] #salvamos el resultado para su proceso if update_stat > 0 or delete_stat > 0: #Ha habido alguna actualización o borrado? Entonces salvamos if (update_stat > 0 and path != False) or item.ow_force == '1': logger.error('** Lista de Actualizaciones a realizar: ' + str(canal_org_des_list)) - for canal_org_def, canal_des_def, url_total, ow_force_def in canal_org_des_list: #pasamos por todas las "parejas" cambiadas - if ow_force_def != 'del': + for canal_org_def, canal_des_def, url_total, opt_def, ow_force_def in canal_org_des_list: #pasamos por todas las "parejas" cambiadas + if ow_force_def != 'del' and ow_force_def != 'emerg': url_total_def = url_total - if item.channel == channel_py or channel in fail_over_list: #Si es Newpct1... + if (item.channel == channel_py or channel in fail_over_list): #Si es Newpct1... if item.contentType == "tvshow": url_total_def = re.sub(r'\/\d+\/?$', '', url_total) #parece que con el título encuentra la serie, normalmente... if item.url: @@ -1871,30 +1937,57 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F # Listamos todos los ficheros de la serie, asi evitamos tener que comprobar si existe uno por uno canal_erase_list = [] + from core import videolibrarytools raiz, carpetas_series, ficheros = filetools.walk(path).next() ficheros = [filetools.join(path, f) for f in ficheros] #Almacenamos la lista de archivos de la carpeta + #logger.error(ficheros) for archivo in ficheros: - for canal_org_def, canal_des_def, url_total, ow_force_def in canal_org_des_list: #pasamos por todas las "parejas" a borrar + for canal_org_def, canal_des_def, url_total, opt_def, ow_force_def in canal_org_des_list: #pasamos por las "parejas" a borrar canal_erase = '[%s]' % canal_org_def + canal_erase_alt = "'%s'" % canal_org_def canal_new = '[%s]' % canal_des_def - if canal_erase in archivo: #Borramos los .json que sean de los canal afectados - if canal_des_def: + archivo_alt = "'%s'" % scrapertools.find_single_match(archivo, '\[(\w+)\].json') + if archivo_alt == "''": archivo_alt = "'xyz123'" + #logger.error(canal_erase + canal_new + archivo + archivo_alt) + #Borramos los .json que sean de los canal afectados, incluidos todos los de los clones de newpct1 si éste es el canal + if canal_erase in archivo or (ow_force_def == 'emerg' and canal_erase_alt in fail_over_list and archivo_alt in fail_over_list): + if canal_des_def and it.contentType == 'movie': #Si es película ... item_json = Item().fromjson(filetools.read(archivo)) #leemos el .json ante de borrarlo para salvar... title = item_json.title #... el título con su formato language = item_json.language #... los idiomas, que no están en el .nfo wanted = item_json.wanted #... y wanted con el título original json_path = archivo.replace(canal_erase, canal_new) #Salvamos el path del .json para luego crearlo - json_path_list += [(canal_org_def, canal_des_def, url_total, json_path, title, language, wanted)] + + emer_urls = '' + if ow_force_def == 'emerg' and opt_def in ['1', '3']: #Si era una op. para añadir/actualizar urls de emergencia ... + item_json = videolibrarytools.emergency_urls(item_json) #... ejecutamos "findvideos" del canal para obtenerlas + if item_json.emergency_urls: #... si las hay ... + emer_urls = item_json.emergency_urls #... lo preparamos para el .json + if it.emergency_urls and not isinstance(it.emergency_urls, dict): + del it.emergency_urls + if not it.emergency_urls: #... lo actualizamos en el .nfo + it.emergency_urls = dict() #... iniciamos la variable si no existe + it.emergency_urls.update({canal_des_def: True}) #... se marca como activo + else: + continue #Si no hay url, pasamos al siguiente, sin borrar el .json + if ow_force_def == 'emerg' and opt_def == '2': #Si era una operación para borrar urls de emergencia ... + emer_urls = '2' #borramos enlaces + if it.emergency_urls and not isinstance(it.emergency_urls, dict): + del it.emergency_urls + if it.emergency_urls and it.emergency_urls.get(item_json.channel, False): + it.emergency_urls.pop(item_json.channel, None) #borramos la entrada del .nfo + + json_path_list += [(canal_org_def, canal_des_def, url_total, json_path, title, language, wanted, emer_urls)] filetools.remove(archivo) #Borramos el .json logger.error('** BORRAMOS: ' + str(archivo)) - if ow_force_def == 'del': #Si la función es 'del' ... + if ow_force_def == 'del' or ow_force_def == 'emerg': #Si la función es 'del' or 'emerg' ... overwrite = True #Le decimos que sobreescriba todos los .jsons item.ow_force = '1' #Le decimos que revise todas las temporadas #Si se ha cambiado algo, se actualizan los .nfo - if item.contentType == "movie" and ".nfo" in archivo: + if item.contentType == "movie" and ".nfo" in archivo: #Para películas if it.ow_force: del it.ow_force - filetools.write(archivo, head_nfo + it.tojson()) #escribo el .nfo de la peli por si aborta update + filetools.write(archivo, head_nfo + it.tojson()) #escribo el .nfo de la peli if item.contentType != "movie" and "tvshow.nfo" in archivo: filetools.write(archivo, head_nfo + it.tojson()) #escribo el tvshow.nfo por si aborta update @@ -1908,15 +2001,17 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F del item_movie.library_urls del item_movie.nfo del item_movie.path - del item_movie.strm_path - del item_movie.text_color + if item_movie.strm_path: del item_movie.strm_path + if item_movie.text_color: del item_movie.text_color if not item_movie.context: item_movie.context = "['buscar_trailer']" if not item_movie.extra: item_movie.extra = "peliculas" if json_path_list: logger.error('** .json LIST: ' + str(json_path_list)) - for canal_org_def, canal_des_def, url_total, json_path, title, language, wanted in json_path_list: #pasamos por todas canales + for canal_org_def, canal_des_def, url_total, json_path, title, language, wanted, emer_urls in json_path_list: #pasamos por todos canales logger.error('** ESCRIBIMOS: ' + json_path) + item_movie.emergency_urls = False + del item_movie.emergency_urls item_movie.channel = canal_des_def #mombre del canal migrado if not item_movie.category: item_movie.category = canal_des_def.capitalize() #categoría item_movie.url = url_total #url migrada @@ -1924,10 +2019,17 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F if language: item_movie.language = language #restaurmos los idiomas if wanted: item_movie.wanted = wanted #restaurmos wanted item_movie.added_replacing = canal_org_def #guardamos la traza del canal reemplazado + if emer_urls == '2': #si estamos borrando urls de emergencia ... + if item_movie.emergency_urls: + del item_movie.emergency_urls #... las borramos + elif emer_urls: #si estamos añadiendo urls de emergencia ... + item_movie.emergency_urls = emer_urls #... las copiamos al .json filetools.write(json_path, item_movie.tojson()) #Salvamos el nuevo .json de la película if (update_stat > 0 and path != False and ow_force_def in ['force', 'auto']) or item.ow_force == '1' or len(json_path_list) > 0: logger.error('ITEM cambiado') + if it.emergency_urls: + logger.error(it.emergency_urls) logger.error(item) return (item, it, overwrite) diff --git a/plugin.video.alfa/videolibrary_service.py b/plugin.video.alfa/videolibrary_service.py index 2ea63840..187b2845 100644 --- a/plugin.video.alfa/videolibrary_service.py +++ b/plugin.video.alfa/videolibrary_service.py @@ -25,6 +25,9 @@ def update(path, p_dialog, i, t, serie, overwrite): ###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial try: + head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo') #Refresca el .nfo para recoger actualizaciones + if it.emergency_urls: + serie.emergency_urls = it.emergency_urls serie, it, overwrite = generictools.redirect_clone_newpct1(serie, head_nfo, it, path, overwrite) except: pass From fe9e8216e8b492415e0e48dfc76517144e74e979 Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Wed, 31 Oct 2018 16:20:00 +0100 Subject: [PATCH 03/12] =?UTF-8?q?Subtorrents:=20mejora=20en=20subt=C3=ADtu?= =?UTF-8?q?los?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/channels/subtorrents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.video.alfa/channels/subtorrents.py b/plugin.video.alfa/channels/subtorrents.py index 6e5ebe34..07f3c693 100644 --- a/plugin.video.alfa/channels/subtorrents.py +++ b/plugin.video.alfa/channels/subtorrents.py @@ -452,7 +452,7 @@ def findvideos(item): data_subtitle = scrapertools.find_single_match(data_subtitle, patron) patron = '.*? 1: #Solo se guarda si hay más de un idioma. Si no, automático + if subtitles: item.subtitle = [] for subtitle in subtitles: subtitle = subtitle.replace('&', '&').replace('.io/', sufix).replace('.com/', sufix) From d16e3efffbb3496be7cc40d04cd0622fe02fd1b4 Mon Sep 17 00:00:00 2001 From: Alfa-beto <30815244+Alfa-beto@users.noreply.github.com> Date: Wed, 31 Oct 2018 12:24:45 -0300 Subject: [PATCH 04/12] correcciones y novedades MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AnimeFlv: Corrección para videoteca - BlogHorror: Corrección por cambio de estructura - CanalPelis: Corrección por cambio de estructura - Dilo: Correccion en listados de episodios - FanPelis: Corrección en la detección de enlaces - PelisPlus: Corrección en la detección de temporadas, eposidios y enlaces - PelisR: Corrección en la detección de enlaces - RetroSeries: Corrección por cambio de estructura - TuPelicua: Nuevo canal --- plugin.video.alfa/channels/animeflv.py | 2 +- plugin.video.alfa/channels/bloghorror.py | 4 +- plugin.video.alfa/channels/canalpelis.py | 41 ++-- plugin.video.alfa/channels/dilo.py | 3 +- plugin.video.alfa/channels/fanpelis.py | 9 +- plugin.video.alfa/channels/pelisplus.py | 71 ++++--- plugin.video.alfa/channels/pelisr.py | 11 +- plugin.video.alfa/channels/retroseriestv.py | 60 +++--- plugin.video.alfa/channels/tupelicula.json | 77 ++++++++ plugin.video.alfa/channels/tupelicula.py | 205 ++++++++++++++++++++ 10 files changed, 402 insertions(+), 81 deletions(-) create mode 100644 plugin.video.alfa/channels/tupelicula.json create mode 100644 plugin.video.alfa/channels/tupelicula.py diff --git a/plugin.video.alfa/channels/animeflv.py b/plugin.video.alfa/channels/animeflv.py index 14787bcc..de6d7901 100644 --- a/plugin.video.alfa/channels/animeflv.py +++ b/plugin.video.alfa/channels/animeflv.py @@ -181,7 +181,7 @@ def episodios(item): itemlist.append(item.clone(title=title, url=url, action='findvideos', show=info[1])) itemlist = itemlist[::-1] if config.get_videolibrary_support() and len(itemlist) > 0: - itemlist.append(Item(channel=item.channel, title="Añadir esta serie a la videoteca", + itemlist.append(Item(channel=item.channel, title="Añadir esta serie a la videoteca", url=item.url, action="add_serie_to_library", extra="episodios")) return itemlist diff --git a/plugin.video.alfa/channels/bloghorror.py b/plugin.video.alfa/channels/bloghorror.py index 0004b752..210c62bb 100644 --- a/plugin.video.alfa/channels/bloghorror.py +++ b/plugin.video.alfa/channels/bloghorror.py @@ -30,8 +30,8 @@ def mainlist(item): itemlist = [] - itemlist.append(Item(channel=item.channel, fanart=fanart, title="Todas", action="list_all", url=host, - thumbnail=get_thumb('all', auto=True))) + itemlist.append(Item(channel=item.channel, fanart=fanart, title="Todas", action="list_all", + url=host+'/category/terror', thumbnail=get_thumb('all', auto=True))) itemlist.append(Item(channel=item.channel, fanart=fanart, title="Asiaticas", action="list_all", url=host+'/category/asiatico', thumbnail=get_thumb('asiaticas', auto=True))) diff --git a/plugin.video.alfa/channels/canalpelis.py b/plugin.video.alfa/channels/canalpelis.py index cbea6079..3a4a8b5a 100644 --- a/plugin.video.alfa/channels/canalpelis.py +++ b/plugin.video.alfa/channels/canalpelis.py @@ -348,31 +348,38 @@ def episodios(item): return itemlist - def findvideos(item): logger.info() + from lib import generictools + import urllib + import base64 itemlist = [] - data = httptools.downloadpage(item.url).data data = re.sub(r"\n|\r|\t|\(.*?\)|\s{2}| ", "", data) - patron = '
    ' + patron = 'data-post="(\d+)" data-nume="(\d+)".*?img src=\'([^\']+)\'' matches = re.compile(patron, re.DOTALL).findall(data) + for id, option, lang in matches: + lang = scrapertools.find_single_match(lang, '.*?/flags/(.*?).png') + if lang == 'en': + lang = 'VOSE' + post = {'action': 'doo_player_ajax', 'post': id, 'nume': option, 'type':'movie'} + post = urllib.urlencode(post) + test_url = '%swp-admin/admin-ajax.php' % host + new_data = httptools.downloadpage(test_url, post=post, headers={'Referer':item.url}).data + hidden_url = scrapertools.find_single_match(new_data, "src='([^']+)'") + new_data = httptools.downloadpage(hidden_url, follow_redirects=False) + try: + b64_url = scrapertools.find_single_match(new_data.headers['location'], "y=(.*)") + url = base64.b64decode(b64_url) + except: + url = hidden_url + if url != '': + itemlist.append( + Item(channel=item.channel, url=url, title='%s', action='play', language=lang, + infoLabels=item.infoLabels)) - for option, url in matches: - datas = httptools.downloadpage(urlparse.urljoin(host, url), - headers={'Referer': item.url}).data - - patron = ']+src="([^"]+)"' - url = scrapertools.find_single_match(datas, patron) - lang = scrapertools.find_single_match( - data, '
  • <\/b> (.*?)' % option) - lang = lang.replace('Español ', '').replace('B.S.O. ', '') - - server = servertools.get_server_from_url(url) - title = "%s [COLOR yellow](%s) (%s)[/COLOR]" % (item.contentTitle, server.title(), lang) - itemlist.append(item.clone(action='play', url=url, title=title, extra1=title, - server=server, language = lang, text_color=color3)) + itemlist = servertools.get_servers_itemlist(itemlist, lambda x: x.title % x.server.capitalize()) if config.get_videolibrary_support() and len(itemlist) > 0 and item.extra != 'episodios': itemlist.append(Item(channel=__channel__, url=item.url, action="add_pelicula_to_library", extra="findvideos", diff --git a/plugin.video.alfa/channels/dilo.py b/plugin.video.alfa/channels/dilo.py index 70a52b20..a1c8dfde 100644 --- a/plugin.video.alfa/channels/dilo.py +++ b/plugin.video.alfa/channels/dilo.py @@ -204,14 +204,13 @@ def episodesxseason(item): data = jsontools.load(httptools.downloadpage(seasons_url, post=post, headers=headers).data) infoLabels = item.infoLabels for dict in data: - episode = dict['number'] epi_name = dict['name'] title = '%sx%s - %s' % (season, episode, epi_name) url = '%s%s/' % (host, dict['permalink']) infoLabels['episode'] = episode itemlist.append(Item(channel=item.channel, title=title, action='findvideos', url=url, - contentEpisodeNumber=season, id=item.id, infoLabels=infoLabels)) + contentEpisodeNumber=episode, id=item.id, infoLabels=infoLabels)) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) diff --git a/plugin.video.alfa/channels/fanpelis.py b/plugin.video.alfa/channels/fanpelis.py index aba09ec5..ede3f2d6 100644 --- a/plugin.video.alfa/channels/fanpelis.py +++ b/plugin.video.alfa/channels/fanpelis.py @@ -247,10 +247,17 @@ def episodesxseason(item): def findvideos(item): logger.info() + import urllib + itemlist = [] data = get_source(item.url) - patron = '