From 969403fc771afdddcb53766a58b4551fbe5997c0 Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Fri, 1 Jun 2018 19:41:34 +0200 Subject: [PATCH] =?UTF-8?q?Clones=20NewPct1:=20mejoras=20internas,=20gesti?= =?UTF-8?q?=C3=B3n=20de=20errores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/channels/descargas2020.json | 8 + plugin.video.alfa/channels/descargas2020.py | 159 +++++++++++++----- .../channels/mispelisyseries.json | 8 + plugin.video.alfa/channels/mispelisyseries.py | 159 +++++++++++++----- plugin.video.alfa/channels/torrentlocura.json | 8 + plugin.video.alfa/channels/torrentlocura.py | 159 +++++++++++++----- plugin.video.alfa/channels/torrentrapid.json | 8 + plugin.video.alfa/channels/torrentrapid.py | 159 +++++++++++++----- .../channels/tumejortorrent.json | 8 + plugin.video.alfa/channels/tumejortorrent.py | 159 +++++++++++++----- plugin.video.alfa/channels/tvsinpagar.json | 8 + plugin.video.alfa/channels/tvsinpagar.py | 159 +++++++++++++----- 12 files changed, 744 insertions(+), 258 deletions(-) diff --git a/plugin.video.alfa/channels/descargas2020.json b/plugin.video.alfa/channels/descargas2020.json index b6b22008..d159b644 100755 --- a/plugin.video.alfa/channels/descargas2020.json +++ b/plugin.video.alfa/channels/descargas2020.json @@ -22,6 +22,14 @@ "enabled": true, "visible": true }, + { + "id": "modo_grafico", + "type": "bool", + "label": "Buscar información extra (TMDB)", + "default": true, + "enabled": true, + "visible": true + }, { "id": "clonenewpct1_ver_enlaces_veronline", "type": "list", diff --git a/plugin.video.alfa/channels/descargas2020.py b/plugin.video.alfa/channels/descargas2020.py index 241d2456..906edb96 100644 --- a/plugin.video.alfa/channels/descargas2020.py +++ b/plugin.video.alfa/channels/descargas2020.py @@ -15,6 +15,11 @@ from core import tmdb host = 'http://descargas2020.com/' +item = Item() +if not item.channel: + item.channel = scrapertools.find_single_match(host, r'(\w+)\.com\/') +__modo_grafico__ = config.get_setting('modo_grafico', item.channel) + def mainlist(item): logger.info() @@ -57,7 +62,12 @@ def submenu(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("'", '"').replace('/series"', '/series/"') #Compatibilidad con mispelisy.series.com @@ -68,11 +78,19 @@ def submenu(item): else: if data: data = scrapertools.get_match(data, patron) + 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.channel.capitalize() + '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 else: - return itemlist + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos patron = '<.*?href="([^"]+)".*?>([^>]+)' 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.channel.capitalize() + '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() @@ -106,6 +124,10 @@ def alfabeto(item): patron = ']+>([^>]+)' 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.channel.capitalize() + '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.upper() @@ -130,7 +152,12 @@ def listado(item): if item.totalItems: del item.totalItems - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de 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 #Establecemos los valores básicos en función del tipo de contenido if item.extra == "peliculas": @@ -150,6 +177,10 @@ def listado(item): patron = '' if data: fichas = scrapertools.get_match(data, patron) + if not fichas: #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 else: return itemlist page_extra = clase @@ -157,10 +188,15 @@ def listado(item): #Scrapea los datos de cada vídeo. Título alternativo se mantiene, aunque no se usa de momento patron = ' item.infoLabels['temporada_num_episodios']: item.infoLabels['temporada_num_episodios'] = num_episodios # Descarga la página - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea " + " / 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures") @@ -1029,10 +1082,9 @@ def findvideos(item): #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']) - if item.infoLabels['episodio_titulo'] == item.contentSerieName: - item.infoLabels['episodio_titulo'] = '' + item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '') if item.infoLabels['aired'] and item.contentType == "episode": - item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') + item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() @@ -1040,6 +1092,10 @@ def findvideos(item): # obtenemos la url torrent patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' item_local.url = scrapertools.find_single_match(data, patron) + if not item_local.url: #error + logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: FINDVIDEOS: 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_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso #logger.debug("Patron: " + patron + " url: " + item_local.url) #logger.debug(data) @@ -1268,7 +1324,12 @@ def episodios(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + except: #Algún error de proceso, salimos + logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea") + 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 #Busca y pre-carga todas las páginas de episodios que componen las serie, para obtener la url de cada página pattern = '' % "pagination" # item.pattern @@ -1288,22 +1349,27 @@ def episodios(item): list_pages = [item.url] for index, page in enumerate(list_pages): #Recorre la lista de páginas - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) - data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") - data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com - pattern = '' % "buscar-list" # item.pattern - if scrapertools.find_single_match(data, pattern): + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) + data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") + data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com + pattern = '' % "buscar-list" # item.pattern data = scrapertools.get_match(data, pattern) - else: - logger.debug(item) - logger.debug("patron: " + pattern + " / data: " + data) - return itemlist + except: + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / " + str(list_pages + " / DATA: " + data)) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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 if "pelisyseries.com" in host: pattern = ']*>
]+>(?P.*?)?<\/h3>.*?<\/li>' else: pattern = ']*>]+>(?P.*?)?<\/h2>' matches = re.compile(pattern, re.DOTALL).findall(data) + if not matches: #error + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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: " + pattern) #logger.debug(matches) @@ -1380,20 +1446,21 @@ def episodios(item): item_local.contentEpisodeNumber = match['episode'] item_local.contentSeason = match['season'] item_local.action = "findvideos" + item_local.contentType = "episode" item_local.extra = "episodios" itemlist.append(item_local.clone()) - - logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber)) - + # Pasada por TMDB y clasificación de lista por temporada y episodio - tmdb.set_infoLabels(itemlist, seekTmdb = True) + tmdb.set_infoLabels(itemlist, seekTmdb = __modo_grafico__) if len(itemlist) > 1: itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) # Pasada para maqullaje de los títulos obtenidos desde TMDB num_episodios = 1 + num_episodios_lista = [0] num_temporada = 1 + num_episodios_flag = True for item_local in itemlist: # Si no hay datos de TMDB, pongo los datos locales que conozco @@ -1416,7 +1483,7 @@ def episodios(item): if item_local.infoLabels['episodio_titulo']: if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName) - item_local.infoLabels['episodio_titulo'] = '%s %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) + item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) else: item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo']) if item_local.infoLabels['year']: @@ -1439,8 +1506,14 @@ def episodios(item): num_episodios = item_local.contentEpisodeNumber if num_episodios and not item_local.infoLabels['temporada_num_episodios']: item_local.infoLabels['temporada_num_episodios'] = num_episodios + num_episodios_flag = False + num_episodios_lista[item_local.contentSeason:] = [num_episodios] - #logger.debug("title=[" + item_local.title + "], url=[" + item_local.url + "], item=[" + str(item_local) + "]") + #logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag)) + + if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie + for item_local in itemlist: + item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason] if config.get_videolibrary_support() and len(itemlist) > 0: title = '' diff --git a/plugin.video.alfa/channels/mispelisyseries.json b/plugin.video.alfa/channels/mispelisyseries.json index 10e65edb..bb97b924 100755 --- a/plugin.video.alfa/channels/mispelisyseries.json +++ b/plugin.video.alfa/channels/mispelisyseries.json @@ -21,6 +21,14 @@ "enabled": true, "visible": true }, + { + "id": "modo_grafico", + "type": "bool", + "label": "Buscar información extra (TMDB)", + "default": true, + "enabled": true, + "visible": true + }, { "id": "clonenewpct1_ver_enlaces_veronline", "type": "list", diff --git a/plugin.video.alfa/channels/mispelisyseries.py b/plugin.video.alfa/channels/mispelisyseries.py index 76e2c44e..24d0be1e 100644 --- a/plugin.video.alfa/channels/mispelisyseries.py +++ b/plugin.video.alfa/channels/mispelisyseries.py @@ -15,6 +15,11 @@ from core import tmdb host = 'http://mispelisyseries.com/' +item = Item() +if not item.channel: + item.channel = scrapertools.find_single_match(host, r'(\w+)\.com\/') +__modo_grafico__ = config.get_setting('modo_grafico', item.channel) + def mainlist(item): logger.info() @@ -57,7 +62,12 @@ def submenu(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("'", '"').replace('/series"', '/series/"') #Compatibilidad con mispelisy.series.com @@ -68,11 +78,19 @@ def submenu(item): else: if data: data = scrapertools.get_match(data, patron) + 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.channel.capitalize() + '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 else: - return itemlist + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos patron = '<.*?href="([^"]+)".*?>([^>]+)' 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.channel.capitalize() + '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() @@ -106,6 +124,10 @@ def alfabeto(item): patron = ']+>([^>]+)' 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.channel.capitalize() + '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.upper() @@ -130,7 +152,12 @@ def listado(item): if item.totalItems: del item.totalItems - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de 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 #Establecemos los valores básicos en función del tipo de contenido if item.extra == "peliculas": @@ -150,6 +177,10 @@ def listado(item): patron = '' if data: fichas = scrapertools.get_match(data, patron) + if not fichas: #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 else: return itemlist page_extra = clase @@ -157,10 +188,15 @@ def listado(item): #Scrapea los datos de cada vídeo. Título alternativo se mantiene, aunque no se usa de momento patron = ' item.infoLabels['temporada_num_episodios']: item.infoLabels['temporada_num_episodios'] = num_episodios # Descarga la página - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea " + " / 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures") @@ -1029,10 +1082,9 @@ def findvideos(item): #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']) - if item.infoLabels['episodio_titulo'] == item.contentSerieName: - item.infoLabels['episodio_titulo'] = '' + item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '') if item.infoLabels['aired'] and item.contentType == "episode": - item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') + item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() @@ -1040,6 +1092,10 @@ def findvideos(item): # obtenemos la url torrent patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' item_local.url = scrapertools.find_single_match(data, patron) + if not item_local.url: #error + logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: FINDVIDEOS: 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_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso #logger.debug("Patron: " + patron + " url: " + item_local.url) #logger.debug(data) @@ -1268,7 +1324,12 @@ def episodios(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + except: #Algún error de proceso, salimos + logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea") + 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 #Busca y pre-carga todas las páginas de episodios que componen las serie, para obtener la url de cada página pattern = '' % "pagination" # item.pattern @@ -1288,22 +1349,27 @@ def episodios(item): list_pages = [item.url] for index, page in enumerate(list_pages): #Recorre la lista de páginas - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) - data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") - data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com - pattern = '' % "buscar-list" # item.pattern - if scrapertools.find_single_match(data, pattern): + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) + data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") + data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com + pattern = '' % "buscar-list" # item.pattern data = scrapertools.get_match(data, pattern) - else: - logger.debug(item) - logger.debug("patron: " + pattern + " / data: " + data) - return itemlist + except: + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / " + str(list_pages + " / DATA: " + data)) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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 if "pelisyseries.com" in host: pattern = ']*>
]+>(?P.*?)?<\/h3>.*?<\/li>' else: pattern = ']*>]+>(?P.*?)?<\/h2>' matches = re.compile(pattern, re.DOTALL).findall(data) + if not matches: #error + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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: " + pattern) #logger.debug(matches) @@ -1380,20 +1446,21 @@ def episodios(item): item_local.contentEpisodeNumber = match['episode'] item_local.contentSeason = match['season'] item_local.action = "findvideos" + item_local.contentType = "episode" item_local.extra = "episodios" itemlist.append(item_local.clone()) - - logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber)) - + # Pasada por TMDB y clasificación de lista por temporada y episodio - tmdb.set_infoLabels(itemlist, seekTmdb = True) + tmdb.set_infoLabels(itemlist, seekTmdb = __modo_grafico__) if len(itemlist) > 1: itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) # Pasada para maqullaje de los títulos obtenidos desde TMDB num_episodios = 1 + num_episodios_lista = [0] num_temporada = 1 + num_episodios_flag = True for item_local in itemlist: # Si no hay datos de TMDB, pongo los datos locales que conozco @@ -1416,7 +1483,7 @@ def episodios(item): if item_local.infoLabels['episodio_titulo']: if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName) - item_local.infoLabels['episodio_titulo'] = '%s %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) + item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) else: item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo']) if item_local.infoLabels['year']: @@ -1439,8 +1506,14 @@ def episodios(item): num_episodios = item_local.contentEpisodeNumber if num_episodios and not item_local.infoLabels['temporada_num_episodios']: item_local.infoLabels['temporada_num_episodios'] = num_episodios + num_episodios_flag = False + num_episodios_lista[item_local.contentSeason:] = [num_episodios] - #logger.debug("title=[" + item_local.title + "], url=[" + item_local.url + "], item=[" + str(item_local) + "]") + #logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag)) + + if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie + for item_local in itemlist: + item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason] if config.get_videolibrary_support() and len(itemlist) > 0: title = '' diff --git a/plugin.video.alfa/channels/torrentlocura.json b/plugin.video.alfa/channels/torrentlocura.json index 357f99f9..5401381d 100755 --- a/plugin.video.alfa/channels/torrentlocura.json +++ b/plugin.video.alfa/channels/torrentlocura.json @@ -23,6 +23,14 @@ "enabled": true, "visible": true }, + { + "id": "modo_grafico", + "type": "bool", + "label": "Buscar información extra (TMDB)", + "default": true, + "enabled": true, + "visible": true + }, { "id": "clonenewpct1_ver_enlaces_veronline", "type": "list", diff --git a/plugin.video.alfa/channels/torrentlocura.py b/plugin.video.alfa/channels/torrentlocura.py index 8f5a5e2a..c354db34 100755 --- a/plugin.video.alfa/channels/torrentlocura.py +++ b/plugin.video.alfa/channels/torrentlocura.py @@ -15,6 +15,11 @@ from core import tmdb host = 'http://torrentlocura.com/' +item = Item() +if not item.channel: + item.channel = scrapertools.find_single_match(host, r'(\w+)\.com\/') +__modo_grafico__ = config.get_setting('modo_grafico', item.channel) + def mainlist(item): logger.info() @@ -57,7 +62,12 @@ def submenu(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("'", '"').replace('/series"', '/series/"') #Compatibilidad con mispelisy.series.com @@ -68,11 +78,19 @@ def submenu(item): else: if data: data = scrapertools.get_match(data, patron) + 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.channel.capitalize() + '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 else: - return itemlist + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos patron = '<.*?href="([^"]+)".*?>([^>]+)' 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.channel.capitalize() + '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() @@ -106,6 +124,10 @@ def alfabeto(item): patron = ']+>([^>]+)' 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.channel.capitalize() + '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.upper() @@ -130,7 +152,12 @@ def listado(item): if item.totalItems: del item.totalItems - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de 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 #Establecemos los valores básicos en función del tipo de contenido if item.extra == "peliculas": @@ -150,6 +177,10 @@ def listado(item): patron = '' if data: fichas = scrapertools.get_match(data, patron) + if not fichas: #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 else: return itemlist page_extra = clase @@ -157,10 +188,15 @@ def listado(item): #Scrapea los datos de cada vídeo. Título alternativo se mantiene, aunque no se usa de momento patron = ' item.infoLabels['temporada_num_episodios']: item.infoLabels['temporada_num_episodios'] = num_episodios # Descarga la página - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea " + " / 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures") @@ -1029,10 +1082,9 @@ def findvideos(item): #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']) - if item.infoLabels['episodio_titulo'] == item.contentSerieName: - item.infoLabels['episodio_titulo'] = '' + item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '') if item.infoLabels['aired'] and item.contentType == "episode": - item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') + item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() @@ -1040,6 +1092,10 @@ def findvideos(item): # obtenemos la url torrent patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' item_local.url = scrapertools.find_single_match(data, patron) + if not item_local.url: #error + logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: FINDVIDEOS: 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_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso #logger.debug("Patron: " + patron + " url: " + item_local.url) #logger.debug(data) @@ -1268,7 +1324,12 @@ def episodios(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + except: #Algún error de proceso, salimos + logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea") + 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 #Busca y pre-carga todas las páginas de episodios que componen las serie, para obtener la url de cada página pattern = '
    (.*?)
