Siguiente<\/a>'
+ try:
+ next_page_url, curr_page = scrapertools.find_single_match(data, patron)
+ curr_page = int(curr_page) / len(matches)
+ except: #Si no lo encuentra, lo ponemos a 1
+ #logger.error('ERROR 03: LISTADO: Al obtener la paginación: ' + patron + ' / ' + data)
+ fin = 0 #Forzamos a salir del WHILE al final del FOR
+ cnt_title = 0 #Evitamos pié de página
+ curr_page = 1
+ next_page_url = item.url
+ next_page_url = urlparse.urljoin(host, next_page_url)
+ #logger.debug('curr_page: ' + str(curr_page) + ' / url: ' + next_page_url)
+
+ #Empezamos el procesado de matches
+ for scrapedtitle, scrapedurl, scrapedthumb in matches:
+ if item.extra2 == 'categorias': #Cambia el orden de tres parámetros (Categorías)
+ title = scrapedthumb
+ url = urlparse.urljoin(host, scrapedtitle)
+ thumb = scrapedurl
+ else: #lo estándar
+ title = scrapedtitle
+ url = urlparse.urljoin(host, scrapedurl)
+ thumb = scrapedthumb
+
+
+ quality = scrapertools.find_single_match(title, '\[(.*?)\]') #capturamos quality
+ title = re.sub(r'\[.*?\]', '', title) #y lo borramos de title
+
+ title = title.replace("á", "a").replace("é", "e").replace("í", "i").replace("ó", "o").replace("ú", "u").replace("ü", "u").replace("�", "ñ").replace("ñ", "ñ").replace("ã", "a").replace("&etilde;", "e").replace("ĩ", "i").replace("õ", "o").replace("ũ", "u").replace("ñ", "ñ").replace("’", "'")
+
+ item_local = item.clone() #Creamos copia de Item para trabajar
+ if item_local.tipo: #... y limpiamos
+ 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.intervencion:
+ del item_local.intervencion
+ if item_local.viewmode:
+ del item_local.viewmode
+ item_local.text_bold = True
+ del item_local.text_bold
+ item_local.text_color = True
+ del item_local.text_color
+
+ title_subs = [] #creamos una lista para guardar info importante
+ item_local.language = [] #iniciamos Lenguaje
+ item_local.quality = quality #guardamos la calidad, si la hay
+ item_local.url = url #guardamos el thumb
+ item_local.thumbnail = thumb #guardamos el thumb
+ item_local.context = "['buscar_trailer']"
+
+ item_local.contentType = "movie" #por defecto, son películas
+ item_local.action = "findvideos"
+
+ #Ajustamos los idiomas
+ if ("-latino-" in url.lower() or "(latino)" in title.lower()) and "LAT" not in item_local.language:
+ item_local.language += ['LAT']
+ elif ('-vos-' in url.lower() or '-vose-' in url.lower() or '(vos)' in title.lower() or '(vose)' in title.lower()) and "VOSE" not in item_local.language:
+ item_local.language += ['VOSE']
+ elif ('-vo-' in url.lower() or '(vo)' in title.lower()) and "VO" not in item_local.language:
+ item_local.language += ['VO']
+
+ if item_local.language == []:
+ item_local.language = ['CAST'] #Por defecto
+
+ title = re.sub(r'\(.*?\)', '', title) #Limpiamos del idioma de title
+
+ #Detectamos info interesante a guardar para después de TMDB
+ if scrapertools.find_single_match(title, '[m|M].*?serie'):
+ title = re.sub(r'[m|M]iniserie', '', title)
+ title_subs += ["Miniserie"]
+ if scrapertools.find_single_match(title, '[s|S]aga'):
+ title = re.sub(r'[s|S]aga', '', title)
+ title_subs += ["Saga"]
+ if scrapertools.find_single_match(title, '[c|C]olecc'):
+ title = re.sub(r'[c|C]olecc...', '', title)
+ title_subs += ["Colección"]
+
+ 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() or "v.e." in title.lower()or "v e " in title.lower():
+ title_subs += ["[V. Extendida]"]
+ title = title.replace("Version Extendida", "").replace("(Version Extendida)", "").replace("V. Extendida", "").replace("VExtendida", "").replace("V Extendida", "").replace("V.Extendida", "").replace("V Extendida", "").replace("V.E.", "").replace("V E ", "").replace("V:Extendida", "")
+
+ item_local.infoLabels["year"] = '-' #Reseteamos el año para TMDB
+
+ #Limpiamos el título de la basura innecesaria
+ title = re.sub(r'- $', '', title)
+ title = re.sub(r'TV|Online|Spanish|Torrent|en Espa\xc3\xb1ol|Español|Latino|Subtitulado|Blurayrip|Bluray rip|\[.*?\]|R2 Pal|\xe3\x80\x90 Descargar Torrent \xe3\x80\x91|Completa|Temporada|Descargar|Torren', '', title, flags=re.IGNORECASE)
+
+ #Terminamos de limpiar el título
+ title = re.sub(r'\??\s?\d*?\&.*', '', title)
+ title = re.sub(r'[\(|\[]\s+[\)|\]]', '', title)
+ title = title.replace('()', '').replace('[]', '').strip().lower().title()
+
+ item_local.from_title = title.strip().lower().title() #Guardamos esta etiqueta para posible desambiguación de título
+
+ #Salvamos el título según el tipo de contenido
+ if item_local.contentType == "movie":
+ item_local.contentTitle = title.strip().lower().title()
+ else:
+ item_local.contentSerieName = title.strip().lower().title()
+
+ item_local.title = title.strip().lower().title() #Guardamos el título
+
+ #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
+
+ #Ahora se filtra por idioma, si procede, y se pinta lo que vale
+ if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra
+ itemlist = filtertools.get_link(itemlist, item_local, list_language)
+ else:
+ itemlist.append(item_local.clone()) #Si no, pintar pantalla
+
+ cnt_title = len(itemlist) #Contador de líneas añadidas
+
+ #logger.debug(item_local)
+
+ #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)
+
+ # Si es necesario añadir paginacion
+ if cnt_title >= cnt_tot * cnt_pct:
+
+ title = '%s' % curr_page
+
+ itemlist.append(Item(channel=item.channel, action="listado", title=">> Página siguiente " + title, url=next_page_url, extra=item.extra, extra2=item.extra2))
return itemlist
-
+
def findvideos(item):
logger.info()
-
itemlist = []
- data = get_source(item.url)
+ itemlist_t = [] #Itemlist total de enlaces
+ itemlist_f = [] #Itemlist de enlaces filtrados
+ if not item.language:
+ item.language = ['CAST'] #Castellano por defecto
- second_url = scrapertools.find_single_match(data, ')| ", "", httptools.downloadpage(item.url, timeout=timeout).data)
+ data = unicode(data, "utf-8", errors="replace").encode("utf-8")
+ except:
+ pass
+
+ if not data:
+ logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url)
+ 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
- if url != '':
- quality = item.quality
- title = 'Torrent [%s]' % quality
- itemlist.append(item.clone(title=title, url=url, quality=quality, action='play', server='torrent',
- language='cast'))
+ matches = re.compile(patron, re.DOTALL).findall(data)
+ if not matches: #error
+ logger.error("ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web " + " / PATRON: " + patron + data)
+ itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web. Verificar en la Web esto último y reportar el error con el log'))
+ return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
+
+ #logger.debug("PATRON: " + patron)
+ #logger.debug(matches)
+ #logger.debug(data)
+
+ #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
+ item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
- # Requerido para FilterTools
+ #Ahora tratamos los enlaces .torrent
+ for scrapedurl in matches: #leemos los torrents con la diferentes calidades
+ if 'javascript' in scrapedurl: #evitamos la basura
+ continue
+
+ url = urlparse.urljoin(host, scrapedurl)
+ #Leemos la siguiente página, que es de verdad donde está el magnet/torrent
+ try:
+ data = re.sub(r"\n|\r|\t|\s{2}|()| ", "", httptools.downloadpage(url, timeout=timeout).data)
+ data = unicode(data, "utf-8", errors="replace").encode("utf-8")
+ except:
+ pass
+
+ patron = "window.open\('([^']+)'"
+ url = scrapertools.find_single_match(data, patron)
+ if not url: #error
+ logger.error("ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web " + " / PATRON: " + patron + data)
+ itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web. Verificar en la Web esto último y reportar el error con el log'))
+ continue #si no hay más datos, algo no funciona, pasamos al siguiente
+
+ #Generamos una copia de Item para trabajar sobre ella
+ item_local = item.clone()
+
+ item_local.url = urlparse.urljoin(host, url)
+
+ #Buscamos si ya tiene tamaño, si no, los buscamos en el archivo .torrent
+ size = scrapertools.find_single_match(item_local.quality, '\s\[(\d+,?\d*?\s\w\s?[b|B])\]')
+ if not size:
+ size = generictools.get_torrent_size(item_local.url) #Buscamos el tamaño en el .torrent
+ if size:
+ item_local.title = re.sub(r'\s\[\d+,?\d*?\s\w[b|B]\]', '', item_local.title) #Quitamos size de título, si lo traía
+ item_local.title = '%s [%s]' % (item_local.title, size) #Agregamos size al final del título
+ size = size.replace('GB', 'G B').replace('Gb', 'G b').replace('MB', 'M B').replace('Mb', 'M b')
+ item_local.quality = re.sub(r'\s\[\d+,?\d*?\s\w\s?[b|B]\]', '', item_local.quality) #Quitamos size de calidad, si lo traía
+ item_local.quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final de la calidad
+
+ #Ahora pintamos el link del Torrent
+ item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language))
+
+ #Preparamos título y calidad, quitamos etiquetas vacías
+ item_local.title = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', item_local.title)
+ item_local.title = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', item_local.title)
+ item_local.title = item_local.title.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
+ item_local.quality = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', item_local.quality)
+ item_local.quality = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', item_local.quality).strip()
+ item_local.quality = item_local.quality.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
- itemlist = filtertools.get_links(itemlist, item, list_language)
+ item_local.alive = "??" #Calidad del link sin verificar
+ item_local.action = "play" #Visualizar vídeo
+ item_local.server = "torrent" #Servidor Torrent
+
+ itemlist_t.append(item_local.clone()) #Pintar pantalla, si no se filtran idiomas
+
+ # Requerido para FilterTools
+ if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra
+ itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío
+
+ #logger.debug("TORRENT: " + scrapedurl + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName)
+
+ #logger.debug(item_local)
+
+ if len(itemlist_f) > 0: #Si hay entradas filtradas...
+ itemlist.extend(itemlist_f) #Pintamos pantalla filtrada
+ else:
+ if config.get_setting('filter_languages', channel) > 0 and len(itemlist_t) > 0: #Si no hay entradas filtradas ...
+ thumb_separador = get_thumb("next.png") #... pintamos todo con aviso
+ itemlist.append(Item(channel=item.channel, url=host, title="[COLOR red][B]NO hay elementos con el idioma seleccionado[/B][/COLOR]", thumbnail=thumb_separador))
+ itemlist.extend(itemlist_t) #Pintar pantalla con todo si no hay filtrado
# Requerido para AutoPlay
-
- autoplay.start(itemlist, item)
-
- if config.get_videolibrary_support() and len(itemlist) > 0 and item.extra != 'findvideos':
- itemlist.append(
- Item(channel=item.channel, title='[COLOR yellow]Añadir esta pelicula a la videoteca[/COLOR]', url=item.url,
- action="add_pelicula_to_library", extra="findvideos", contentTitle=item.contentTitle))
-
+ autoplay.start(itemlist, item) #Lanzamos Autoplay
+
return itemlist
+def actualizar_titulos(item):
+ logger.info()
+
+ item = generictools.update_title(item) #Llamamos al método que actualiza el título con tmdb.find_and_set_infoLabels
+
+ #Volvemos a la siguiente acción en el canal
+ return item
+
+
def search(item, texto):
logger.info()
texto = texto.replace(" ", "+")
- item.url = item.url + texto
- item.type = 'buscar'
+
+ try:
+ item.url = item.url + texto
- if texto != '':
- return list_all(item)
- else:
+ if texto != '':
+ return listado(item)
+ except:
+ import sys
+ for line in sys.exc_info():
+ logger.error("{0}".format(line))
return []
-
-
+
+
def newest(categoria):
logger.info()
itemlist = []
item = Item()
+
try:
if categoria in ['torrent', 'peliculas']:
- item.url = host+'torrents'
+ item.url = host + 'torrents'
elif categoria == '4k':
- item.url = 'http://www.todo-peliculas.com/tags/4k'
- item.type='section'
- itemlist = list_all(item)
+ item.url = host + 'tags/4k'
+ item.extra2 = 'categorias'
+ item.extra = "peliculas"
+ item.channel = channel
+ item.category_new= 'newest'
- if itemlist[-1].title == 'Siguiente >>':
+ itemlist = listado(item)
+ if ">> Página siguiente" in itemlist[-1].title:
itemlist.pop()
+
+ # Se captura la excepción, para no interrumpir al canal novedades si un canal falla
except:
import sys
for line in sys.exc_info():
logger.error("{0}".format(line))
return []
- return itemlist
+ return itemlist
\ No newline at end of file