# -*- coding: utf-8 -*- import re import sys import urllib import urlparse import datetime import ast from channelselector import get_thumb from core import httptools from core import scrapertools from core import servertools from core.item import Item from platformcode import config, logger, platformtools from core import tmdb from lib import generictools channel_py = 'newpct1' #Código para permitir usar un único canal para todas las webs clones de NewPct1 clone_list = config.get_setting('clonenewpct1_channels_list', channel_py) #Carga lista de clones clone_list = ast.literal_eval(clone_list) #la convierte en array host_index = 0 host_index = config.get_setting('clonenewpct1_channel_default', channel_py) #Clone por defecto i = 0 for active_clone, channel_clone, host_clone, contentType_clone, info_clone in clone_list: if i == host_index: channel_clone_name = channel_clone #Nombre del Canal elegido host = host_clone #URL del Canal elegido break i += 1 item = Item() item.channel_host = host if item.channel != channel_py: item.channel = channel_py item.category = channel_clone_name.capitalize() #Carga de opciones del canal __modo_grafico__ = config.get_setting('modo_grafico', channel_py) #TMDB? modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', channel_py) #Actualización sólo últ. Temporada? timeout = config.get_setting('clonenewpct1_timeout_downloadpage', channel_py) #Timeout downloadpage if timeout == 0: timeout = None platformtools.dialog_notification("NewPct1, ¡¡¡he vuelto como canal VIRTUAL!!!", "Hemos centralizado la gestión de los clones de NewPct1 en NewPct1 como canal virtual. Los clones desaparecerán en breve. Para más información lee el tutorial: https://alfa-addon.com /threads/newpct1-implantando-alta-disponibilidad.1200/", time=30000) #Vayamos a la siguiente acción en el canal Newpct1 from platformcode import launcher channel_clone_name = "mispelisyseries" #Nombre del Canal elegido channel_py = channel_clone_name host = "http://mispelisyseries.com/" item.category = channel_clone_name.capitalize() item.action = "mainlist" item.channel_host = host #launcher.run(item) def mainlist(item): logger.info() #if item.channel != channel_py: # return itemlist = [] if not item.channel_host: item.channel_host = host item.category = channel_clone_name.capitalize() thumb_pelis = get_thumb("channels_movie.png") thumb_pelis_hd = get_thumb("channels_movie_hd.png") thumb_series = get_thumb("channels_tvshow.png") thumb_series_hd = get_thumb("channels_tvshow_hd.png") thumb_series_az = get_thumb("channels_tvshow_az.png") thumb_docus = get_thumb("channels_documentary.png") thumb_buscar = get_thumb("search.png") thumb_settings = get_thumb("setting_0.png") itemlist.append(Item(channel=item.channel, action="submenu", title="Películas", url=host, extra="peliculas", thumbnail=thumb_pelis, category=item.category, channel_host=item.channel_host)) itemlist.append(Item(channel=item.channel, action="submenu", title="Series", url=host, extra="series", thumbnail=thumb_series, category=item.category, channel_host=item.channel_host)) itemlist.append(Item(channel=item.channel, action="submenu", title="Documentales", url=host, extra="varios", thumbnail=thumb_docus, category=item.category, channel_host=item.channel_host)) itemlist.append( Item(channel=item.channel, action="search", title="Buscar", url=host + "buscar", thumbnail=thumb_buscar, category=item.category, channel_host=item.channel_host)) itemlist.append( Item(channel=item.channel, action="", title="[COLOR yellow]Configuración de Servidores:[/COLOR]", url="", thumbnail=thumb_settings, category=item.category, channel_host=item.channel_host)) itemlist.append( Item(channel=item.channel, action="settingCanal", title="Servidores para Ver Online y Descargas", url="", thumbnail=thumb_settings, category=item.category, channel_host=item.channel_host)) return itemlist def settingCanal(item): from platformcode import platformtools return platformtools.show_channel_settings() def submenu(item): logger.info() itemlist = [] data = '' try: data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) except: pass patron = '
  • <\/i>.*Inicio<\/a><\/li>(.+)<\/ul>\s?<\/nav>' #Verificamos si se ha cargado una página, y si además tiene la estructura correcta if not data or not scrapertools.find_single_match(data, patron): logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú item, data = generictools.fail_over_newpct1(item, patron) if not data: #Si no ha logrado encontrar nada, salimos itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR]: Ningún canal NewPct1 activo')) itemlist.append(item.clone(action='', title=item.category + ': ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos elif item.channel_alt: #Si ha habido fail-over, lo comento itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR] [ALT ] en uso')) itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.channel_alt.capitalize() + '[/COLOR] inaccesible')) if item.url_alt: del item.url_alt del item.channel_alt data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") data = data.replace("'", '"').replace('/series"', '/series/"') #Compatibilidad con mispelisy.series.com if "pelisyseries.com" in item.channel_host and item.extra == "varios": #compatibilidad con mispelisy.series.com data = '
  • Documentales
  • ' else: data = scrapertools.get_match(data, patron) #Seleccionamos el trozo que nos interesa if not data: logger.error("ERROR 02: SUBMENU: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: SUBMENU: Ha cambiado la estructura de la Web. Reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos patron = '
  • ([^>]+)<\/a><\/li>' matches = re.compile(patron, re.DOTALL).findall(data) if not matches: logger.error("ERROR 02: SUBMENU: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: SUBMENU: Ha cambiado la estructura de la Web. Reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos for scrapedurl, scrapedtitle in matches: title = scrapedtitle.strip() #Preguntamos por las entradas que no corresponden al "extra" if item.extra in scrapedtitle.lower() or (item.extra == "peliculas" and ("cine" in scrapedurl or "anime" in scrapedurl)) or (item.extra == "varios" and ("documentales" in scrapedurl or "varios" in scrapedurl)): itemlist.append(item.clone(action="listado", title=title, url=scrapedurl)) itemlist.append(item.clone(action="alfabeto", title=title + " [A-Z]", url=scrapedurl)) if item.extra == "peliculas": itemlist.append(item.clone(action="listado", title="Películas 4K", url=item.channel_host + "peliculas-hd/4kultrahd/")) itemlist.append(item.clone(action="alfabeto", title="Películas 4K" + " [A-Z]", url=item.channel_host + "peliculas-hd/4kultrahd/")) return itemlist def alfabeto(item): logger.info() itemlist = [] data = '' data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8") patron = '' if not data or not scrapertools.find_single_match(data, patron): logger.error("ERROR 01: ALFABETO: La Web no responde o ha cambiado de URL: " + item.url + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú item, data = generictools.fail_over_newpct1(item, patron) if not data: #Si no ha logrado encontrar nada, salimos itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR]: Ningún canal NewPct1 activo')) itemlist.append(item.clone(action='', title=item.category + ': ERROR 01: ALFABETO: La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos elif item.channel_alt: #Si ha habido fail-over, lo comento itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR] [ALT ] en uso')) itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.channel_alt.capitalize() + '[/COLOR] inaccesible')) if item.url_alt: del item.url_alt del item.channel_alt data = scrapertools.get_match(data, patron) patron = ']+>([^>]+)' matches = re.compile(patron, re.DOTALL).findall(data) if not matches: logger.error("ERROR 02: ALFABETO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: ALFABETO: Ha cambiado la estructura de la Web. Reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos for scrapedurl, scrapedtitle in matches: title = scrapedtitle.upper() itemlist.append(item.clone(action="listado", title=title, url=scrapedurl)) return itemlist def listado(item): logger.info() itemlist = [] clase = "pelilist" # etiqueta para localizar zona de listado de contenidos url_next_page ='' # Controlde paginación cnt_tot = 30 # Poner el num. máximo de items por página if item.totalItems: del item.totalItems data = '' try: data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) except: pass patron = '' #seleccionamos el bloque que nos interesa if not data or (not scrapertools.find_single_match(data, patron) and not '

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

    ( 0 ) Resultados encontrados ' in data: #error logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: LISTADO: Ha cambiado la estructura de la Web. Reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos elif '

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

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