' % "pagination" # item.pattern @@ -1288,22 +1349,27 @@ def episodios(item): list_pages = [item.url] for index, page in enumerate(list_pages): #Recorre la lista de páginas - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) - data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") - data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com - pattern = '
    (.*?)
' % "buscar-list" # item.pattern - if scrapertools.find_single_match(data, pattern): + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) + data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") + data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com + pattern = '
    (.*?)
' % "buscar-list" # item.pattern data = scrapertools.get_match(data, pattern) - else: - logger.debug(item) - logger.debug("patron: " + pattern + " / data: " + data) - return itemlist + except: + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / " + str(list_pages + " / DATA: " + data)) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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 if "pelisyseries.com" in host: pattern = ']*>
]+>(?P.*?)?<\/h3>.*?<\/li>' else: pattern = ']*>]+>(?P.*?)?<\/h2>' matches = re.compile(pattern, re.DOTALL).findall(data) + if not matches: #error + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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: " + pattern) #logger.debug(matches) @@ -1380,20 +1446,21 @@ def episodios(item): item_local.contentEpisodeNumber = match['episode'] item_local.contentSeason = match['season'] item_local.action = "findvideos" + item_local.contentType = "episode" item_local.extra = "episodios" itemlist.append(item_local.clone()) - - logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber)) - + # Pasada por TMDB y clasificación de lista por temporada y episodio - tmdb.set_infoLabels(itemlist, seekTmdb = True) + tmdb.set_infoLabels(itemlist, seekTmdb = __modo_grafico__) if len(itemlist) > 1: itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) # Pasada para maqullaje de los títulos obtenidos desde TMDB num_episodios = 1 + num_episodios_lista = [0] num_temporada = 1 + num_episodios_flag = True for item_local in itemlist: # Si no hay datos de TMDB, pongo los datos locales que conozco @@ -1416,7 +1483,7 @@ def episodios(item): if item_local.infoLabels['episodio_titulo']: if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName) - item_local.infoLabels['episodio_titulo'] = '%s %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) + item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) else: item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo']) if item_local.infoLabels['year']: @@ -1439,8 +1506,14 @@ def episodios(item): num_episodios = item_local.contentEpisodeNumber if num_episodios and not item_local.infoLabels['temporada_num_episodios']: item_local.infoLabels['temporada_num_episodios'] = num_episodios + num_episodios_flag = False + num_episodios_lista[item_local.contentSeason:] = [num_episodios] - #logger.debug("title=[" + item_local.title + "], url=[" + item_local.url + "], item=[" + str(item_local) + "]") + #logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag)) + + if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie + for item_local in itemlist: + item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason] if config.get_videolibrary_support() and len(itemlist) > 0: title = '' diff --git a/plugin.video.alfa/channels/torrentrapid.json b/plugin.video.alfa/channels/torrentrapid.json index 77afe28f..6b0a7129 100644 --- a/plugin.video.alfa/channels/torrentrapid.json +++ b/plugin.video.alfa/channels/torrentrapid.json @@ -23,6 +23,14 @@ "enabled": true, "visible": true }, + { + "id": "modo_grafico", + "type": "bool", + "label": "Buscar información extra (TMDB)", + "default": true, + "enabled": true, + "visible": true + }, { "id": "clonenewpct1_ver_enlaces_veronline", "type": "list", diff --git a/plugin.video.alfa/channels/torrentrapid.py b/plugin.video.alfa/channels/torrentrapid.py index 47090a32..d1409c0a 100644 --- a/plugin.video.alfa/channels/torrentrapid.py +++ b/plugin.video.alfa/channels/torrentrapid.py @@ -15,6 +15,11 @@ from core import tmdb host = 'http://torrentrapid.com/' +item = Item() +if not item.channel: + item.channel = scrapertools.find_single_match(host, r'(\w+)\.com\/') +__modo_grafico__ = config.get_setting('modo_grafico', item.channel) + def mainlist(item): logger.info() @@ -57,7 +62,12 @@ def submenu(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("'", '"').replace('/series"', '/series/"') #Compatibilidad con mispelisy.series.com @@ -68,11 +78,19 @@ def submenu(item): else: if data: data = scrapertools.get_match(data, patron) + 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.channel.capitalize() + '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 else: - return itemlist + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos patron = '<.*?href="([^"]+)".*?>([^>]+)' 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.channel.capitalize() + '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() @@ -106,6 +124,10 @@ def alfabeto(item): patron = ']+>([^>]+)' 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.channel.capitalize() + '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.upper() @@ -130,7 +152,12 @@ def listado(item): if item.totalItems: del item.totalItems - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de 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 #Establecemos los valores básicos en función del tipo de contenido if item.extra == "peliculas": @@ -150,6 +177,10 @@ def listado(item): patron = '
    (.*?)
