Merge pull request #457 from lopezvg/master
DocumaniaTV: nuevo canal de documentales
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"id": "documaniatv",
|
||||
"name": "DocumaniaTV",
|
||||
"active": true,
|
||||
"adult": false,
|
||||
"language": ["cast"],
|
||||
"banner": "",
|
||||
"thumbnail": "https://www.documaniatv.com/uploads/xcustom-logo.png.pagespeed.ic.lxJKR_lQE9.webp",
|
||||
"version": 1,
|
||||
"categories": [
|
||||
"documentary",
|
||||
"vos",
|
||||
"direct",
|
||||
"torrent"
|
||||
],
|
||||
"settings": [
|
||||
{
|
||||
"id": "include_in_global_search",
|
||||
"type": "bool",
|
||||
"label": "Incluir en busqueda global",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "modo_grafico",
|
||||
"type": "bool",
|
||||
"label": "Buscar información extra",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "filter_languages",
|
||||
"type": "list",
|
||||
"label": "Mostrar enlaces en idioma...",
|
||||
"default": 0,
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": [
|
||||
"No filtrar",
|
||||
"CAST",
|
||||
"LAT",
|
||||
"VO",
|
||||
"VOS",
|
||||
"VOSE"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "timeout_downloadpage",
|
||||
"type": "list",
|
||||
"label": "Timeout (segs.) en descarga de páginas o verificación de servidores",
|
||||
"default": 5,
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": [
|
||||
"None",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"10"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "include_in_newest_documentales",
|
||||
"type": "bool",
|
||||
"label": "Incluir en Novedades - Documentales",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,792 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
import sys
|
||||
import urllib
|
||||
import urlparse
|
||||
import time
|
||||
|
||||
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
|
||||
from core import tmdb
|
||||
from lib import generictools
|
||||
from channels import filtertools
|
||||
from channels import autoplay
|
||||
|
||||
|
||||
#IDIOMAS = {'CAST': 'Castellano', 'LAT': 'Latino', 'VO': 'Version Original'}
|
||||
IDIOMAS = {'Castellano': 'CAST', 'Latino': 'LAT', 'Version Original': 'VO'}
|
||||
list_language = IDIOMAS.values()
|
||||
list_quality = []
|
||||
list_servers = ['directo']
|
||||
|
||||
|
||||
host = 'https://www.documaniatv.com/'
|
||||
channel = "documaniatv"
|
||||
|
||||
categoria = channel.capitalize()
|
||||
__modo_grafico__ = config.get_setting('modo_grafico', channel)
|
||||
timeout = config.get_setting('timeout_downloadpage', channel)
|
||||
|
||||
|
||||
def mainlist(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
|
||||
thumb_docus = get_thumb("channels_documentary.png")
|
||||
thumb_series = get_thumb("channels_tvshow.png")
|
||||
thumb_buscar = get_thumb("search.png")
|
||||
thumb_separador = get_thumb("next.png")
|
||||
thumb_settings = get_thumb("setting_0.png")
|
||||
thumb_cartelera = get_thumb("now_playing.png")
|
||||
thumb_pelis_vos = get_thumb("channels_vos.png")
|
||||
thumb_popular = get_thumb("popular.png")
|
||||
thumb_generos = get_thumb("genres.png")
|
||||
|
||||
autoplay.init(item.channel, list_servers, list_quality)
|
||||
|
||||
itemlist.append(Item(channel=item.channel, title="Novedades", action="listado", url=host + "newvideos.html", thumbnail=thumb_docus, extra="novedades"))
|
||||
itemlist.append(Item(channel=item.channel, title="Los Más Vistos", action="listado", url=host + "topvideos.html", thumbnail=thumb_popular, extra="populares"))
|
||||
itemlist.append(Item(channel=item.channel, title="Por Géneros", action="categorias", url=host + "categorias-y-canales.html", thumbnail=thumb_generos, extra="categorias"))
|
||||
itemlist.append(Item(channel=item.channel, title="Series", action="listado", url=host + "top-series-documentales.html", thumbnail=thumb_series, extra="series"))
|
||||
|
||||
itemlist.append(Item(channel=item.channel, title="Buscar...", action="search", url=host + "search.php?keywords=", thumbnail=thumb_buscar, extra="search"))
|
||||
|
||||
itemlist.append(Item(channel=item.channel, url=host, title="[COLOR yellow]Configuración:[/COLOR]", folder=False, thumbnail=thumb_separador))
|
||||
|
||||
itemlist.append(Item(channel=item.channel, action="configuracion", title="Configurar canal", thumbnail=thumb_settings))
|
||||
|
||||
autoplay.show_option(item.channel, itemlist) #Activamos Autoplay
|
||||
|
||||
return itemlist
|
||||
|
||||
def configuracion(item):
|
||||
from platformcode import platformtools
|
||||
ret = platformtools.show_channel_settings()
|
||||
platformtools.itemlist_refresh()
|
||||
return
|
||||
|
||||
|
||||
def categorias(item):
|
||||
logger.info()
|
||||
|
||||
itemlist = []
|
||||
|
||||
data = ''
|
||||
try:
|
||||
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url, timeout=timeout).data)
|
||||
data = unicode(data, "utf-8", errors="replace").encode("utf-8")
|
||||
except:
|
||||
pass
|
||||
|
||||
patron = '<a href="([^"]+)" title="([^"]+)">'
|
||||
#Verificamos si se ha cargado una página, y si además tiene la estructura correcta
|
||||
if not data or not scrapertools.find_single_match(data, patron):
|
||||
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
|
||||
if item.intervencion: #Sí ha sido clausurada judicialmente
|
||||
for clone_inter, autoridad in item.intervencion:
|
||||
thumb_intervenido = get_thumb(autoridad)
|
||||
itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido))
|
||||
return itemlist #Salimos
|
||||
|
||||
logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url + data)
|
||||
if not data: #Si no ha logrado encontrar nada, salimos
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
#logger.debug(matches)
|
||||
|
||||
for scrapedurl, scrapedtitle in matches:
|
||||
if 'series documentales' in scrapedtitle.lower():
|
||||
continue
|
||||
itemlist.append(item.clone(action="listado", title=scrapedtitle.capitalize().strip(), url=scrapedurl))
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def listado(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
item.category = categoria
|
||||
|
||||
#logger.debug(item)
|
||||
|
||||
curr_page = 1 # Página inicial Web
|
||||
curr_page_foot = 1 # Página inicial Alfa
|
||||
last_page = 99999 # Última página inicial
|
||||
last_page_foot = 1 # Última página inicial
|
||||
cnt_tot = 40 # Poner el num. máximo de items por página
|
||||
cnt_title = 0 # Contador de líneas insertadas en Itemlist
|
||||
cnt_title_tot = 0 # Contador de líneas insertadas en Itemlist, total
|
||||
if item.curr_page:
|
||||
curr_page = int(item.curr_page) # Si viene de una pasada anterior, lo usamos
|
||||
del item.curr_page # ... y lo borramos
|
||||
if item.curr_page_foot:
|
||||
curr_page_foot = int(item.curr_page_foot) # Si viene de una pasada anterior, lo usamos
|
||||
del item.curr_page_foot # ... y lo borramos
|
||||
if item.last_page:
|
||||
last_page = int(item.last_page) # Si viene de una pasada anterior, lo usamos
|
||||
del item.last_page # ... y lo borramos
|
||||
if item.last_page_foot:
|
||||
last_page_foot = int(item.last_page_foot) # Si viene de una pasada anterior, lo usamos
|
||||
del item.last_page_foot # ... y lo borramos
|
||||
if item.cnt_tot:
|
||||
cnt_tot = int(item.cnt_tot) # Si viene de una pasada anterior, lo usamos
|
||||
del item.cnt_tot # ... y lo borramos
|
||||
if item.cnt_title_tot:
|
||||
cnt_title_tot = int(item.cnt_title_tot) # Si viene de una pasada anterior, lo usamos
|
||||
del item.cnt_title_tot # ... y lo borramos
|
||||
|
||||
inicio = time.time() # Controlaremos que el proceso no exceda de un tiempo razonable
|
||||
fin = inicio + 10 # Después de este tiempo pintamos (segundos)
|
||||
timeout_search = timeout # Timeout para descargas
|
||||
if item.extra == 'search':
|
||||
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
|
||||
|
||||
if not item.extra2: # Si viene de Catálogo o de Alfabeto
|
||||
item.extra2 = ''
|
||||
|
||||
next_page_url = item.url
|
||||
#Máximo num. de líneas permitidas por TMDB. Máx de 10 segundos por Itemlist para no degradar el rendimiento
|
||||
while cnt_title < cnt_tot and curr_page <= last_page and fin > time.time():
|
||||
|
||||
# Descarga la página
|
||||
data = ''
|
||||
try:
|
||||
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)| ", "", httptools.downloadpage(next_page_url, timeout=timeout_search).data)
|
||||
data = unicode(data, "utf-8", errors="replace").encode("utf-8")
|
||||
except:
|
||||
pass
|
||||
|
||||
if not data: #Si la web está caída salimos sin dar error
|
||||
logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data)
|
||||
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log'))
|
||||
break #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
|
||||
#Patrón para todo, menos para Series
|
||||
patron = '<span class="pm-label-duration">(.*?)<\/span>.*?<a href="([^"]+)" title="([^"]+)">.*?data-echo="([^"]+)"'
|
||||
|
||||
#Si viene de Series, ponemos un patrón especializado
|
||||
if item.extra == 'series':
|
||||
patron = '(?:<span class="pm-label-duration">(.*?)<\/span>.*?)?<a href="([^"]+)" title="([^"]+)">.*?<img src="([^"]+)"'
|
||||
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
if not matches and not 'Lo siento, tu búsqueda no arrojó ningún resultado, intenta con otras palabras.' in data: #error
|
||||
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
|
||||
if item.intervencion: #Sí ha sido clausurada judicialmente
|
||||
item, itemlist = generictools.post_tmdb_episodios(item, itemlist) #Llamamos al método para el pintado del error
|
||||
return itemlist #Salimos
|
||||
|
||||
logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
|
||||
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: LISTADO: Ha cambiado la estructura de la Web. Reportar el error con el log'))
|
||||
break #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
|
||||
matches_len = len(matches)
|
||||
if matches_len > cnt_title_tot and cnt_title_tot > 0:
|
||||
matches = matches[cnt_title_tot:]
|
||||
|
||||
#logger.debug("PATRON: " + patron)
|
||||
#logger.debug(matches)
|
||||
#logger.debug(data)
|
||||
|
||||
#Buscamos la url de paginado y la última página
|
||||
data_page = scrapertools.find_single_match(data, '<ul class="pagination pagination-sm pagination-arrows">.*?<\/li><\/ul><\/div><\/div> <\/div>')
|
||||
if item.extra == 'series':
|
||||
patron = '>(\d+)?<\/a><\/li><li class=""><a href="([^"]+-(\d+).html)"><i class="fa fa-arrow-right"><\/i><\/a><\/li><\/ul><\/div><\/div>\s?<\/div>'
|
||||
elif item.extra == 'categorias':
|
||||
patron = '>(\d+)?<\/a><\/li><li class=""><a href="([^"]+-(\d+)-date.html)">»<\/a><\/li><\/ul><\/div><\/div>\s?<\/div>'
|
||||
if not scrapertools.find_single_match(data, patron):
|
||||
patron = '>(\d+)?<\/a><\/li><li class=""><a href="([^"]+page-(\d+)\/)">»<\/a><\/li><\/ul><\/div><\/div>\s?<\/div>'
|
||||
else:
|
||||
patron = '>(\d+)?<\/a><\/li><li class=""><a href="([^"]+&page=(\d+))">»<\/a><\/li><\/ul><\/div><\/div>\s?<\/div>'
|
||||
|
||||
#Si la página de la web es superior a la página del canal, se ponen los limites
|
||||
if item.extra == 'novedades': cnt_tot = matches_len
|
||||
elif item.extra == 'populares': cnt_tot = 25
|
||||
elif item.extra == 'categorias': cnt_tot = matches_len
|
||||
elif item.extra == 'series': cnt_tot = 25
|
||||
elif item.extra == 'search': cnt_tot = matches_len
|
||||
else: cnt_tot = 40
|
||||
|
||||
if last_page == 99999: #Si es el valor inicial, buscamos
|
||||
#Se busca el píe de página
|
||||
try:
|
||||
last_page, next_page_url, next_page = scrapertools.find_single_match(data, patron)
|
||||
last_page = int(last_page)
|
||||
curr_page = int(next_page)-1
|
||||
next_page_url = urlparse.urljoin(host, next_page_url)
|
||||
except: #Si no lo encuentra, lo ponemos a 1
|
||||
logger.error('ERROR 03: LISTADO: Al obtener la paginación: ' + patron)
|
||||
curr_page = 1
|
||||
last_page = 0
|
||||
if item.extra == 'series':
|
||||
next_page_url = item.url
|
||||
else:
|
||||
next_page_url = item.url + '?&page=1'
|
||||
|
||||
#Calculamos el num de páginas totales si la página web es más grande que la del canal
|
||||
last_page_foot = last_page
|
||||
if matches_len > cnt_tot:
|
||||
if last_page == 0:
|
||||
last_page = 1
|
||||
if last_page_foot == 0:
|
||||
last_page_foot = 1
|
||||
if item.extra == 'series':
|
||||
last_page_foot = last_page_foot * (100 / cnt_tot)
|
||||
else:
|
||||
last_page_foot = last_page_foot * (matches_len / cnt_tot)
|
||||
|
||||
#Calculamos la url de la siguiente página
|
||||
if last_page > 1 or last_page_foot > 1:
|
||||
curr_page_foot += 1 #Apunto ya a la página siguiente
|
||||
if item.extra == 'series':
|
||||
if cnt_title_tot + cnt_tot >= matches_len:
|
||||
curr_page += 1 #Apunto ya a la página siguiente
|
||||
cnt_title_tot = 0 - len(matches)
|
||||
if len(matches) < cnt_tot: #Si va a cargar otra página, no lo cuento
|
||||
curr_page_foot -= 1 #Vuelvo a la página actual
|
||||
next_page_url = re.sub(r'(?:-\d+)?.html', '-%s.html' % curr_page, next_page_url)
|
||||
item.url = next_page_url
|
||||
else:
|
||||
next_page_url = item.url
|
||||
elif item.extra == 'categorias':
|
||||
curr_page += 1 #Apunto ya a la página siguiente
|
||||
if scrapertools.find_single_match(next_page_url, '(?:-\d+)-date.html'):
|
||||
next_page_url = re.sub(r'(?:-\d+)-date.html', '-%s-date.html' % curr_page, next_page_url)
|
||||
else:
|
||||
next_page_url = re.sub(r'\/page-\d+', '/page-%s' % curr_page, next_page_url)
|
||||
elif item.extra == 'populares':
|
||||
next_page_url = item.url
|
||||
else:
|
||||
curr_page += 1 #Apunto ya a la página siguiente
|
||||
next_page_url = re.sub(r'page=\d+', 'page=%s' % curr_page, next_page_url)
|
||||
|
||||
#logger.debug('curr_page: ' + str(curr_page) + ' / last_page: ' + str(last_page) + ' / url: ' + next_page_url + ' / cnt_title: ' + str(cnt_title) + ' / cnt_title_tot: ' + str(cnt_title_tot) + ' / cnt_tot: ' + str(cnt_tot) + ' / matches_len: ' + str(matches_len))
|
||||
|
||||
#Empezamos el procesado de matches
|
||||
for scrapedduration, scrapedurl, scrapedtitle, scrapedthumb in matches:
|
||||
|
||||
title = scrapedtitle
|
||||
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
|
||||
if item_local.url_plus:
|
||||
del item_local.url_plus
|
||||
|
||||
title_subs = [] #creamos una lista para guardar info importante
|
||||
item_local.language = [] #iniciamos Lenguaje
|
||||
item_local.quality = "" #iniciamos calidad
|
||||
item_local.url = scrapedurl #guardamos la url
|
||||
item_local.thumbnail = scrapedthumb #guardamos el thumb
|
||||
if channel not in item_local.thumbnail: #si el thumb está encriptado, paamos
|
||||
item_local.thumbnail = get_thumb("channels_tvshow.png") #... y ponemos el de Series por defecto
|
||||
item_local.context = "['buscar_trailer']"
|
||||
|
||||
item_local.contentType = "movie" #por defecto, son películas
|
||||
item_local.action = "findvideos"
|
||||
|
||||
#Analizamos los formatos de series
|
||||
if '/top-series' in scrapedurl or item_local.extra == 'series':
|
||||
item_local.contentType = "tvshow"
|
||||
item_local.action = "episodios"
|
||||
|
||||
#Buscamos calidades adicionales
|
||||
if "3d" in title.lower() and not "3d" in item_local.quality.lower():
|
||||
if item_local.quality:
|
||||
item_local.quality += " 3D"
|
||||
else:
|
||||
item_local.quality = "3D"
|
||||
title = re.sub('3D', '', title, flags=re.IGNORECASE)
|
||||
title = title.replace('[]', '')
|
||||
if item_local.quality:
|
||||
item_local.quality += ' %s' % scrapertools.find_single_match(title, '\[(.*?)\]')
|
||||
else:
|
||||
item_local.quality = '%s' % scrapertools.find_single_match(title, '\[(.*?)\]')
|
||||
|
||||
#Detectamos idiomas
|
||||
if ("latino" in scrapedurl.lower() or "latino" in title.lower()) and "LAT" not in item_local.language:
|
||||
item_local.language += ['LAT']
|
||||
elif ('subtitulado' in scrapedurl.lower() or 'subtitulado' in title.lower() or 'vose' in title.lower()) and "VOSE" not in item_local.language:
|
||||
item_local.language += ['VOSE']
|
||||
elif ('version-original' in scrapedurl.lower() or 'version original' in title.lower()) and "VO" not in item_local.language:
|
||||
item_local.language += ['VO']
|
||||
|
||||
if item_local.language == []:
|
||||
item_local.language = ['CAST']
|
||||
|
||||
#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", "")
|
||||
|
||||
#Ponemos el año a '-'
|
||||
item_local.infoLabels["year"] = '-'
|
||||
|
||||
#Limpiamos el título de la basura innecesaria
|
||||
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)
|
||||
|
||||
title = title.replace("Dual", "").replace("dual", "").replace("Subtitulada", "").replace("subtitulada", "").replace("Subt", "").replace("subt", "").replace("(Proper)", "").replace("(proper)", "").replace("Proper", "").replace("proper", "").replace("#", "").replace("(Latino)", "").replace("Latino", "").replace("LATINO", "").replace("Spanish", "").replace("Trailer", "").replace("Audio", "")
|
||||
|
||||
#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()
|
||||
|
||||
#Añadimos la duración a la Calidad
|
||||
if scrapedduration:
|
||||
if item_local.quality:
|
||||
item_local.quality += ' [%s]' % scrapedduration
|
||||
else:
|
||||
item_local.quality = '[%s]' % scrapedduration
|
||||
|
||||
#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
|
||||
if cnt_title >= cnt_tot: #Si hemos llegado al límite de la página, pintamos
|
||||
cnt_title_tot += cnt_title
|
||||
break
|
||||
|
||||
#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 (curr_page <= last_page and item.extra not in ['populares']) or (cnt_title_tot < matches_len and 'populares' in item.extra):
|
||||
if last_page_foot > 1:
|
||||
title = '%s de %s' % (curr_page_foot-1, last_page_foot)
|
||||
else:
|
||||
title = '%s' % curr_page_foot-1
|
||||
|
||||
if item.extra not in ['populares', 'series']:
|
||||
cnt_title_tot = 0
|
||||
|
||||
itemlist.append(Item(channel=item.channel, action="listado", title=">> Página siguiente " + title, url=next_page_url, extra=item.extra, extra2=item.extra2, last_page=str(last_page), last_page_foot=str(last_page_foot), curr_page=str(curr_page), curr_page_foot=str(curr_page_foot), cnt_tot=str(cnt_tot), cnt_title_tot=str(cnt_title_tot)))
|
||||
|
||||
#logger.debug(str(cnt_tot) + ' / ' + str(cnt_title) + ' / ' + str(cnt_title_tot))
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def findvideos(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
itemlist_t = [] #Itemlist total de enlaces
|
||||
itemlist_f = [] #Itemlist de enlaces filtrados
|
||||
if not item.language:
|
||||
item.language = ['CAST'] #Castellano por defecto
|
||||
matches = []
|
||||
item.category = categoria
|
||||
|
||||
item.extra2 = 'xyz'
|
||||
del item.extra2
|
||||
|
||||
#logger.debug(item)
|
||||
|
||||
#Bajamos los datos de la página
|
||||
data = ''
|
||||
patron = '<link itemprop="embedUrl"\s*href="([^"]+)"\s*\/>(?:<iframe src="([^"]*)")?'
|
||||
try:
|
||||
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", 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
|
||||
|
||||
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)
|
||||
|
||||
#Si es un episodio suelto, se ofrece la posibilidad de ver la lista de Episodios completa
|
||||
if scrapertools.find_single_match(item.contentTitle, ':\s*(\d+)-\s*') and item.contentType != 'episode':
|
||||
serie = item.contentTitle
|
||||
url_serie = scrapertools.find_single_match(data, '<dt><span>Serie Documental<\/span><\/dt>\s*<dd><a href="([^"]+)"\s*>')
|
||||
serie = scrapertools.find_single_match(data, '<dt><span>Serie Documental<\/span><\/dt><dd><a href="[^"]+"\s*>(.*?)<')
|
||||
if url_serie:
|
||||
itemlist.append(item.clone(title="**-[COLOR yellow] Ver TODOS los episodios de la Serie [/COLOR]-**", action="episodios", contentType='tvshow', url=url_serie, extra="series", from_title=serie, wanted=serie, contentSerieName=serie, contentTitle=serie, quality="", language=[]))
|
||||
|
||||
#Recorremos la lista de servidores Directos, excluyendo YouTube para trailers
|
||||
for scrapedurl, scrapedplayer in matches:
|
||||
#Generamos una copia de Item para trabajar sobre ella
|
||||
item_local = item.clone()
|
||||
|
||||
#Buscamos la url del vídeo
|
||||
if 'cnubis.com' in scrapedplayer:
|
||||
videourl = conector_cnubis(scrapedurl, scrapedplayer)
|
||||
else:
|
||||
videourl = servertools.findvideos(scrapedurl)
|
||||
|
||||
#Ya tenemos un enlace, lo pintamos
|
||||
if len(videourl) > 0:
|
||||
server = videourl[0][0]
|
||||
enlace = videourl[0][1]
|
||||
mostrar_server = True
|
||||
if config.get_setting("hidepremium"): #Si no se aceptan servidore premium, se ignoran
|
||||
mostrar_server = servertools.is_server_enabled(server)
|
||||
|
||||
#Se comprueba si el vídeo existe
|
||||
if mostrar_server:
|
||||
item_local.alive = "??" #Se asume poe defecto que es link es dudoso
|
||||
item_local.alive = servertools.check_video_link(enlace, server, timeout=timeout)
|
||||
if '?' in item_local.alive:
|
||||
alive = '?' #No se ha podido comprobar el vídeo
|
||||
elif 'no' in item_local.alive.lower():
|
||||
continue #El enlace es malo
|
||||
else:
|
||||
alive = '' #El enlace está verificado
|
||||
|
||||
#Ahora pintamos el link del Servidor Directo
|
||||
item_local.url = enlace
|
||||
item_local.title = '[COLOR yellow][%s][/COLOR] [COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (alive, server.capitalize(), 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)
|
||||
item_local.quality = item_local.quality.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
|
||||
|
||||
item_local.action = "play" #Visualizar vídeo
|
||||
item_local.server = server.lower() #Servidor Directo
|
||||
|
||||
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("DIRECTO: " server + ' / ' + enlace + " / title: " + 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) #Lanzamos Autoplay
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def episodios(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
item.category = categoria
|
||||
|
||||
#logger.debug(item)
|
||||
|
||||
if item.from_title:
|
||||
item.title = item.from_title
|
||||
item.extra2 = 'xyz'
|
||||
del item.extra2
|
||||
next_page_url = item.url
|
||||
|
||||
inicio = time.time() # Controlaremos que el proceso no exceda de un tiempo razonable
|
||||
fin = inicio + 10 # Después de este tiempo pintamos (segundos)
|
||||
timeout_search = timeout # Timeout para descargas
|
||||
|
||||
item.quality = re.sub(r'\s?\[\d+:\d+\]', '', item.quality) #quitamos la duración de la serie
|
||||
|
||||
# Obtener la información actualizada de la Serie. TMDB es imprescindible para Videoteca
|
||||
if not item.infoLabels['tmdb_id']:
|
||||
tmdb.set_infoLabels(item, True)
|
||||
|
||||
#Bucle para recorrer todas las páginas
|
||||
epis = 1
|
||||
while next_page_url and fin > time.time():
|
||||
|
||||
# Descarga la página
|
||||
data = '' #Inserto en num de página en la url
|
||||
try:
|
||||
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)| ", "", httptools.downloadpage(next_page_url, timeout=timeout).data)
|
||||
data = unicode(data, "utf-8", errors="replace").encode("utf-8")
|
||||
except: #Algún error de proceso, salimos
|
||||
pass
|
||||
|
||||
if not data:
|
||||
logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea" + item.url)
|
||||
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: EPISODIOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log'))
|
||||
return itemlist
|
||||
|
||||
#Buscamos los episodios
|
||||
patron = '<span class="pm-label-duration">(.*?)<\/span>.*?<a href="([^"]+)" title="([^"]+)">.*?data-echo="([^"]+)"'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
if not matches: #error
|
||||
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
|
||||
if item.intervencion: #Sí ha sido clausurada judicialmente
|
||||
item, itemlist = generictools.post_tmdb_episodios(item, itemlist) #Llamamos al método para el pintado del error
|
||||
return itemlist #Salimos
|
||||
|
||||
logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / 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: " + patron)
|
||||
#logger.debug(matches)
|
||||
#logger.debug(data)
|
||||
|
||||
patron = '<li class=""><a href="([^"]+)">»<\/a><\/li><\/ul><\/div><\/div>\s*<\/div>'
|
||||
next_page_url = ''
|
||||
next_page_url = scrapertools.find_single_match(data, patron)
|
||||
if next_page_url:
|
||||
next_page_url = urlparse.urljoin(host, next_page_url)
|
||||
#logger.debug(next_page_url)
|
||||
|
||||
# Recorremos todos los episodios generando un Item local por cada uno en Itemlist
|
||||
for scrapedduration, scrapedurl, scrapedtitle, scrapedthumbnail in matches:
|
||||
item_local = item.clone()
|
||||
item_local.action = "findvideos"
|
||||
item_local.contentType = "episode"
|
||||
item_local.extra = "episodios"
|
||||
if item_local.library_playcounts:
|
||||
del item_local.library_playcounts
|
||||
if item_local.library_urls:
|
||||
del item_local.library_urls
|
||||
if item_local.path:
|
||||
del item_local.path
|
||||
if item_local.update_last:
|
||||
del item_local.update_last
|
||||
if item_local.update_next:
|
||||
del item_local.update_next
|
||||
if item_local.channel_host:
|
||||
del item_local.channel_host
|
||||
if item_local.active:
|
||||
del item_local.active
|
||||
if item_local.contentTitle:
|
||||
del item_local.infoLabels['title']
|
||||
if item_local.season_colapse:
|
||||
del item_local.season_colapse
|
||||
if item_local.unify:
|
||||
del item_local.unify
|
||||
if item_local.tmdb_stat:
|
||||
del item_local.tmdb_stat
|
||||
item_local.wanted = 'xyz'
|
||||
del item_local.wanted
|
||||
|
||||
item_local.title = ''
|
||||
item_local.context = "['buscar_trailer']"
|
||||
item_local.url = scrapedurl
|
||||
title = scrapedtitle
|
||||
item_local.language = []
|
||||
|
||||
#Buscamos calidades del episodio
|
||||
if 'hdtv' in scrapedtitle.lower() or 'hdtv' in scrapedurl:
|
||||
item_local.quality = 'HDTV'
|
||||
elif 'hd7' in scrapedtitle.lower() or 'hd7' in scrapedurl:
|
||||
item_local.quality = 'HD720p'
|
||||
elif 'hd1' in scrapedtitle.lower() or 'hd1' in scrapedurl:
|
||||
item_local.quality = 'HD1080p'
|
||||
|
||||
if not item_local.quality:
|
||||
item_local.quality = '[%s]' % scrapedduration
|
||||
|
||||
#Buscamos idiomas del episodio
|
||||
lang = scrapedtitle.strip()
|
||||
if ('v.o' in lang.lower() or 'v.o' in scrapedurl.lower()) and not 'VO' in item_local.language:
|
||||
item_local.language += ['VO']
|
||||
elif ('vose' in lang.lower() or 'v.o.s.e' in lang.lower() or 'vose' in scrapedurl.lower() or 'v.o.s.e' in scrapedurl.lower()) and not 'VOSE' in item_local.language:
|
||||
item_local.language += ['VOSE']
|
||||
elif ('latino' in lang.lower() or 'latino' in scrapedurl.lower()) and not 'LAT' in item_local.language:
|
||||
item_local.language += ['LAT']
|
||||
|
||||
if not item_local.language:
|
||||
item_local.language += ['CAST']
|
||||
|
||||
#Buscamos la Temporada y el Episodio
|
||||
item_local.contentSeason = 0
|
||||
item_local.contentEpisodeNumber = 0
|
||||
try:
|
||||
#Extraemos los episodios
|
||||
patron = ':\s*(\d+)-\s*'
|
||||
if scrapertools.find_single_match(title, patron):
|
||||
item_local.contentEpisodeNumber = int(scrapertools.find_single_match(title, patron))
|
||||
|
||||
#Extraemos la temporada
|
||||
patron = '\s*\(t|T(\d+)\):'
|
||||
if scrapertools.find_single_match(title, patron):
|
||||
item_local.contentSeason = int(scrapertools.find_single_match(title, patron))
|
||||
except:
|
||||
logger.error('ERROR al extraer Temporada/Episodio: ' + title)
|
||||
|
||||
if item_local.contentSeason == 0:
|
||||
if 'ii:' in title.lower(): item_local.contentSeason = 2
|
||||
elif 'iii:' in title.lower(): item_local.contentSeason = 3
|
||||
elif 'iv:' in title.lower(): item_local.contentSeason = 4
|
||||
else: item_local.contentSeason = 1
|
||||
|
||||
if item_local.contentEpisodeNumber == 0:
|
||||
item_local.contentEpisodeNumber = epis
|
||||
|
||||
#Formateamos el título compatible con la Videoteca
|
||||
item_local.title = '%sx%s -' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2))
|
||||
patron = ':(?:\s*\d+-)?\s*(.*?)$'
|
||||
item_local.infoLabels['episodio_titulo'] = scrapertools.find_single_match(title, patron)
|
||||
|
||||
itemlist.append(item_local.clone())
|
||||
epis += 1
|
||||
|
||||
#logger.debug(item_local)
|
||||
|
||||
if len(itemlist) > 1:
|
||||
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) #clasificamos
|
||||
|
||||
# Pasada por TMDB y clasificación de lista por temporada y episodio
|
||||
tmdb.set_infoLabels(itemlist, True)
|
||||
|
||||
#Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
|
||||
item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
|
||||
|
||||
#logger.debug(item)
|
||||
|
||||
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 conector_cnubis(scrapedurl, scrapedplayer):
|
||||
logger.info("url=%s, player=https:%s" % (scrapedurl, scrapedplayer))
|
||||
videourl = []
|
||||
|
||||
headers = { 'Referer': scrapedurl } #Referer con la url inical
|
||||
data = httptools.downloadpage('https:' + scrapedplayer, headers=headers).data #busca el video a partir del player + url inical
|
||||
|
||||
#url_file, url_type = scrapertools.find_single_match(data, 'file\s*:\s*"([^"]*)"\s*,\s*type\s*:\s*"([^"]*)')
|
||||
url_file = scrapertools.find_single_match(data, '<meta itemprop="contentURL" content="([^"]+)" />') #obtiene la url de vídeo
|
||||
url_type = 'directo'
|
||||
|
||||
#videourl.append([url_type, 'https:' + url_file])
|
||||
videourl.append([url_type, url_file]) #responde como si volviera de servertools.findvideos()
|
||||
|
||||
logger.info(videourl)
|
||||
return videourl
|
||||
|
||||
|
||||
def search(item, texto):
|
||||
logger.info()
|
||||
texto = texto.replace(" ", "+")
|
||||
|
||||
try:
|
||||
item.url = item.url + texto
|
||||
|
||||
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 == 'documentales':
|
||||
item.url = host + "newvideos.html"
|
||||
item.extra = "novedades"
|
||||
item.channel = channel
|
||||
item.category_new= 'newest'
|
||||
|
||||
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
|
||||
@@ -735,8 +735,8 @@ def listado_busqueda(item):
|
||||
|
||||
#logger.debug(item_local)
|
||||
|
||||
if not category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global
|
||||
return itemlist #Retornamos sin pasar por la fase de maquillaje para ahorra tiempo
|
||||
#if not category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global
|
||||
# return itemlist #Retornamos sin pasar por la fase de maquillaje para ahorra tiempo
|
||||
|
||||
#Llamamos a TMDB para que complete InfoLabels desde itemlist. Mejor desde itemlist porque envía las queries en paralelo
|
||||
tmdb.set_infoLabels(itemlist, __modo_grafico__)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"id": "miltorrents",
|
||||
"name": "Miltorrents",
|
||||
"active": false,
|
||||
"adult": false,
|
||||
"language": ["cast"],
|
||||
"thumbnail": "http://imgur.com/KZoska0.png",
|
||||
"banner": "miltorrents.png",
|
||||
"categories": [
|
||||
"torrent",
|
||||
"movie",
|
||||
"tvshow"
|
||||
],
|
||||
"settings": [
|
||||
{
|
||||
"id": "include_in_global_search",
|
||||
"type": "bool",
|
||||
"label": "Incluir en busqueda global",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "include_in_newest_torrent",
|
||||
"type": "bool",
|
||||
"label": "Incluir en Novedades - Torrent",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,447 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import unicodedata
|
||||
import urllib
|
||||
|
||||
from core import httptools
|
||||
from core import scrapertools
|
||||
from core import tmdb
|
||||
from core.item import Item
|
||||
from core.scrapertools import decodeHtmlentities as dhe
|
||||
from platformcode import config, logger
|
||||
from channelselector import get_thumb
|
||||
|
||||
|
||||
def mainlist(item):
|
||||
logger.info()
|
||||
check_bg = item.action
|
||||
|
||||
if str(check_bg) == "":
|
||||
check_bg = "bglobal"
|
||||
itemlist = []
|
||||
|
||||
itemlist.append(Item(channel=item.channel, title="[COLOR yellow][B]Películas[/B][/COLOR]", action="peliculas",
|
||||
url="http://www.miltorrents.com", thumbnail=get_thumb('movies', auto=True),
|
||||
fanart="http://imgur.com/y4nJyZh.jpg"))
|
||||
title = "[COLOR firebrick][B]Buscar[/B][/COLOR]" + " " + "[COLOR yellow][B]Peliculas[/B][/COLOR]"
|
||||
itemlist.append(Item(channel=item.channel, title=" " + title, action="search", url="",
|
||||
thumbnail=get_thumb('search', auto=True), fanart="http://imgur.com/gwjawWV.jpg",
|
||||
extra="peliculas" + "|" + check_bg))
|
||||
|
||||
itemlist.append(Item(channel=item.channel, title="[COLOR slategray][B]Series[/B][/COLOR]", action="peliculas",
|
||||
url="http://www.miltorrents.com/series", thumbnail=get_thumb('tvshows', auto=True),
|
||||
fanart="http://imgur.com/LwS32zX.jpg"))
|
||||
|
||||
title = "[COLOR firebrick][B]Buscar[/B][/COLOR]" + " " + "[COLOR slategray][B]Series[/B][/COLOR]"
|
||||
itemlist.append(Item(channel=item.channel, title=" " + title, action="search", url="",
|
||||
thumbnail=get_thumb('search', auto=True), fanart="http://imgur.com/ecPmzDj.jpg",
|
||||
extra="series" + "|" + check_bg))
|
||||
|
||||
return itemlist
|
||||
|
||||
def search(item, texto):
|
||||
logger.info()
|
||||
texto = texto.replace(" ", "+")
|
||||
if item.extra:
|
||||
if item.extra.split("|")[0] == "series":
|
||||
item.url = "http://www.miltorrents.com/series/?pTit=%s&pOrd=FE" % (texto)
|
||||
else:
|
||||
item.url = "http://www.miltorrents.com/?pTit=%s&pOrd=FE" % (texto)
|
||||
|
||||
item.extra = "search" + "|" + item.extra.split("|")[1] + "|" + texto
|
||||
|
||||
try:
|
||||
return peliculas(item)
|
||||
# Se captura la excepciÛn, para no interrumpir al buscador global si un canal falla
|
||||
except:
|
||||
import sys
|
||||
for line in sys.exc_info():
|
||||
logger.error("%s" % line)
|
||||
return []
|
||||
else:
|
||||
if item.contentType != "movie":
|
||||
item.url = "http://www.miltorrents.com/series/?pTit=%s&pOrd=FE" % (texto)
|
||||
check_sp = "tvshow"
|
||||
else:
|
||||
item.url = "http://www.miltorrents.com/?pTit=%s&pOrd=FE" % (texto)
|
||||
check_sp = "peliculas"
|
||||
item.extra = "search" + "|""bglobal" + "|" + texto + "|" + check_sp
|
||||
try:
|
||||
return peliculas(item)
|
||||
# Se captura la excepciÛn, para no interrumpir al buscador global si un canal falla
|
||||
except:
|
||||
import sys
|
||||
for line in sys.exc_info():
|
||||
logger.error("%s" % line)
|
||||
return []
|
||||
|
||||
def peliculas(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
data = httptools.downloadpage(item.url).data
|
||||
data = re.sub(r"Independance", "Independence", data)
|
||||
if "serie" in item.url:
|
||||
patron = '<div class="corner-episode">(.*?)<\/div>.*?<a href="([^"]+)".*?image:url\(\'([^"]+)\'.*?"tooltipbox">(.*?)<br'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
if item.extra.split("|")[0] == "search":
|
||||
check_bg = item.action
|
||||
for episodio, url, thumbnail, title in matches:
|
||||
title = title.decode('latin1').encode('utf8')
|
||||
title_fan = title.strip()
|
||||
trailer = title_fan + " " + "series" + "trailer"
|
||||
title_f = "[COLOR slategray][B]" + title.strip() + "[/B][/COLOR]" + " " + "[COLOR floralwhite][B]" + episodio + "[/B][/COLOR]"
|
||||
trailer = urllib.quote(trailer)
|
||||
extra = trailer + "|" + title_fan + "|" + " " + "|" + "pelicula"
|
||||
itemlist.append(Item(channel=item.channel, title=title_f, url=url, action="findvideos", thumbnail=thumbnail,
|
||||
fanart="http://imgur.com/NrZNOTN.jpg", extra=extra, folder=True, contentSerieName= title))
|
||||
else:
|
||||
patron = '<div class="moviesbox">(.*?)<a href="([^"]+)".*?image:url\(\'([^"]+)\'.*?<span class="tooltipbox">([^<]+)<i>\((\d\d\d\d)\)'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for p_rating, url, thumbnail, title, year in matches:
|
||||
|
||||
try:
|
||||
rating = scrapertools.get_match(p_rating, '<div class="moviesbox_rating">(.*?)<img')
|
||||
except:
|
||||
rating = "(Sin puntuacion)"
|
||||
title = title.decode('latin1').encode('utf8')
|
||||
title_fan = re.sub(r"\[.*?\]|\(.*?\)|\d&#.*?;\d+|-|Temporada.*?Completa| ;|(Sin puntuacion)", "", title)
|
||||
try:
|
||||
check_rating = scrapertools.get_match(rating, '(\d+).')
|
||||
if int(check_rating) >= 5 and int(check_rating) < 8:
|
||||
rating = "[COLOR springgreen][B]" + rating + "[/B][/COLOR]"
|
||||
elif int(check_rating) >= 8 and int(check_rating) < 10:
|
||||
rating = "[COLOR yellow][B]" + rating + "[/B][/COLOR]"
|
||||
elif int(check_rating) == 10:
|
||||
rating = "[COLOR orangered][B]" + rating + "[/B][/COLOR]"
|
||||
else:
|
||||
rating = "[COLOR crimson][B]" + rating + "[/B][/COLOR]"
|
||||
except:
|
||||
rating = "[COLOR crimson][B]" + rating + "[/B][/COLOR]"
|
||||
if "10." in rating:
|
||||
rating = re.sub(r'10\.\d+', '10', rating)
|
||||
title_f = "[COLOR gold][B]" + title + "[/B][/COLOR]" + " " + rating
|
||||
trailer = title_fan + " " + "trailer"
|
||||
trailer = urllib.quote(trailer)
|
||||
extra = trailer + "|" + title_fan + "|" + year + "|" + "pelicula"
|
||||
itemlist.append(Item(channel=item.channel, title=title_f, url=url, action="findvideos", thumbnail=thumbnail,
|
||||
fanart="http://imgur.com/Oi1mlFn.jpg", extra=extra, folder=True, contentTitle= title, infoLabels={'year':year}))
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
## Paginación
|
||||
patronvideos = '<div class="pagination">.*?<a href="#">.*?<\/a><\/span><a href="([^"]+)"'
|
||||
matches = re.compile(patronvideos, re.DOTALL).findall(data)
|
||||
if len(matches) > 0:
|
||||
url = matches[0]
|
||||
itemlist.append(Item(channel=item.channel, action="peliculas", title="[COLOR khaki]siguiente[/COLOR]", url=url,
|
||||
thumbnail="http://imgur.com/fJzoytz.png", fanart="http://imgur.com/3AqH1Zu.jpg",
|
||||
folder=True))
|
||||
return itemlist
|
||||
|
||||
|
||||
def capitulos(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
data = item.extra
|
||||
thumbnail = scrapertools.get_match(data, 'background-image:url\(\'([^"]+)\'')
|
||||
thumbnail = re.sub(r"w185", "original", thumbnail)
|
||||
patron = '<a href="([^"]+)".*?<i>(.*?)<\/i>'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for url, capitulo in matches:
|
||||
capitulo = re.sub(r"Cap.*?tulo", "", capitulo)
|
||||
capitulo = "[COLOR floralwhite][B]" + capitulo + "[/B][/COLOR]"
|
||||
if capitulo == item.extra.split("|")[4]:
|
||||
continue
|
||||
if not ".jpg" in item.extra.split("|")[2]:
|
||||
fanart = item.show.split("|")[0]
|
||||
else:
|
||||
fanart = item.extra.split("|")[2]
|
||||
itemlist.append(Item(channel=item.channel, title=capitulo, action="findvideos", url=url, thumbnail=thumbnail,
|
||||
extra="fv2" + "|" + item.extra.split("|")[3], show=item.show, category=item.category,
|
||||
fanart=fanart, folder=True))
|
||||
return itemlist
|
||||
|
||||
|
||||
def get_source(url):
|
||||
logger.info()
|
||||
data = httptools.downloadpage(url).data
|
||||
data = re.sub(r'\n|\r|\t| |<br>|\s{2,}', "", data)
|
||||
return data
|
||||
|
||||
|
||||
def findvideos(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
data = get_source(item.url)
|
||||
|
||||
if not "serie" in item.url:
|
||||
thumbnail = item.category
|
||||
else:
|
||||
thumbnail = ''
|
||||
|
||||
patronbloque_enlaces = '<div class="detail_content_subtitle">(.*?)<\/div>(.*?)<div class="torrent_sep">'
|
||||
matchesenlaces = re.compile(patronbloque_enlaces, re.DOTALL).findall(data)
|
||||
if len(matchesenlaces) == 0:
|
||||
thumb = ""
|
||||
check = ""
|
||||
itemlist.append(
|
||||
Item(channel=item.channel, title="[COLOR crimson][B]No hay Torrent[/B][/COLOR]", action="mainlist", url="",
|
||||
fanart=item.show.split("|")[0], thumbnail=thumbnail, folder=False))
|
||||
for calidad_bloque, bloque_enlaces in matchesenlaces:
|
||||
calidad_bloque = dhe(calidad_bloque)
|
||||
calidad_bloque = ''.join((c for c in unicodedata.normalize('NFD', unicode(calidad_bloque.decode('utf-8'))) if
|
||||
unicodedata.category(c) != 'Mn'))
|
||||
if "Alta" in calidad_bloque:
|
||||
title = 'Alta Definicion'
|
||||
title = " [COLOR yellow][B]" + title + "[/B][/COLOR]"
|
||||
elif "estandar" in calidad_bloque:
|
||||
title = 'Definicion Estandar'
|
||||
title = " [COLOR mediumaquamarine][B]" + title + "[/B][/COLOR]"
|
||||
else:
|
||||
title = 'Screener'
|
||||
title = " [COLOR slategray][B]" + title + "[/B][/COLOR]"
|
||||
itemlist.append(
|
||||
Item(channel=item.channel, title=title, action="mainlist", url="", fanart=item.show.split("|")[0],
|
||||
thumbnail=thumbnail, folder=False))
|
||||
if "serie" in item.url:
|
||||
thumb = scrapertools.get_match(data, '<div class="detail_background2".*?url\(([^"]+)\)')
|
||||
patron = '\:showDownload.*?(http.*?)\''
|
||||
matches = re.compile(patron, re.DOTALL).findall(bloque_enlaces)
|
||||
for url in matches:
|
||||
calidad = ""
|
||||
try:
|
||||
if not url.endswith(".torrent") and not "elitetorrent" in url:
|
||||
if url.endswith("fx"):
|
||||
url = httptools.downloadpage(url, follow_redirects=False)
|
||||
url = url.headers.get("location")
|
||||
if url.endswith(".fx"):
|
||||
url = httptools.downloadpage(url, follow_redirects=False)
|
||||
url = url.headers.get("location")
|
||||
|
||||
url = " http://estrenosli.org" + url
|
||||
|
||||
else:
|
||||
if not url.endswith(".mkv"):
|
||||
url = httptools.downloadpage(url, follow_redirects=False)
|
||||
url = url.headers.get("location")
|
||||
|
||||
torrents_path = config.get_videolibrary_path() + '/torrents'
|
||||
|
||||
if not os.path.exists(torrents_path):
|
||||
os.mkdir(torrents_path)
|
||||
try:
|
||||
urllib.URLopener.version = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 SE 2.X MetaSr 1.0'
|
||||
urllib.urlretrieve(url, torrents_path + "/temp.torrent")
|
||||
pepe = open(torrents_path + "/temp.torrent", "rb").read()
|
||||
except:
|
||||
pepe = ""
|
||||
if "used CloudFlare" in pepe:
|
||||
try:
|
||||
urllib.urlretrieve("http://anonymouse.org/cgi-bin/anon-www.cgi/" + url.strip(),
|
||||
torrents_path + "/temp.torrent")
|
||||
pepe = open(torrents_path + "/temp.torrent", "rb").read()
|
||||
except:
|
||||
pepe = ""
|
||||
torrent = decode(pepe)
|
||||
logger.debug('el torrent %s' % torrent)
|
||||
try:
|
||||
name = torrent["info"]["name"]
|
||||
sizet = torrent["info"]['length']
|
||||
sizet = convert_size(sizet)
|
||||
except:
|
||||
name = "no disponible"
|
||||
try:
|
||||
check_video = scrapertools.find_multiple_matches(str(torrent["info"]["files"]),
|
||||
"'length': (\d+)}")
|
||||
size = max([int(i) for i in check_video])
|
||||
for file in torrent["info"]["files"]:
|
||||
manolo = "%r - %d bytes" % ("/".join(file["path"]), file["length"])
|
||||
if str(size) in manolo:
|
||||
video = manolo
|
||||
size = convert_size(size)
|
||||
ext_v = re.sub(r"-.*? bytes|.*?\[.*?\].|'|.*?COM.|.*?\[.*?\]|\(.*?\)|.*?\.", "", video)
|
||||
try:
|
||||
os.remove(torrents_path + "/temp.torrent")
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
size = sizet
|
||||
ext_v = re.sub(r"-.*? bytes|.*?\[.*?\].|'|.*?COM.|.*?\.es.|.*?\[.*?\]|.*?\(.*?\)\.|.*?\.", "",
|
||||
name)
|
||||
try:
|
||||
os.remove(torrents_path + "/temp.torrent")
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
size = "en estos momentos..."
|
||||
ext_v = "no disponible"
|
||||
if "Alta" in calidad_bloque:
|
||||
title = "[COLOR navajowhite][B]" + calidad + "[/B][/COLOR]" + " " + "[COLOR peachpuff]( Video [/COLOR]" + "[COLOR peachpuff]" + ext_v + " -- " + size + " )[/COLOR]"
|
||||
elif "estandar" in calidad_bloque:
|
||||
title = "[COLOR lavender][B]" + calidad + "[/B][/COLOR]" + " " + "[COLOR azure]( Video [/COLOR]" + "[COLOR azure]" + ext_v + " -- " + size + " )[/COLOR]"
|
||||
else:
|
||||
title = "[COLOR gainsboro][B]" + calidad + "[/B][/COLOR]" + " " + "[COLOR silver]( Video [/COLOR]" + "[COLOR silver]" + ext_v + " -- " + size + " )[/COLOR]"
|
||||
if "rar" in ext_v:
|
||||
ext_v = ext_v + " -- No reproducible"
|
||||
size = ""
|
||||
item.title = re.sub(r"\[.*?\]", "", item.title)
|
||||
temp_epi = scrapertools.find_multiple_matches(item.title, '(\d+)x(\d+)')
|
||||
for temp, epi in temp_epi:
|
||||
check = temp + "x" + epi
|
||||
if item.extra.split("|")[0] == "fv2":
|
||||
extra = item.extra.split("|")[1] + "|" + " " + "|" + temp + "|" + epi
|
||||
else:
|
||||
extra = item.extra + "|" + temp + "|" + epi
|
||||
|
||||
itemlist.append(Item(channel=item.channel, title=title, action="play", url=url, server="torrent",
|
||||
thumbnail=thumbnail, extra=item.extra, show=item.show,
|
||||
fanart=item.show.split("|")[0], folder=False))
|
||||
else:
|
||||
patron = '<a href=.*?(http.*?)\'\).*?<i>(.*?)<i>(.*?)<\/i>'
|
||||
matches = re.compile(patron, re.DOTALL).findall(bloque_enlaces)
|
||||
for url, calidad, peso in matches:
|
||||
try:
|
||||
if not url.endswith(".torrent") and not "elitetorrent" in url:
|
||||
if url.endswith("fx"):
|
||||
url = httptools.downloadpage(url, follow_redirects=False)
|
||||
url = url.headers.get("location")
|
||||
if url.endswith(".fx"):
|
||||
url = httptools.downloadpage(url, follow_redirects=False)
|
||||
url = url.headers.get("location")
|
||||
url = " http://estrenosli.org" + url
|
||||
else:
|
||||
if not url.endswith(".mkv"):
|
||||
url = httptools.downloadpage(url, follow_redirects=False)
|
||||
url = url.headers.get("location")
|
||||
torrents_path = config.get_videolibrary_path() + '/torrents'
|
||||
if not os.path.exists(torrents_path):
|
||||
os.mkdir(torrents_path)
|
||||
urllib.URLopener.version = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 SE 2.X MetaSr 1.0'
|
||||
urllib.urlretrieve(url, torrents_path + "/temp.torrent")
|
||||
pepe = open(torrents_path + "/temp.torrent", "rb").read()
|
||||
if "used CloudFlare" in pepe:
|
||||
try:
|
||||
urllib.urlretrieve("http://anonymouse.org/cgi-bin/anon-www.cgi/" + url.strip(),
|
||||
torrents_path + "/temp.torrent")
|
||||
pepe = open(torrents_path + "/temp.torrent", "rb").read()
|
||||
except:
|
||||
pepe = ""
|
||||
torrent = decode(pepe)
|
||||
try:
|
||||
name = torrent["info"]["name"]
|
||||
except:
|
||||
name = "no disponible"
|
||||
try:
|
||||
check_video = scrapertools.find_multiple_matches(str(torrent["info"]["files"]),
|
||||
"'length': (\d+)}")
|
||||
size = max([int(i) for i in check_video])
|
||||
for file in torrent["info"]["files"]:
|
||||
manolo = "%r - %d bytes" % ("/".join(file["path"]), file["length"])
|
||||
if str(size) in manolo:
|
||||
video = manolo
|
||||
ext_v = re.sub(r"-.*? bytes|\.*?\[.*?\]\.|'|\.*?COM.|.*?\[.*?\]|\(.*?\)|.*?\.", "", video)
|
||||
try:
|
||||
os.remove(torrents_path + "/temp.torrent")
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
ext_v = re.sub(r"-.*? bytes|.*?\[.*?\].|'|.*?COM.|.*?\.es\.|.*?\[.*?\]|.*?\(.*?\)\.|.*?\.", "",
|
||||
name)
|
||||
try:
|
||||
os.remove(torrents_path + "/temp.torrent")
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
size = "en estos momentos..."
|
||||
ext_v = "no disponible"
|
||||
if "rar" in ext_v:
|
||||
ext_v = ext_v + " -- No reproducible"
|
||||
calidad = re.sub(r"</i>", "", calidad)
|
||||
if "Alta" in calidad_bloque:
|
||||
title = "[COLOR khaki][B]" + calidad + "[/B][/COLOR]" + "[COLOR darkkhaki][B]" + " - " + peso + "[/B][/COLOR]" + " " + "[COLOR lemonchiffon]( Video [/COLOR]" + "[COLOR lemonchiffon]" + ext_v + " )[/COLOR]"
|
||||
elif "estandar" in calidad_bloque:
|
||||
title = "[COLOR darkcyan][B]" + calidad + "[/B][/COLOR]" + "[COLOR cadetblue][B]" + " - " + peso + "[/B][/COLOR]" + " " + "[COLOR paleturquoise]( Video [/COLOR]" + "[COLOR paleturquoise]" + ext_v + " )[/COLOR]"
|
||||
else:
|
||||
title = "[COLOR dimgray][B]" + calidad + "[/B][/COLOR]" + "[COLOR gray][B]" + " - " + peso + "[/B][/COLOR]" + " " + "[COLOR lightslategray]( Video [/COLOR]" + "[COLOR lightslategray]" + ext_v + " )[/COLOR]"
|
||||
itemlist.append(Item(channel=item.channel, title=title, action="play", url=url, server="torrent",
|
||||
thumbnail=thumbnail, extra=item.extra, show=item.show,
|
||||
fanart=item.show.split("|")[0], folder=False))
|
||||
if "serie" in item.url and item.extra.split("|")[0] != "fv2":
|
||||
title_info = 'Temporadas'
|
||||
title_info = "[COLOR springgreen][B]" + title_info + "[/B][/COLOR]"
|
||||
itemlist.append(Item(channel=item.channel, title=" " + title_info,
|
||||
action="mainlist", url="", fanart=item.show.split("|")[0], thumbnail=thumbnail,
|
||||
folder=False))
|
||||
data = re.sub(r"\n|\r|\t|\s{2}| ", "", data)
|
||||
patron = 'class="contactlinkh">(.*?)<\/a><\/div>(.*?)</div></div></div>'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for temporadas, bloque_capitulos in matches:
|
||||
thumbnail = scrapertools.get_match(bloque_capitulos, 'background-image:url\(\'([^"]+)\'')
|
||||
thumbnail = re.sub(r"w185", "original", thumbnail)
|
||||
itemlist.append(Item(channel=item.channel, title="[COLOR chartreuse][B]" + temporadas + "[/B][/COLOR]",
|
||||
action="capitulos", url=item.url, thumbnail=thumbnail,
|
||||
extra="fv2" + "|" + bloque_capitulos + "|" + thumb + "|" + item.extra + "|" + check,
|
||||
show=item.show, fanart=item.show.split("|")[0], category=item.category, folder=True))
|
||||
return itemlist
|
||||
|
||||
|
||||
def decode(text):
|
||||
try:
|
||||
src = tokenize(text)
|
||||
data = decode_item(src.next, src.next())
|
||||
for token in src: # look for more tokens
|
||||
raise SyntaxError("trailing junk")
|
||||
except (AttributeError, ValueError, StopIteration):
|
||||
try:
|
||||
data = data
|
||||
except:
|
||||
data = src
|
||||
return data
|
||||
|
||||
|
||||
def tokenize(text, match=re.compile("([idel])|(\d+):|(-?\d+)").match):
|
||||
i = 0
|
||||
while i < len(text):
|
||||
m = match(text, i)
|
||||
s = m.group(m.lastindex)
|
||||
i = m.end()
|
||||
if m.lastindex == 2:
|
||||
yield "s"
|
||||
yield text[i:i + int(s)]
|
||||
i = i + int(s)
|
||||
else:
|
||||
yield s
|
||||
|
||||
|
||||
def decode_item(next, token):
|
||||
if token == "i":
|
||||
# integer: "i" value "e"
|
||||
data = int(next())
|
||||
if next() != "e":
|
||||
raise ValueError
|
||||
elif token == "s":
|
||||
# string: "s" value (virtual tokens)
|
||||
data = next()
|
||||
elif token == "l" or token == "d":
|
||||
# container: "l" (or "d") values "e"
|
||||
data = []
|
||||
tok = next()
|
||||
while tok != "e":
|
||||
data.append(decode_item(next, tok))
|
||||
tok = next()
|
||||
if token == "d":
|
||||
data = dict(zip(data[0::2], data[1::2]))
|
||||
else:
|
||||
raise ValueError
|
||||
return data
|
||||
|
||||
|
||||
def convert_size(size):
|
||||
if (size == 0):
|
||||
return '0B'
|
||||
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
|
||||
i = int(math.floor(math.log(size, 1024)))
|
||||
p = math.pow(1024, i)
|
||||
s = round(size / p, 2)
|
||||
return '%s %s' % (s, size_name[i])
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"id": "tiotorrent",
|
||||
"name": "TioTorrent",
|
||||
"active": false,
|
||||
"adult": false,
|
||||
"language": ["cast","lat"],
|
||||
"thumbnail": "https://s1.postimg.cc/29eths1fi7/tiotorrent.png",
|
||||
"banner": "https://s1.postimg.cc/9gkc73lxb3/tiotorrent-banner.png",
|
||||
"version": 1,
|
||||
"categories": [
|
||||
"movie",
|
||||
"tvshow",
|
||||
"torrent"
|
||||
],
|
||||
"settings": [
|
||||
{
|
||||
"id": "include_in_newest_peliculas",
|
||||
"type": "bool",
|
||||
"label": "Incluir en Novedades - Peliculas",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "include_in_newest_torrent",
|
||||
"type": "bool",
|
||||
"label": "Incluir en Novedades - Torrent",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,343 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- Channel TioTorrent -*-
|
||||
# -*- Created for Alfa-addon -*-
|
||||
# -*- By the Alfa Develop Group -*-
|
||||
|
||||
import re
|
||||
from channelselector import get_thumb
|
||||
from platformcode import logger
|
||||
from platformcode import config
|
||||
from core import scrapertools
|
||||
from core.item import Item
|
||||
from core import servertools
|
||||
from core import httptools
|
||||
from core import tmdb
|
||||
|
||||
host = 'http://www.tiotorrent.com/'
|
||||
|
||||
def mainlist(item):
|
||||
logger.info()
|
||||
|
||||
itemlist = []
|
||||
|
||||
itemlist.append(item.clone(title="Peliculas",
|
||||
action="movie_list",
|
||||
thumbnail=get_thumb("channels_movie.png")
|
||||
))
|
||||
|
||||
itemlist.append(item.clone(title="Series",
|
||||
action="series_list",
|
||||
thumbnail=get_thumb("channels_tvshow.png")
|
||||
))
|
||||
return itemlist
|
||||
|
||||
|
||||
def movie_list(item):
|
||||
logger.info()
|
||||
|
||||
itemlist = []
|
||||
|
||||
itemlist.append(item.clone(title="Estrenos",
|
||||
action="lista",
|
||||
url=host + 'estrenos-de-cine',
|
||||
extra='movie'
|
||||
))
|
||||
|
||||
itemlist.append(item.clone(title="Todas",
|
||||
action="lista",
|
||||
url=host + 'peliculas',
|
||||
extra='movie'
|
||||
))
|
||||
|
||||
itemlist.append(item.clone(title="Buscar",
|
||||
action="search",
|
||||
url=host + '/peliculas/?pTit=',
|
||||
thumbnail=get_thumb("search.png"),
|
||||
extra='movie'
|
||||
))
|
||||
return itemlist
|
||||
|
||||
|
||||
def series_list(item):
|
||||
logger.info()
|
||||
|
||||
itemlist = []
|
||||
|
||||
itemlist.append(item.clone(title="Todas",
|
||||
action="lista",
|
||||
url=host + 'series',
|
||||
extra='serie'
|
||||
))
|
||||
|
||||
itemlist.append(item.clone(title="Buscar",
|
||||
action="search",
|
||||
url=host + '/series/?pTit=',
|
||||
thumbnail=get_thumb("search.png"),
|
||||
extra='serie'
|
||||
))
|
||||
return itemlist
|
||||
|
||||
|
||||
def get_source(url):
|
||||
logger.info()
|
||||
data = httptools.downloadpage(url).data
|
||||
data = re.sub(r'"|\n|\r|\t| |<br>|\s{2,}', "", data)
|
||||
return data
|
||||
|
||||
def lista (item):
|
||||
logger.info ()
|
||||
itemlist = []
|
||||
data = get_source(item.url)
|
||||
if item.extra == 'movie':
|
||||
patron = "<div class=moviesbox.*?><a href=(.*?)>.*?image:url\('(.*?)'\)>.*?<b>.*?>(.*?)<"
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for scrapedurl, scrapedthumbnail, scrapedtitle in matches:
|
||||
url = scrapedurl
|
||||
thumbnail = scrapedthumbnail
|
||||
contentTitle = scrapedtitle.decode('latin1').encode('utf8')
|
||||
title = contentTitle
|
||||
filtro_thumb = scrapedthumbnail.replace("https://image.tmdb.org/t/p/w396", "")
|
||||
filtro_list = {"poster_path": filtro_thumb}
|
||||
filtro_list = filtro_list.items()
|
||||
|
||||
itemlist.append(item.clone(action='findvideos',
|
||||
title=title, url=url,
|
||||
thumbnail=thumbnail,
|
||||
contentTitle=contentTitle,
|
||||
infoLabels={'filtro': filtro_list},
|
||||
extra=item.extra
|
||||
))
|
||||
else:
|
||||
patron = "<div class=moviesbox.*?>.*?episode>(.*?)x(.*?)<.*?href=(.*?)>.*?image:url\('(.*?)'.*?href.*?>(.*?)<"
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for season, episode, scrapedurl, scrapedthumbnail, scrapedtitle in matches:
|
||||
url = scrapedurl
|
||||
thumbnail = scrapedthumbnail
|
||||
contentSerieName = scrapedtitle
|
||||
title = '%s' % contentSerieName
|
||||
filtro_thumb = scrapedthumbnail.replace("https://image.tmdb.org/t/p/w396", "")
|
||||
filtro_list = {"poster_path": filtro_thumb}
|
||||
filtro_list = filtro_list.items()
|
||||
contentSeason=season
|
||||
contentEpisode=episode
|
||||
itemlist.append(item.clone(action='seasons',
|
||||
title=title,
|
||||
url=url,
|
||||
thumbnail=thumbnail,
|
||||
contentSerieName=contentSerieName,
|
||||
contentSeason=contentSeason,
|
||||
contentEpisode=contentEpisode,
|
||||
infoLabels={'filtro': filtro_list},
|
||||
extra=item.extra
|
||||
))
|
||||
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb =True)
|
||||
#Paginacion
|
||||
|
||||
if itemlist !=[]:
|
||||
actual_page_url = item.url
|
||||
next_page = scrapertools.find_single_match(data,'<span class=pagination_next><a href=(.*?)>')
|
||||
import inspect
|
||||
if next_page !='':
|
||||
itemlist.append(item.clone(action = "lista",
|
||||
title = 'Siguiente >>>',
|
||||
url = next_page,
|
||||
thumbnail='https://s32.postimg.cc/4zppxf5j9/siguiente.png'
|
||||
))
|
||||
return itemlist
|
||||
|
||||
|
||||
def search(item, texto):
|
||||
logger.info()
|
||||
texto = texto.replace(" ", "+")
|
||||
item.url = item.url + texto
|
||||
|
||||
if texto != '':
|
||||
return lista(item)
|
||||
else:
|
||||
return []
|
||||
|
||||
|
||||
def seasons(item):
|
||||
logger.info()
|
||||
itemlist=[]
|
||||
infoLabels = item.infoLabels
|
||||
data=get_source(item.url)
|
||||
patron ='href=javascript:showSeasson\(.*?\); id=.*?>Temporada (.*?)<\/a>'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
|
||||
for season in matches:
|
||||
title='Temporada %s' % season
|
||||
infoLabels['season'] = season
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
title= title,
|
||||
url=item.url,
|
||||
action='episodesxseasons',
|
||||
contentSeasonNumber=season,
|
||||
contentSerieName=item.contentSerieName,
|
||||
infoLabels=infoLabels
|
||||
))
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
itemlist = itemlist[::-1]
|
||||
if config.get_videolibrary_support() and len(itemlist) > 0:
|
||||
itemlist.append(
|
||||
Item(channel=item.channel, title='[COLOR yellow]Añadir esta serie a la videoteca[/COLOR]', url=item.url,
|
||||
action="add_serie_to_library", extra="all_episodes", contentSerieName=item.contentSerieName))
|
||||
|
||||
return itemlist
|
||||
|
||||
def all_episodes(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
templist = seasons(item)
|
||||
for tempitem in templist:
|
||||
itemlist += episodesxseasons(tempitem)
|
||||
|
||||
return itemlist
|
||||
|
||||
def episodesxseasons(item):
|
||||
logger.info()
|
||||
|
||||
itemlist=[]
|
||||
|
||||
data=get_source(item.url)
|
||||
patron = "<div class=corner-episode>%sx(.\d+)<\/div><a href=(.*?)>.*?" % item.contentSeasonNumber
|
||||
patron += "image:url\('(.*?)'.*?href.*?>(%s)<" % item.contentSerieName
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
infoLabels=item.infoLabels
|
||||
for episode, scrapedurl, scrapedthumbnail, scrapedtitle in matches:
|
||||
contentEpisodeNumber=episode
|
||||
season = item.contentSeasonNumber
|
||||
url=scrapedurl
|
||||
thumbnail=scrapedthumbnail
|
||||
infoLabels['episode']=episode
|
||||
title = '%sx%s - %s' % (season, episode, item.contentSerieName)
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
action='findvideos',
|
||||
title=title,
|
||||
url=url,
|
||||
thumbnail=thumbnail,
|
||||
contentSerieName=item.contentSerieName,
|
||||
contentEpisodeNumber=contentEpisodeNumber,
|
||||
infoLabels=infoLabels
|
||||
))
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
|
||||
return itemlist[::-1]
|
||||
|
||||
|
||||
# def findvideos(item):
|
||||
# logger.info()
|
||||
# itemlist=[]
|
||||
# data = get_source(item.url)
|
||||
# patron = "<a class=dload.*? target=_blank>.*?<\/a><i>(.*?)<\/i>.*?<a href=.*?showDownload\((.*?)\);"
|
||||
# matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
#
|
||||
# for quality, extra_info in matches:
|
||||
# extra_info= extra_info.replace("'",'')
|
||||
# extra_info= extra_info.split(',')
|
||||
# title = '%s [%s]' % (item.contentTitle, quality)
|
||||
# url = extra_info[1]
|
||||
# if item.extra == 'movie':
|
||||
# url = extra_info[1]
|
||||
# else:
|
||||
# url = extra_info[2]
|
||||
# server = 'torrent'
|
||||
# itemlist.append(Item(channel=item.channel,
|
||||
# title=title,
|
||||
# contentTitle= item.title,
|
||||
# url=url,
|
||||
# action='play',
|
||||
# quality=quality,
|
||||
# server=server,
|
||||
# thumbnail = item.infoLabels['thumbnail'],
|
||||
# infoLabels=item.infoLabels
|
||||
# ))
|
||||
#
|
||||
# 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
|
||||
# ))
|
||||
#
|
||||
# return itemlist
|
||||
|
||||
|
||||
def findvideos(item):
|
||||
logger.info()
|
||||
itemlist=[]
|
||||
data = get_source(item.url)
|
||||
patron = "showDownload\(([^\)]+)\);.*?alt=.*?torrent (.*?) "
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
|
||||
for extra_info, quality in matches:
|
||||
extra_info= extra_info.replace(",'",'|')
|
||||
extra_info= extra_info.split('|')
|
||||
title = '%s [%s]' % ('Torrent', quality.strip())
|
||||
if item.extra == 'movie':
|
||||
url = extra_info[2].strip("'")
|
||||
else:
|
||||
url = extra_info[3].strip("'")
|
||||
server = 'torrent'
|
||||
|
||||
if not '.torrent' in url:
|
||||
if 'tvsinpagar' in url:
|
||||
url = url.replace('http://','http://www.')
|
||||
try:
|
||||
from_web = httptools.downloadpage(url, follow_redirects=False)
|
||||
url = from_web.headers['location']
|
||||
except:
|
||||
pass
|
||||
|
||||
if '.torrent' in url:
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
title=title,
|
||||
contentTitle= item.title,
|
||||
url=url,
|
||||
action='play',
|
||||
quality=quality,
|
||||
server=server,
|
||||
thumbnail = item.infoLabels['thumbnail'],
|
||||
infoLabels=item.infoLabels
|
||||
))
|
||||
|
||||
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
|
||||
))
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def newest(category):
|
||||
logger.info()
|
||||
item = Item()
|
||||
try:
|
||||
if category in ['peliculas', 'torrent']:
|
||||
item.url = host + 'estrenos-de-cine'
|
||||
item.extra='movie'
|
||||
itemlist = lista(item)
|
||||
if itemlist[-1].title == 'Siguiente >>>':
|
||||
itemlist.pop()
|
||||
if category == 'torrent':
|
||||
|
||||
item.url = host+'series'
|
||||
item.extra = 'serie'
|
||||
itemlist.extend(lista(item))
|
||||
|
||||
if itemlist[-1].title == 'Siguiente >>>':
|
||||
itemlist.pop()
|
||||
except:
|
||||
import sys
|
||||
for line in sys.exc_info():
|
||||
logger.error("%s" % line)
|
||||
return []
|
||||
|
||||
return itemlist
|
||||
Reference in New Issue
Block a user