diff --git a/plugin.video.alfa/channels/elitetorrent.py b/plugin.video.alfa/channels/elitetorrent.py index 235a7c40..224e94a6 100644 --- a/plugin.video.alfa/channels/elitetorrent.py +++ b/plugin.video.alfa/channels/elitetorrent.py @@ -40,9 +40,13 @@ def submenu(item): logger.info() itemlist = [] + data = '' try: data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) except: + pass + + if not data: logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) return itemlist #Algo no funciona, pintamos lo que tenemos @@ -55,6 +59,13 @@ def submenu(item): patron = ')", "", httptools.downloadpage(item.url).data) except: - logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data) - itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + pass + if not data: #Si la web está caída salimos sin dar error - logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data) - itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos patron = '
.*?<\/nav><\/div><\/div>' data = scrapertools.find_single_match(data, patron) @@ -110,9 +121,14 @@ def listado(item): matches = re.compile(patron, re.DOTALL).findall(data) if not matches and not '503 Backend fetch failed' 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.channel.capitalize() + ': 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 + 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_listado(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + + logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': 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 #logger.debug("PATRON: " + patron) #logger.debug(matches) @@ -153,7 +169,7 @@ def listado(item): if "dual" in scrapedcategory.lower() or "dual" in title.lower(): item_local.language[0:0] = ["DUAL"] - #Limpiamos el título de la basuna innecesaria + #Limpiamos el título de la basura innecesaria title = title.replace("Dual", "").replace("dual", "").replace("Subtitulada", "").replace("subtitulada", "").replace("Subt", "").replace("subt", "").replace("Sub", "").replace("sub", "").replace("(Proper)", "").replace("(proper)", "").replace("Proper", "").replace("proper", "").replace("#", "").replace("(Latino)", "").replace("Latino", "") title = title.replace("- HDRip", "").replace("(HDRip)", "").replace("- Hdrip", "").replace("(microHD)", "").replace("(DVDRip)", "").replace("(HDRip)", "").replace("(BR-LINE)", "").replace("(HDTS-SCREENER)", "").replace("(BDRip)", "").replace("(BR-Screener)", "").replace("(DVDScreener)", "").replace("TS-Screener", "").replace(" TS", "").replace(" Ts", "") title = re.sub(r'\??\s?\d*?\&.*', '', title).title().strip() @@ -199,11 +215,11 @@ def listado(item): itemlist.append(item_local.clone()) #Pintar pantalla - #if not item.category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global - # return itemlist #Retornamos sin pasar por la fase de maquillaje para ahorra tiempo + 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 #Pasamos a TMDB la lista completa Itemlist - #tmdb.set_infoLabels(itemlist, True) + tmdb.set_infoLabels(itemlist, True) #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB item, itemlist = generictools.post_tmdb_listado(item, itemlist) @@ -239,9 +255,13 @@ def findvideos(item): itemlist = [] #Bajamos los datos de la página + data = '' try: data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) except: + pass + + if not data: logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': 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 @@ -268,6 +288,11 @@ def findvideos(item): #logger.info("link Magnet: " + link_magnet) if not link_torrent and not link_magnet: #error + 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 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron_t + " / " + patron_m + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos diff --git a/plugin.video.alfa/channels/grantorrent.py b/plugin.video.alfa/channels/grantorrent.py index ce2f5121..27ed4ee5 100644 --- a/plugin.video.alfa/channels/grantorrent.py +++ b/plugin.video.alfa/channels/grantorrent.py @@ -63,9 +63,13 @@ def submenu(item): thumb_buscar = get_thumb("search.png") + data = '' try: data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) except: + pass + + if not data: logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) return itemlist #Algo no funciona, pintamos lo que tenemos @@ -73,6 +77,13 @@ def submenu(item): if item.extra == "peliculas": patron = '
') except: - logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + video_section) - itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + pass + cnt_next += 1 if not data: #Si la web está caída salimos sin dar error logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + video_section) @@ -178,6 +196,11 @@ def listado(item): matches_alt = re.compile(patron, re.DOTALL).findall(video_section) if not matches_alt and not '
0 resultados' in data: #error + 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_listado(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': 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 @@ -349,9 +372,13 @@ def findvideos(item): itemlist = [] #Bajamos los datos de la página + data = '' try: data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) except: + pass + + if not data: logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': 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 @@ -361,6 +388,11 @@ def findvideos(item): patron = '\/icono_.*?png" title="(?P.*?)?" [^>]+><\/td>(?P.*?)?.*?(?P.*?)?<\/td>)", "", httptools.downloadpage(item.url).data) data = data.replace('"', "'") except: #Algún error de proceso, salimos + pass + + if not data: logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea" + item.url) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: EPISODIOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log')) return itemlist diff --git a/plugin.video.alfa/channels/newpct1.py b/plugin.video.alfa/channels/newpct1.py index 9cae9612..89a6f77e 100644 --- a/plugin.video.alfa/channels/newpct1.py +++ b/plugin.video.alfa/channels/newpct1.py @@ -134,6 +134,13 @@ def submenu(item): 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): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + for clone_inter, autoridad in item.intervencion: + thumb_intervenido = get_thumb(autoridad) + itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido)) + return itemlist #Salimos + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url + data) #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) @@ -211,6 +218,13 @@ def submenu_novedades(item): 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): + 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_listado(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + 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) @@ -650,6 +676,7 @@ def listado_busqueda(item): #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: + data = '' try: data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, post=item.post, timeout=timeout_search).data) except: @@ -661,6 +688,11 @@ def listado_busqueda(item): else: 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): + 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_listado(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + 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) @@ -1236,6 +1268,11 @@ def findvideos(item): patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent #Verificamos si se ha cargado una página, y si además tiene la estructura correcta if not data or not scrapertools.find_single_match(data, patron): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + 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 @@ -1531,6 +1568,11 @@ 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): + 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_episodios(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea: " + item.url) logger.error(pattern + data) diff --git a/plugin.video.alfa/lib/generictools.py b/plugin.video.alfa/lib/generictools.py index 57fda526..8027c314 100644 --- a/plugin.video.alfa/lib/generictools.py +++ b/plugin.video.alfa/lib/generictools.py @@ -665,6 +665,7 @@ def post_tmdb_findvideos(item, itemlist): En Itemlist devuelve un Item con el pseudotítulo. Ahí el canal irá agregando el resto. """ + #logger.debug(item) #Creción de título general del vídeo a visualizar en Findvideos itemlist = [] @@ -684,11 +685,12 @@ def post_tmdb_findvideos(item, itemlist): if item.infoLabels['temporada_num_episodios'] and item.contentEpisodeNumber <= item.infoLabels['temporada_num_episodios']: num_episodios = item.infoLabels['temporada_num_episodios'] - # Obtener la información actualizada del Episodio, si no la hay. Siempre cuando viene de Videoteca - if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'): - tmdb.set_infoLabels(item, True) - elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary": - tmdb.set_infoLabels(item, True) + # Obtener la información actualizada del vídeo. En una segunda lectura de TMDB da más información que en la primera + #if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'): + # tmdb.set_infoLabels(item, True) + #elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary": + # tmdb.set_infoLabels(item, True) + tmdb.set_infoLabels(item, True) #Restauramos la información de max num. de episodios por temporada despues de TMDB try: if item.infoLabels['temporada_num_episodios']: @@ -698,7 +700,7 @@ 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) @@ -722,27 +724,34 @@ def post_tmdb_findvideos(item, itemlist): if item.quality.lower() in ['gb', 'mb']: item.quality = item.quality.replace('GB', 'G B').replace('Gb', 'G b').replace('MB', 'M B').replace('Mb', 'M b') + + #busco "duration" en infoLabels + tiempo = 0 + if item.infoLabels['duration']: + tiempo = item.infoLabels['duration'] + elif item.contentChannel == 'videolibrary': #No hay, viene de la Videoteca? buscamos en la DB #Leo de la BD de Kodi la duración de la película o episodio. En "from_fields" se pueden poner las columnas que se quiera - nun_records = 0 - if item.contentType == 'movie': - nun_records, records = get_field_from_kodi_DB(item, from_fields='c11') #Leo de la BD de Kodi la duración de la película - else: - nun_records, records = get_field_from_kodi_DB(item, from_fields='c09') #Leo de la BD de Kodi la duración del episodio - if nun_records > 0: #Hay registros? - for strFileName, field1 in records: #Es un array, busco el campo del registro: añadir en el FOR un fieldX por nueva columna - tiempo_final = 0 - try: - tiempo_final = int(field1) #lo convierto a int, pero puede se null - if tiempo_final == 0: #en episodios suele estar a 0 - continue #pasamos - if tiempo_final > 700: #Si está en segundos - tiempo_final = tiempo_final / 60 #Lo transformo a minutos - horas = tiempo_final / 60 #Lo transformo a horas - resto = tiempo_final - (horas * 60) #guardo el resto de minutos de la hora - item.quality += ' [%s:%s]' % (str(horas).zfill(2), str(resto).zfill(2)) #Lo agrego a Calidad del Servidor - except: - pass + nun_records = 0 + if item.contentType == 'movie': + nun_records, records = get_field_from_kodi_DB(item, from_fields='c11') #Leo de la BD de Kodi la duración de la película + else: + nun_records, records = get_field_from_kodi_DB(item, from_fields='c09') #Leo de la BD de Kodi la duración del episodio + if nun_records > 0: #Hay registros? + #Es un array, busco el campo del registro: añadir en el FOR un fieldX por nueva columna + for strFileName, field1 in records: + tiempo = field1 + + try: #calculamos el timepo en hh:mm + tiempo_final = int(tiempo) #lo convierto a int, pero puede se null + if tiempo_final > 0: #Si el tiempo está a 0, pasamos + if tiempo_final > 700: #Si está en segundos + tiempo_final = tiempo_final / 60 #Lo transformo a minutos + horas = tiempo_final / 60 #Lo transformo a horas + resto = tiempo_final - (horas * 60) #guardo el resto de minutos de la hora + item.quality += ' [%s:%s]' % (str(horas).zfill(2), str(resto).zfill(2)) #Lo agrego a Calidad del Servidor + except: + pass #Ajustamos el nombre de la categoría if item.channel != channel_py: @@ -1078,7 +1087,7 @@ def web_intervenida(item, data, desactivar=True): if item.channel == channel_py: #Si es un clone de Newpct1, lo desactivamos for settings in json_data['settings']: #Se recorren todos los settings if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting - action_excluded = scrapertools.find_single_match(settings['default'], "\('\d', '%s', '[^']+', '[^']*', '([^']*)'\)" % item.category.lower()) #extraemos el valor de action_excluded + action_excluded = scrapertools.find_single_match(settings['default'], "\('\d', '%s', '[^']+', '[^']*', '([^']*)'\)" % item.category.lower()) #extraemos el valor de action_excluded if action_excluded: if "intervenido" not in action_excluded: action_excluded += ', %s' % judicial #Agregamos el thumb de la autoridad judicial @@ -1095,7 +1104,8 @@ def web_intervenida(item, data, desactivar=True): #Guardamos los cambios hechos en el .json try: - disabled = config.set_setting('enabled', False, item.channel) + if item.channel != channel_py: + disabled = config.set_setting('enabled', False, item.channel) channel_path = filetools.join(config.get_runtime_path(), "channels", item.channel + ".json") with open(channel_path, 'w') as outfile: #Grabamos el .json actualizado json.dump(json_data, outfile, sort_keys = True, indent = 2, ensure_ascii = False)