' if data: fichas = scrapertools.get_match(data, patron) + if not fichas: #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 else: return itemlist page_extra = clase @@ -157,10 +188,15 @@ def listado(item): #Scrapea los datos de cada vídeo. Título alternativo se mantiene, aunque no se usa de momento patron = ' item.infoLabels['temporada_num_episodios']: item.infoLabels['temporada_num_episodios'] = num_episodios # Descarga la página - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea " + " / 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures") @@ -1029,10 +1082,9 @@ def findvideos(item): #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']) - if item.infoLabels['episodio_titulo'] == item.contentSerieName: - item.infoLabels['episodio_titulo'] = '' + item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '') if item.infoLabels['aired'] and item.contentType == "episode": - item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') + item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() @@ -1040,6 +1092,10 @@ def findvideos(item): # obtenemos la url torrent patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' item_local.url = scrapertools.find_single_match(data, patron) + if not item_local.url: #error + logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: FINDVIDEOS: 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_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso #logger.debug("Patron: " + patron + " url: " + item_local.url) #logger.debug(data) @@ -1268,7 +1324,12 @@ def episodios(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + except: #Algún error de proceso, salimos + logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea") + 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 #Busca y pre-carga todas las páginas de episodios que componen las serie, para obtener la url de cada página pattern = '
    (.*?)
' % "pagination" # item.pattern @@ -1288,22 +1349,27 @@ def episodios(item): list_pages = [item.url] for index, page in enumerate(list_pages): #Recorre la lista de páginas - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) - data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") - data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com - pattern = '
    (.*?)
' % "buscar-list" # item.pattern - if scrapertools.find_single_match(data, pattern): + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) + data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") + data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com + pattern = '
    (.*?)
' % "buscar-list" # item.pattern data = scrapertools.get_match(data, pattern) - else: - logger.debug(item) - logger.debug("patron: " + pattern + " / data: " + data) - return itemlist + except: + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / " + str(list_pages + " / DATA: " + data)) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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 if "pelisyseries.com" in host: pattern = ']*>
]+>(?P.*?)?<\/h3>.*?<\/li>' else: pattern = ']*>]+>(?P.*?)?<\/h2>' matches = re.compile(pattern, re.DOTALL).findall(data) + if not matches: #error + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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: " + pattern) #logger.debug(matches) @@ -1380,20 +1446,21 @@ def episodios(item): item_local.contentEpisodeNumber = match['episode'] item_local.contentSeason = match['season'] item_local.action = "findvideos" + item_local.contentType = "episode" item_local.extra = "episodios" itemlist.append(item_local.clone()) - - logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber)) - + # Pasada por TMDB y clasificación de lista por temporada y episodio - tmdb.set_infoLabels(itemlist, seekTmdb = True) + tmdb.set_infoLabels(itemlist, seekTmdb = __modo_grafico__) if len(itemlist) > 1: itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) # Pasada para maqullaje de los títulos obtenidos desde TMDB num_episodios = 1 + num_episodios_lista = [0] num_temporada = 1 + num_episodios_flag = True for item_local in itemlist: # Si no hay datos de TMDB, pongo los datos locales que conozco @@ -1416,7 +1483,7 @@ def episodios(item): if item_local.infoLabels['episodio_titulo']: if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName) - item_local.infoLabels['episodio_titulo'] = '%s %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) + item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) else: item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo']) if item_local.infoLabels['year']: @@ -1439,8 +1506,14 @@ def episodios(item): num_episodios = item_local.contentEpisodeNumber if num_episodios and not item_local.infoLabels['temporada_num_episodios']: item_local.infoLabels['temporada_num_episodios'] = num_episodios + num_episodios_flag = False + num_episodios_lista[item_local.contentSeason:] = [num_episodios] - #logger.debug("title=[" + item_local.title + "], url=[" + item_local.url + "], item=[" + str(item_local) + "]") + #logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag)) + + if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie + for item_local in itemlist: + item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason] if config.get_videolibrary_support() and len(itemlist) > 0: title = '' diff --git a/plugin.video.alfa/channels/tumejortorrent.json b/plugin.video.alfa/channels/tumejortorrent.json index 3d0b53cd..24220195 100644 --- a/plugin.video.alfa/channels/tumejortorrent.json +++ b/plugin.video.alfa/channels/tumejortorrent.json @@ -22,6 +22,14 @@ "enabled": true, "visible": true }, + { + "id": "modo_grafico", + "type": "bool", + "label": "Buscar información extra (TMDB)", + "default": true, + "enabled": true, + "visible": true + }, { "id": "clonenewpct1_ver_enlaces_veronline", "type": "list", diff --git a/plugin.video.alfa/channels/tumejortorrent.py b/plugin.video.alfa/channels/tumejortorrent.py index 61f987da..82d84217 100644 --- a/plugin.video.alfa/channels/tumejortorrent.py +++ b/plugin.video.alfa/channels/tumejortorrent.py @@ -15,6 +15,11 @@ from core import tmdb host = 'http://tumejortorrent.com/' +item = Item() +if not item.channel: + item.channel = scrapertools.find_single_match(host, r'(\w+)\.com\/') +__modo_grafico__ = config.get_setting('modo_grafico', item.channel) + def mainlist(item): logger.info() @@ -57,7 +62,12 @@ def submenu(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("'", '"').replace('/series"', '/series/"') #Compatibilidad con mispelisy.series.com @@ -68,11 +78,19 @@ def submenu(item): else: if data: data = scrapertools.get_match(data, patron) + 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.channel.capitalize() + '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 else: - return itemlist + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos patron = '<.*?href="([^"]+)".*?>([^>]+)' 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.channel.capitalize() + '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() @@ -106,6 +124,10 @@ def alfabeto(item): patron = ']+>([^>]+)' 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.channel.capitalize() + '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.upper() @@ -130,7 +152,12 @@ def listado(item): if item.totalItems: del item.totalItems - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de 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 #Establecemos los valores básicos en función del tipo de contenido if item.extra == "peliculas": @@ -150,6 +177,10 @@ def listado(item): patron = '
    (.*?)
' if data: fichas = scrapertools.get_match(data, patron) + if not fichas: #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 else: return itemlist page_extra = clase @@ -157,10 +188,15 @@ def listado(item): #Scrapea los datos de cada vídeo. Título alternativo se mantiene, aunque no se usa de momento patron = ' item.infoLabels['temporada_num_episodios']: item.infoLabels['temporada_num_episodios'] = num_episodios # Descarga la página - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea " + " / 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures") @@ -1029,10 +1082,9 @@ def findvideos(item): #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']) - if item.infoLabels['episodio_titulo'] == item.contentSerieName: - item.infoLabels['episodio_titulo'] = '' + item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '') if item.infoLabels['aired'] and item.contentType == "episode": - item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') + item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() @@ -1040,6 +1092,10 @@ def findvideos(item): # obtenemos la url torrent patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' item_local.url = scrapertools.find_single_match(data, patron) + if not item_local.url: #error + logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: FINDVIDEOS: 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_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso #logger.debug("Patron: " + patron + " url: " + item_local.url) #logger.debug(data) @@ -1268,7 +1324,12 @@ def episodios(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + except: #Algún error de proceso, salimos + logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea") + 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 #Busca y pre-carga todas las páginas de episodios que componen las serie, para obtener la url de cada página pattern = '
    (.*?)
' % "pagination" # item.pattern @@ -1288,22 +1349,27 @@ def episodios(item): list_pages = [item.url] for index, page in enumerate(list_pages): #Recorre la lista de páginas - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) - data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") - data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com - pattern = '
    (.*?)
' % "buscar-list" # item.pattern - if scrapertools.find_single_match(data, pattern): + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) + data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") + data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com + pattern = '
    (.*?)
' % "buscar-list" # item.pattern data = scrapertools.get_match(data, pattern) - else: - logger.debug(item) - logger.debug("patron: " + pattern + " / data: " + data) - return itemlist + except: + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / " + str(list_pages + " / DATA: " + data)) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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 if "pelisyseries.com" in host: pattern = ']*>
]+>(?P.*?)?<\/h3>.*?<\/li>' else: pattern = ']*>]+>(?P.*?)?<\/h2>' matches = re.compile(pattern, re.DOTALL).findall(data) + if not matches: #error + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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: " + pattern) #logger.debug(matches) @@ -1380,20 +1446,21 @@ def episodios(item): item_local.contentEpisodeNumber = match['episode'] item_local.contentSeason = match['season'] item_local.action = "findvideos" + item_local.contentType = "episode" item_local.extra = "episodios" itemlist.append(item_local.clone()) - - logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber)) - + # Pasada por TMDB y clasificación de lista por temporada y episodio - tmdb.set_infoLabels(itemlist, seekTmdb = True) + tmdb.set_infoLabels(itemlist, seekTmdb = __modo_grafico__) if len(itemlist) > 1: itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) # Pasada para maqullaje de los títulos obtenidos desde TMDB num_episodios = 1 + num_episodios_lista = [0] num_temporada = 1 + num_episodios_flag = True for item_local in itemlist: # Si no hay datos de TMDB, pongo los datos locales que conozco @@ -1416,7 +1483,7 @@ def episodios(item): if item_local.infoLabels['episodio_titulo']: if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName) - item_local.infoLabels['episodio_titulo'] = '%s %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) + item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) else: item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo']) if item_local.infoLabels['year']: @@ -1439,8 +1506,14 @@ def episodios(item): num_episodios = item_local.contentEpisodeNumber if num_episodios and not item_local.infoLabels['temporada_num_episodios']: item_local.infoLabels['temporada_num_episodios'] = num_episodios + num_episodios_flag = False + num_episodios_lista[item_local.contentSeason:] = [num_episodios] - #logger.debug("title=[" + item_local.title + "], url=[" + item_local.url + "], item=[" + str(item_local) + "]") + #logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag)) + + if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie + for item_local in itemlist: + item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason] if config.get_videolibrary_support() and len(itemlist) > 0: title = '' diff --git a/plugin.video.alfa/channels/tvsinpagar.json b/plugin.video.alfa/channels/tvsinpagar.json index a88f0dc2..6539b031 100644 --- a/plugin.video.alfa/channels/tvsinpagar.json +++ b/plugin.video.alfa/channels/tvsinpagar.json @@ -22,6 +22,14 @@ "enabled": true, "visible": true }, + { + "id": "modo_grafico", + "type": "bool", + "label": "Buscar información extra (TMDB)", + "default": true, + "enabled": true, + "visible": true + }, { "id": "clonenewpct1_ver_enlaces_veronline", "type": "list", diff --git a/plugin.video.alfa/channels/tvsinpagar.py b/plugin.video.alfa/channels/tvsinpagar.py index 4af3fc06..00b31233 100644 --- a/plugin.video.alfa/channels/tvsinpagar.py +++ b/plugin.video.alfa/channels/tvsinpagar.py @@ -15,6 +15,11 @@ from core import tmdb host = 'http://www.tvsinpagar.com/' +item = Item() +if not item.channel: + item.channel = scrapertools.find_single_match(host, r'(\w+)\.com\/') +__modo_grafico__ = config.get_setting('modo_grafico', item.channel) + def mainlist(item): logger.info() @@ -57,7 +62,12 @@ def submenu(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("'", '"').replace('/series"', '/series/"') #Compatibilidad con mispelisy.series.com @@ -68,11 +78,19 @@ def submenu(item): else: if data: data = scrapertools.get_match(data, patron) + 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.channel.capitalize() + '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 else: - return itemlist + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos patron = '<.*?href="([^"]+)".*?>([^>]+)' 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.channel.capitalize() + '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() @@ -106,6 +124,10 @@ def alfabeto(item): patron = ']+>([^>]+)' 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.channel.capitalize() + '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.upper() @@ -130,7 +152,12 @@ def listado(item): if item.totalItems: del item.totalItems - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de 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 #Establecemos los valores básicos en función del tipo de contenido if item.extra == "peliculas": @@ -150,6 +177,10 @@ def listado(item): patron = '
    (.*?)
' if data: fichas = scrapertools.get_match(data, patron) + if not fichas: #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 else: return itemlist page_extra = clase @@ -157,10 +188,15 @@ def listado(item): #Scrapea los datos de cada vídeo. Título alternativo se mantiene, aunque no se usa de momento patron = ' item.infoLabels['temporada_num_episodios']: item.infoLabels['temporada_num_episodios'] = num_episodios # Descarga la página - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea " + " / 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 data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures") @@ -1029,10 +1082,9 @@ def findvideos(item): #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']) - if item.infoLabels['episodio_titulo'] == item.contentSerieName: - item.infoLabels['episodio_titulo'] = '' + item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '') if item.infoLabels['aired'] and item.contentType == "episode": - item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') + item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})') #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() @@ -1040,6 +1092,10 @@ def findvideos(item): # obtenemos la url torrent patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' item_local.url = scrapertools.find_single_match(data, patron) + if not item_local.url: #error + logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: FINDVIDEOS: 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_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso #logger.debug("Patron: " + patron + " url: " + item_local.url) #logger.debug(data) @@ -1268,7 +1324,12 @@ def episodios(item): logger.info() itemlist = [] - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) + except: #Algún error de proceso, salimos + logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea") + 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 #Busca y pre-carga todas las páginas de episodios que componen las serie, para obtener la url de cada página pattern = '
    (.*?)
' % "pagination" # item.pattern @@ -1288,22 +1349,27 @@ def episodios(item): list_pages = [item.url] for index, page in enumerate(list_pages): #Recorre la lista de páginas - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) - data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") - data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com - pattern = '
    (.*?)
' % "buscar-list" # item.pattern - if scrapertools.find_single_match(data, pattern): + try: + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(page).data) + data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") + data = data.replace("chapters", "buscar-list") #Compatibilidad con mispelisy.series.com + pattern = '
    (.*?)
' % "buscar-list" # item.pattern data = scrapertools.get_match(data, pattern) - else: - logger.debug(item) - logger.debug("patron: " + pattern + " / data: " + data) - return itemlist + except: + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / " + str(list_pages + " / DATA: " + data)) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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 if "pelisyseries.com" in host: pattern = ']*>
]+>(?P.*?)?<\/h3>.*?<\/li>' else: pattern = ']*>]+>(?P.*?)?<\/h2>' matches = re.compile(pattern, re.DOTALL).findall(data) + if not matches: #error + logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + pattern + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + 'ERROR 02: EPISODIOS: 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: " + pattern) #logger.debug(matches) @@ -1380,20 +1446,21 @@ def episodios(item): item_local.contentEpisodeNumber = match['episode'] item_local.contentSeason = match['season'] item_local.action = "findvideos" + item_local.contentType = "episode" item_local.extra = "episodios" itemlist.append(item_local.clone()) - - logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber)) - + # Pasada por TMDB y clasificación de lista por temporada y episodio - tmdb.set_infoLabels(itemlist, seekTmdb = True) + tmdb.set_infoLabels(itemlist, seekTmdb = __modo_grafico__) if len(itemlist) > 1: itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) # Pasada para maqullaje de los títulos obtenidos desde TMDB num_episodios = 1 + num_episodios_lista = [0] num_temporada = 1 + num_episodios_flag = True for item_local in itemlist: # Si no hay datos de TMDB, pongo los datos locales que conozco @@ -1416,7 +1483,7 @@ def episodios(item): if item_local.infoLabels['episodio_titulo']: if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName) - item_local.infoLabels['episodio_titulo'] = '%s %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) + item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName) else: item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo']) if item_local.infoLabels['year']: @@ -1439,8 +1506,14 @@ def episodios(item): num_episodios = item_local.contentEpisodeNumber if num_episodios and not item_local.infoLabels['temporada_num_episodios']: item_local.infoLabels['temporada_num_episodios'] = num_episodios + num_episodios_flag = False + num_episodios_lista[item_local.contentSeason:] = [num_episodios] - #logger.debug("title=[" + item_local.title + "], url=[" + item_local.url + "], item=[" + str(item_local) + "]") + #logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag)) + + if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie + for item_local in itemlist: + item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason] if config.get_videolibrary_support() and len(itemlist) > 0: title = ''