Merge pull request #482 from lopezvg/master
Cacheo de enlace: nuevos canales y mejoras
This commit is contained in:
@@ -43,6 +43,28 @@
|
||||
"VOSE"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "emergency_urls",
|
||||
"type": "list",
|
||||
"label": "Se quieren guardar Enlaces de Emergencia por si se cae la Web?",
|
||||
"default": 1,
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": [
|
||||
"No",
|
||||
"Guardar",
|
||||
"Borrar",
|
||||
"Actualizar"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "emergency_urls_torrents",
|
||||
"type": "bool",
|
||||
"label": "Se quieren guardar Torrents de Emergencia por si se cae la Web?",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": "!eq(-1,'No')"
|
||||
},
|
||||
{
|
||||
"id": "timeout_downloadpage",
|
||||
"type": "list",
|
||||
|
||||
@@ -514,10 +514,10 @@ def listado(item):
|
||||
def findvideos(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
itemlist_t = [] #Itemlist total de enlaces
|
||||
itemlist_f = [] #Itemlist de enlaces filtrados
|
||||
itemlist_t = [] #Itemlist total de enlaces
|
||||
itemlist_f = [] #Itemlist de enlaces filtrados
|
||||
if not item.language:
|
||||
item.language = ['CAST'] #Castellano por defecto
|
||||
item.language = ['CAST'] #Castellano por defecto
|
||||
matches = []
|
||||
item.category = categoria
|
||||
|
||||
@@ -526,7 +526,7 @@ def findvideos(item):
|
||||
#Bajamos los datos de la página
|
||||
data = ''
|
||||
patron = '<a onclick="eventDownloadTorrent\(.*?\)".?class="linktorrent" href="([^"]+)">'
|
||||
if item.contentType == 'movie':
|
||||
if item.contentType == 'movie': #Es una peli
|
||||
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")
|
||||
@@ -536,43 +536,73 @@ def findvideos(item):
|
||||
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 item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia?
|
||||
matches = item.emergency_urls[0] #Restauramos matches
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
else:
|
||||
if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca...
|
||||
return item #Devolvemos el Item de la llamada
|
||||
else:
|
||||
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 item.armagedon: #Si es un proceso normal, seguimos
|
||||
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
|
||||
else:
|
||||
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
|
||||
if item.intervencion: #Sí ha sido clausurada judicialmente
|
||||
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error
|
||||
else:
|
||||
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'))
|
||||
if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia?
|
||||
matches = item.emergency_urls[0] #Restauramos matches
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
else:
|
||||
if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca...
|
||||
return item #Devolvemos el Item de la llamada
|
||||
else:
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
|
||||
else: #Es un episodio
|
||||
matches = [item.url]
|
||||
|
||||
#logger.debug("PATRON: " + patron)
|
||||
#logger.debug(matches)
|
||||
#logger.debug(data)
|
||||
|
||||
#Si es un lookup para cargar las urls de emergencia en la Videoteca...
|
||||
if item.videolibray_emergency_urls:
|
||||
item.emergency_urls = []
|
||||
item.emergency_urls.append(matches) #Salvamnos matches...
|
||||
return item #... y nos vamos
|
||||
|
||||
#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)
|
||||
|
||||
#Ahora tratamos los enlaces .torrent
|
||||
for scrapedurl in matches: #leemos los torrents con la diferentes calidades
|
||||
for scrapedurl in matches: #leemos los torrents con la diferentes calidades
|
||||
#Generamos una copia de Item para trabajar sobre ella
|
||||
item_local = item.clone()
|
||||
|
||||
#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 not size and not item.armagedon:
|
||||
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
|
||||
item_local.quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final de la calidad
|
||||
|
||||
#Ahora pintamos el link del Torrent
|
||||
item_local.url = scrapedurl
|
||||
if host not in item_local.url and host.replace('https', 'http') not in item_local.url :
|
||||
if host not in item_local.url and host.replace('https', 'http') not in item_local.url and not item.armagedon:
|
||||
item_local.url = host + item_local.url
|
||||
if item_local.url and not item.armagedon:
|
||||
item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la url del .Torrent ALTERNATIVA
|
||||
if item.armagedon: #Si es catastrófico, lo marcamos
|
||||
item_local.quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % item_local.quality
|
||||
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
|
||||
@@ -583,14 +613,14 @@ def findvideos(item):
|
||||
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.alive = "??" #Calidad del link sin verificar
|
||||
item_local.action = "play" #Visualizar vídeo
|
||||
item_local.server = "torrent" #Seridor Torrent
|
||||
item_local.alive = "??" #Calidad del link sin verificar
|
||||
item_local.action = "play" #Visualizar vídeo
|
||||
item_local.server = "torrent" #Seridor Torrent
|
||||
|
||||
itemlist_t.append(item_local.clone()) #Pintar pantalla, si no se filtran idiomas
|
||||
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
|
||||
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)
|
||||
|
||||
@@ -46,6 +46,28 @@
|
||||
"VOSE"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "emergency_urls",
|
||||
"type": "list",
|
||||
"label": "Se quieren guardar Enlaces de Emergencia por si se cae la Web?",
|
||||
"default": 1,
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": [
|
||||
"No",
|
||||
"Guardar",
|
||||
"Borrar",
|
||||
"Actualizar"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "emergency_urls_torrents",
|
||||
"type": "bool",
|
||||
"label": "Se quieren guardar Torrents de Emergencia por si se cae la Web?",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": "!eq(-1,'No')"
|
||||
},
|
||||
{
|
||||
"id": "include_in_newest_peliculas",
|
||||
"type": "bool",
|
||||
|
||||
@@ -309,10 +309,10 @@ def listado(item):
|
||||
def findvideos(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
itemlist_t = [] #Itemlist total de enlaces
|
||||
itemlist_f = [] #Itemlist de enlaces filtrados
|
||||
itemlist_t = [] #Itemlist total de enlaces
|
||||
itemlist_f = [] #Itemlist de enlaces filtrados
|
||||
if not item.language:
|
||||
item.language = ['CAST'] #Castellano por defecto
|
||||
item.language = ['CAST'] #Castellano por defecto
|
||||
|
||||
#Bajamos los datos de la página
|
||||
data = ''
|
||||
@@ -324,8 +324,35 @@ def findvideos(item):
|
||||
if not data:
|
||||
logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data)
|
||||
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log'))
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia?
|
||||
link_torrent = item.emergency_urls[0][0] #Guardamos la url del .Torrent
|
||||
link_magnet = item.emergency_urls[1][0] #Guardamos la url del .Magnet
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
else:
|
||||
if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca...
|
||||
return item #Devolvemos el Item de la llamada
|
||||
else:
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
#data = unicode(data, "utf-8", errors="replace")
|
||||
|
||||
patron_t = '<div class="enlace_descarga".*?<a href="(.*?\.torrent)"'
|
||||
patron_m = '<div class="enlace_descarga".*?<a href="(magnet:?.*?)"'
|
||||
if not item.armagedon: #Si es un proceso normal, seguimos
|
||||
link_torrent = scrapertools.find_single_match(data, patron_t)
|
||||
link_torrent = urlparse.urljoin(item.url, link_torrent)
|
||||
link_torrent = link_torrent.replace(" ", "%20") #sustituimos espacios por %20, por si acaso
|
||||
#logger.info("link Torrent: " + link_torrent)
|
||||
|
||||
link_magnet = scrapertools.find_single_match(data, patron_m)
|
||||
link_magnet = urlparse.urljoin(item.url, link_magnet)
|
||||
#logger.info("link Magnet: " + link_magnet)
|
||||
|
||||
#Si es un lookup para cargar las urls de emergencia en la Videoteca...
|
||||
if (link_torrent or link_magnet) and item.videolibray_emergency_urls:
|
||||
item.emergency_urls = []
|
||||
item.emergency_urls.append([link_torrent]) #Salvamos el enlace de .torrent
|
||||
item.emergency_urls.append([link_magnet]) #Salvamos el enlace de .magnet
|
||||
return item #... y nos vamos
|
||||
|
||||
#Añadimos el tamaño para todos
|
||||
size = scrapertools.find_single_match(item.quality, '\s\[(\d+,?\d*?\s\w\s?[b|B]s)\]')
|
||||
@@ -333,32 +360,28 @@ def findvideos(item):
|
||||
item.title = re.sub('\s\[\d+,?\d*?\s\w[b|B]s\]', '', item.title) #Quitamos size de título, si lo traía
|
||||
item.title = '%s [%s]' % (item.title, size) #Agregamos size al final del título
|
||||
item.quality = re.sub('\s\[\d+,?\d*?\s\w\s?[b|B]s\]', '', item.quality) #Quitamos size de calidad, si lo traía
|
||||
|
||||
patron_t = '<div class="enlace_descarga".*?<a href="(.*?\.torrent)"'
|
||||
link_torrent = scrapertools.find_single_match(data, patron_t)
|
||||
link_torrent = urlparse.urljoin(item.url, link_torrent)
|
||||
link_torrent = link_torrent.replace(" ", "%20") #sustituimos espacios por %20, por si acaso
|
||||
#logger.info("link Torrent: " + link_torrent)
|
||||
|
||||
patron_m = '<div class="enlace_descarga".*?<a href="(magnet:?.*?)"'
|
||||
link_magnet = scrapertools.find_single_match(data, patron_m)
|
||||
link_magnet = urlparse.urljoin(item.url, link_magnet)
|
||||
#logger.info("link Magnet: " + link_magnet)
|
||||
|
||||
if not link_torrent and not link_magnet: #error
|
||||
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
|
||||
if item.intervencion: #Sí ha sido clausurada judicialmente
|
||||
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error
|
||||
return itemlist #Salimos
|
||||
|
||||
logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron_t + " / " + patron_m + " / DATA: " + data)
|
||||
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log'))
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
else:
|
||||
logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron_t + " / " + patron_m + " / DATA: " + data)
|
||||
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log'))
|
||||
if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia?
|
||||
link_torrent = item.emergency_urls[0][0] #Guardamos la url del .Torrent
|
||||
link_magnet = item.emergency_urls[1][0] #Guardamos la url del .Magnet
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
else:
|
||||
if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca...
|
||||
return item #Devolvemos el Item de la llamada
|
||||
else:
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
|
||||
#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)
|
||||
|
||||
if not size:
|
||||
if not size and not item.armagedon:
|
||||
size = generictools.get_torrent_size(link_torrent) #Buscamos el tamaño en el .torrent
|
||||
if size:
|
||||
item.quality = '%s [%s]' % (item.quality, size) #Agregamos size al final de calidad
|
||||
@@ -372,7 +395,12 @@ def findvideos(item):
|
||||
if item_local.quality:
|
||||
item_local.quality += " "
|
||||
item_local.quality += "[Torrent]"
|
||||
if item.armagedon: #Si es catastrófico, lo marcamos
|
||||
item_local.quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % item_local.quality
|
||||
item_local.url = link_torrent
|
||||
if item_local.url and not item.armagedon:
|
||||
item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la url del .Torrent ALTERNATIVA
|
||||
|
||||
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 de Torrent
|
||||
|
||||
#Preparamos título y calidad, quitamos etiquetas vacías
|
||||
@@ -411,6 +439,8 @@ def findvideos(item):
|
||||
if item_local.quality:
|
||||
item_local.quality += " "
|
||||
item_local.quality = item_local.quality.replace("[Torrent]", "") + "[Magnet]"
|
||||
if item.armagedon: #Si es catastrófico, lo marcamos
|
||||
item_local.quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % item_local.quality
|
||||
item_local.url = link_magnet
|
||||
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 de Magnet
|
||||
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title) #Quitamos etiquetas vacías
|
||||
|
||||
@@ -46,6 +46,28 @@
|
||||
"VOSE"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "emergency_urls",
|
||||
"type": "list",
|
||||
"label": "Se quieren guardar Enlaces de Emergencia por si se cae la Web?",
|
||||
"default": 1,
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": [
|
||||
"No",
|
||||
"Guardar",
|
||||
"Borrar",
|
||||
"Actualizar"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "emergency_urls_torrents",
|
||||
"type": "bool",
|
||||
"label": "Se quieren guardar Torrents de Emergencia por si se cae la Web?",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": "!eq(-1,'No')"
|
||||
},
|
||||
{
|
||||
"id": "seleccionar_serie_temporada",
|
||||
"type": "list",
|
||||
|
||||
@@ -427,41 +427,66 @@ def findvideos(item):
|
||||
|
||||
#logger.debug(item)
|
||||
|
||||
timeout_find = timeout
|
||||
if item.videolibray_emergency_urls: #Si se están cacheando enlaces aumentamos el timeout
|
||||
timeout_find = timeout * 2
|
||||
elif item.emergency_urls: #Si se llama desde la Videoteca con enlaces cacheados...
|
||||
timeout_find = timeout / 2 #reducimos el timeout antes de saltar a los enlaces cacheados
|
||||
|
||||
#Bajamos los datos de la página
|
||||
data = ''
|
||||
try:
|
||||
data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, timeout=timeout).data)
|
||||
data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, timeout=timeout_find).data)
|
||||
except:
|
||||
pass
|
||||
|
||||
if not data:
|
||||
logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data)
|
||||
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log'))
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia?
|
||||
matches = item.emergency_urls[1] #Guardamos los matches de los .Torrent
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
else:
|
||||
if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca...
|
||||
return item #Devolvemos el Item de la llamada
|
||||
else:
|
||||
return itemlist #salimos
|
||||
data = unicode(data, "utf-8", errors="replace").encode("utf-8")
|
||||
data = scrapertools.find_single_match(data, 'div id="Tokyo" [^>]+>(.*?)</div>') #Seleccionamos la zona de links
|
||||
|
||||
patron = '\/icono_.*?png" title="(?P<lang>.*?)?" [^>]+><\/td><td>(?P<quality>.*?)?<?\/td>.*?<td>(?P<size>.*?)?<\/td><td><a class="link" href="(?P<url>.*?)?"'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
if not item.armagedon: #Si es un proceso normal, seguimos
|
||||
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_findvideos(item, itemlist) #Llamamos al método para el pintado del error
|
||||
return itemlist #Salimos
|
||||
|
||||
logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
|
||||
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log'))
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
else:
|
||||
logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
|
||||
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log'))
|
||||
if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia?
|
||||
matches = item.emergency_urls[1] #Guardamos los matches de los .Torrent
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
else:
|
||||
if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca...
|
||||
return item #Devolvemos el Item de la llamada
|
||||
else:
|
||||
return itemlist #salimos
|
||||
|
||||
#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)
|
||||
|
||||
#Ahora recorremos todos los links por calidades
|
||||
if item.videolibray_emergency_urls: #Viene de un lookup desde episodios para cachear enlaces
|
||||
emergency_torrents = []
|
||||
emergency_urls = []
|
||||
i = -1
|
||||
for lang, quality, size, scrapedurl in matches:
|
||||
i += 1
|
||||
temp_epi = ''
|
||||
if scrapertools.find_single_match(quality, '\s?\(Contrase.+?: <font color="[^>]*>(.*?)<\/font>\)'):
|
||||
password = scrapertools.find_single_match(quality, '\s?\(Contrase.+?: <font color="[^>]*>(.*?)<\/font>\)')
|
||||
@@ -500,6 +525,12 @@ def findvideos(item):
|
||||
if (contentSeason != item.contentSeason or contentEpisodeNumber != item.contentEpisodeNumber) and item.contentEpisodeNumber != 0:
|
||||
continue #si no son iguales, lo ignoramos
|
||||
|
||||
#Si es un looup desde episodios para cachear enlaces, lo salvamos en este momento
|
||||
if item.videolibray_emergency_urls:
|
||||
emergency_torrents.append(scrapedurl)
|
||||
emergency_urls.append(matches[i])
|
||||
continue
|
||||
|
||||
#Generamos una copia de Item para trabajar sobre ella
|
||||
item_local = item.clone()
|
||||
|
||||
@@ -527,7 +558,7 @@ def findvideos(item):
|
||||
item_local.quality = '%s [/COLOR][COLOR white][%s h]' % (item_local.quality, scrapertools.find_single_match(item.quality, '(\d+:\d+)'))
|
||||
|
||||
#if size and item_local.contentType != "episode":
|
||||
if not size:
|
||||
if not size and not item.armagedon:
|
||||
size = generictools.get_torrent_size(scrapedurl) #Buscamos el tamaño en el .torrent
|
||||
if size:
|
||||
size = size.replace(".", ",").replace("B,", " B").replace("b,", " b")
|
||||
@@ -544,8 +575,13 @@ def findvideos(item):
|
||||
#Salvamos la url del .torrent
|
||||
if scrapedurl:
|
||||
item_local.url = scrapedurl
|
||||
if item_local.emergency_urls and not item.armagedon:
|
||||
item_local = find_torrent_alt(item_local) #Si hay enlaces de emergencia los usamos como alternativos
|
||||
if item.armagedon: #Si es catastrófico, lo marcamos
|
||||
item_local.url = item.emergency_urls[0][i]
|
||||
item_local.quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % item_local.quality
|
||||
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 de Torrent
|
||||
|
||||
|
||||
#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)
|
||||
@@ -554,19 +590,26 @@ def findvideos(item):
|
||||
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.alive = "??" #Calidad del link sin verificar
|
||||
item_local.action = "play" #Visualizar vídeo
|
||||
item_local.server = "torrent" #Seridor Torrent
|
||||
item_local.alive = "??" #Calidad del link sin verificar
|
||||
item_local.action = "play" #Visualizar vídeo
|
||||
item_local.server = "torrent" #Seridor 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
|
||||
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: " + item_local.url + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality)
|
||||
#logger.debug(item_local)
|
||||
|
||||
if item.videolibray_emergency_urls: #Viene de un lookup desde episodios para cachear enlaces
|
||||
if len(emergency_torrents) > 0:
|
||||
item.emergency_urls = [] #Le damos el formato estandar: lista de listas de tuplas
|
||||
item.emergency_urls.append(emergency_torrents) #Devolvemos las urls de .torrents cacheadas
|
||||
item.emergency_urls.append(emergency_urls) #Devolvemos los matches cacheados
|
||||
return item
|
||||
|
||||
if len(itemlist_f) > 0: #Si hay entradas filtradas...
|
||||
itemlist.extend(itemlist_f) #Pintamos pantalla filtrada
|
||||
else:
|
||||
@@ -651,26 +694,29 @@ def episodios(item):
|
||||
if item.library_playcounts["season %d" % s] < temp_actual_num: #Si menor que actual, es Temp.
|
||||
item.contentType = "season"
|
||||
else:
|
||||
item.contentType = "tvshow" #No es Temporada 1, pero es más baja que la actual. Es Serie
|
||||
item.contentType = "tvshow" #No es Temporada 1, pero es más baja que la actual. Es Serie
|
||||
break
|
||||
s += 1
|
||||
else: #Sí, es Serie
|
||||
else: #Sí, es Serie
|
||||
item.contentType = "tvshow"
|
||||
|
||||
else: #Solo hay una temporada en la Videoteca
|
||||
if temp_actual_num > 1: #es Temporada la actual?
|
||||
else: #Solo hay una temporada en la Videoteca
|
||||
if temp_actual_num > 1: #es Temporada la actual?
|
||||
if item.contentSeason:
|
||||
item.contentType = "season" #Si está informado el num de Temp. se creó como Temporada
|
||||
item.contentType = "season" #Si está informado el num de Temp. se creó como Temporada
|
||||
else:
|
||||
item.contentType = "tvshow" #Si no, es Serie que no tiene Temp. 1
|
||||
else: #Si es Temp. 1, se procesa según el valor de configuración
|
||||
if modo_serie_temp == 0: #Es Temporada
|
||||
item.contentType = "tvshow" #Si no, es Serie que no tiene Temp. 1
|
||||
else: #Si es Temp. 1, se procesa según el valor de configuración
|
||||
if modo_serie_temp == 0: #Es Temporada
|
||||
item.contentType = "season"
|
||||
else: #Es Serie
|
||||
else: #Es Serie
|
||||
item.contentType = "tvshow"
|
||||
else:
|
||||
item.contentType = "list"
|
||||
|
||||
if item.ow_force == '1': #Si viene formazado la reconstrucción de la serie, lo hacemo
|
||||
item.contentType = "tvshow"
|
||||
|
||||
temp_lista = []
|
||||
temp_bucle = 0
|
||||
temp_next_alt = ''
|
||||
@@ -753,7 +799,7 @@ def episodios(item):
|
||||
break #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
|
||||
if item.contentType == "season":
|
||||
temp_advance = '' #Es la única temporada
|
||||
temp_advance = '' #Es la últica temporada
|
||||
if temp_next and item.library_playcounts: #Permitimos en actualización de Videoteca añadir nuevas temporadas
|
||||
temp_advance = 'forw' #Si hay nueva temporada, pasamos a esa como actual
|
||||
temp_previous = '' #lo limpiamos, por control
|
||||
@@ -910,6 +956,22 @@ def episodios(item):
|
||||
return itemlist
|
||||
|
||||
|
||||
def find_torrent_alt(item):
|
||||
logger.info()
|
||||
|
||||
if not item.emergency_urls:
|
||||
return item
|
||||
|
||||
i = 0
|
||||
for lang, quality, size, scrapedurl in item.emergency_urls[1]: #buscamos la url actual en la lista de matches cacheada
|
||||
if item.url == scrapedurl: #si está ...
|
||||
item.torrent_alt = item.emergency_urls[0][i] #... copiamos la url o la dirección de .torrent local
|
||||
break #... y nos vamos
|
||||
i += 1
|
||||
|
||||
return item
|
||||
|
||||
|
||||
def lookup_idiomas_paginacion(item, scrapedurl, title, lang, list_language):
|
||||
logger.info()
|
||||
estado = True
|
||||
|
||||
@@ -62,6 +62,14 @@
|
||||
"Actualizar"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "emergency_urls_torrents",
|
||||
"type": "bool",
|
||||
"label": "Se quieren guardar Torrents de Emergencia por si se cae la Web?",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": "!eq(-1,'No')"
|
||||
},
|
||||
{
|
||||
"id": "clonenewpct1_channel_default",
|
||||
"type": "list",
|
||||
@@ -70,11 +78,11 @@
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": [
|
||||
"Torrentrapid",
|
||||
"Tumejortorrent",
|
||||
"Torrentlocura",
|
||||
"Tvsinpagar",
|
||||
"Planetatorrent",
|
||||
"Torrentrapid",
|
||||
"Tumejortorrent",
|
||||
"Descargas2020",
|
||||
"Mispelisyseries"
|
||||
]
|
||||
@@ -83,7 +91,7 @@
|
||||
"id": "clonenewpct1_channels_list",
|
||||
"type": "text",
|
||||
"label": "Lista de clones de NewPct1 y orden de uso",
|
||||
"default": "('1', 'torrentrapid', 'http://torrentrapid.com/', 'movie, tvshow, season, episode', 'serie_episodios'), ('1', 'tumejortorrent', 'http://tumejortorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'torrentlocura', 'http://torrentlocura.com/', 'movie, tvshow, season, episode', ''), ('1', 'tvsinpagar', 'http://www.tvsinpagar.com/', 'tvshow, season, episode', ''), ('1', 'planetatorrent', 'http://planetatorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'descargas2020', 'http://descargas2020.com/', 'movie, tvshow, season, episode', ''), ('1', 'mispelisyseries', 'http://mispelisyseries.com/', 'movie', 'search, listado_busqueda')",
|
||||
"default": "('1', 'torrentlocura', 'http://torrentlocura.com/', 'movie, tvshow, season, episode', ''), ('1', 'tvsinpagar', 'http://www.tvsinpagar.com/', 'tvshow, season, episode', ''), ('1', 'planetatorrent', 'http://planetatorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'torrentrapid', 'http://torrentrapid.com/', 'movie, tvshow, season, episode', 'serie_episodios'), ('1', 'tumejortorrent', 'http://tumejortorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'descargas2020', 'http://descargas2020.com/', 'movie, tvshow, season, episode', ''), ('1', 'mispelisyseries', 'http://mispelisyseries.com/', 'movie', 'search, listado_busqueda')",
|
||||
"enabled": true,
|
||||
"visible": false
|
||||
},
|
||||
|
||||
@@ -1237,6 +1237,7 @@ def listado_busqueda(item):
|
||||
|
||||
def findvideos(item):
|
||||
logger.info()
|
||||
from core import videolibrarytools
|
||||
itemlist = []
|
||||
itemlist_t = [] #Itemlist total de enlaces
|
||||
itemlist_f = [] #Itemlist de enlaces filtrados
|
||||
@@ -1361,38 +1362,46 @@ def findvideos(item):
|
||||
# Descarga la página
|
||||
data = ''
|
||||
data_servidores = ''
|
||||
enlaces_ver = ''
|
||||
try:
|
||||
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url, timeout=timeout).data)
|
||||
data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures")
|
||||
url_servidores = item.url
|
||||
category_servidores = item.category
|
||||
data_servidores = data #salvamos data para verificar servidores, si es necesario
|
||||
except: #La web no responde. Probemos las urls de emergencia
|
||||
data_servidores = data #salvamos data para verificar servidores, si es necesario
|
||||
data_servidores_stat = False
|
||||
except: #La web no responde. Probemos las urls de emergencia
|
||||
pass
|
||||
|
||||
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent
|
||||
if not scrapertools.find_single_match(data, patron):
|
||||
patron = '<a href="([^"]+)"\s?title="[^"]+"\s?class="btn-torrent"' #Patron para .torrent (planetatorrent)
|
||||
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent
|
||||
patron_mult = 'torrent:check:status|' + patron
|
||||
if 'planetatorrent' in item.channel_host:
|
||||
patron = '<a href="([^"]+)"\s?title="[^"]+"\s?class="btn-torrent"' #Patron para .torrent (planetatorrent)
|
||||
patron_mult += '|<a href="([^"]+)"\s?title="[^"]+"\s?class="btn-torrent"'
|
||||
#Verificamos si se ha cargado una página, y si además tiene la estructura correcta
|
||||
if not data or not scrapertools.find_single_match(data, patron):
|
||||
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
|
||||
if item.intervencion: #Sí ha sido clausurada judicialmente
|
||||
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error
|
||||
if item.emergency_urls: #Hay urls de emergencia?
|
||||
item.url = item.emergency_urls[0] #Guardamos la url del .Torrent
|
||||
enlaces_ver = item.emergency_urls[1] #Guardamos los datos iniciales de los Servidores Directos
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
else:
|
||||
return itemlist #Salimos
|
||||
if not data or not scrapertools.find_single_match(data, patron) or not videolibrarytools.verify_url_torrent(scrapertools.find_single_match(data, patron)): # Si no hay datos o url, error
|
||||
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
|
||||
if item.intervencion: #Sí ha sido clausurada judicialmente
|
||||
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error
|
||||
else:
|
||||
logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / PATRON: " + patron + " / DATA: " + data)
|
||||
|
||||
if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia?
|
||||
itemlist.append(item.clone(action='', title=item.category + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log'))
|
||||
item.url = item.emergency_urls[0][0] #Guardamos la url del .Torrent
|
||||
try:
|
||||
enlaces_ver = item.emergency_urls[1] #Guardamos los datos iniciales de los Servidores Directos
|
||||
except:
|
||||
pass
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
data = 'xyz123' #Para que no haga más preguntas
|
||||
else:
|
||||
logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data)
|
||||
|
||||
#Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el vídeo
|
||||
item, data = generictools.fail_over_newpct1(item, patron)
|
||||
|
||||
item, data = generictools.fail_over_newpct1(item, patron_mult)
|
||||
|
||||
if not data: #Si no ha logrado encontrar nada, verificamos si hay servidores
|
||||
cnt_servidores = 0
|
||||
item.category = category_servidores #restauramos valores originales
|
||||
item.category = category_servidores #restauramos valores originales
|
||||
item.url = url_servidores
|
||||
|
||||
# Sistema de scrapeo de servidores creado por Torrentlocula, compatible con otros clones de Newpct1
|
||||
@@ -1414,19 +1423,23 @@ def findvideos(item):
|
||||
#Miramos si ha servidores
|
||||
if not data_servidores: #Si no ha logrado encontrar nada nos vamos
|
||||
itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.channel.capitalize() + '[/COLOR]: Ningún canal NewPct1 activo'))
|
||||
if item.emergency_urls: #Hay urls de emergencia?
|
||||
item.url = str(item.emergency_urls[0]).replace ("'", "").replace ("[", "").replace ("]", "") #Guardamos la url del .Torrent
|
||||
enlaces_ver = item.emergency_urls[1] #Guardamos los datos iniciales de los Servidores Directos
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
itemlist.append(item.clone(action='', title=item.category + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log'))
|
||||
if item.videolibray_emergency_urls:
|
||||
return item
|
||||
else:
|
||||
itemlist.append(item.clone(action='', title=item.category + ': 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
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
|
||||
|
||||
data = data_servidores #restauramos los datos
|
||||
data_servidores_stat = True #Marcamos como que los hemos usado
|
||||
|
||||
data = unicode(data, "iso-8859-1", errors="replace").encode("utf-8")
|
||||
data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures")
|
||||
|
||||
# patrón para la url torrent
|
||||
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent
|
||||
if not scrapertools.find_single_match(data, patron):
|
||||
patron = '<a href="([^"]+)"\s?title="[^"]+"\s?class="btn-torrent"' #Patron para .torrent (planetatorrent)
|
||||
|
||||
#buscamos el tamaño del .torrent
|
||||
size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>')
|
||||
if not size: #Para planetatorrent
|
||||
@@ -1434,8 +1447,8 @@ def findvideos(item):
|
||||
size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra
|
||||
if not size:
|
||||
size = scrapertools.find_single_match(item.quality, '\s?\[(\d+.?\d*?\s?\w\s?[b|B])\]')
|
||||
if not size:
|
||||
size = generictools.get_torrent_size(item.url) #Buscamos el tamaño en el .torrent
|
||||
if not size and not item.armagedon:
|
||||
size = generictools.get_torrent_size(scrapertools.find_single_match(data, patron)) #Buscamos el tamaño en el .torrent
|
||||
if size:
|
||||
item.title = re.sub(r'\s\[\d+,?\d*?\s\w[b|B]\]', '', item.title) #Quitamos size de título, si lo traía
|
||||
item.title = '%s [%s]' % (item.title, size) #Agregamos size al final del título
|
||||
@@ -1443,37 +1456,41 @@ def findvideos(item):
|
||||
item.quality = re.sub(r'\s\[\d+,?\d*?\s\w\s?[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía
|
||||
|
||||
#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)
|
||||
if not item.videolibray_emergency_urls:
|
||||
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
|
||||
|
||||
#Generamos una copia de Item para trabajar sobre ella
|
||||
item_local = item.clone()
|
||||
|
||||
# obtenemos la url torrent o usamos la de emergencia
|
||||
if not item.armagedon: #Si es un proceso normal, seguimos
|
||||
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent
|
||||
if not scrapertools.find_single_match(data, patron):
|
||||
patron = '<a href="([^"]+)"\s?title="[^"]+"\s?class="btn-torrent"' #Patron para .torrent (planetatorrent)
|
||||
# Verificamos la url torrent o usamos la de emergencia
|
||||
if not item.armagedon:
|
||||
item_local.url = scrapertools.find_single_match(data, patron)
|
||||
if not item_local.url: #error
|
||||
logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
|
||||
if item.emergency_urls: #Hay urls de emergencia?
|
||||
item.url = item.emergency_urls[0] #Guardamos la url del .Torrent
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
if item_local.url == 'javascript:;':
|
||||
item_local.url = '' #evitamos url vacías
|
||||
item_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso
|
||||
#logger.debug("Patron: " + patron + " url: " + item_local.url)
|
||||
#logger.debug(data)
|
||||
|
||||
if item_local.url and item.emergency_urls: #la url no está verificada
|
||||
item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la url del .Torrent ALTERNATIVA
|
||||
|
||||
if not item_local.url: #error en url?
|
||||
logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
|
||||
if item.emergency_urls: #Hay urls de emergencia?
|
||||
item.item_local = item.emergency_urls[0][0] #Guardamos la url del .Torrent
|
||||
item.armagedon = True #Marcamos la situación como catastrófica
|
||||
itemlist.append(item.clone(action='', title=item.category + ': [COLOR hotpink]Usando enlaces de emergencia[/COLOR]'))
|
||||
|
||||
#logger.debug("Patron: " + patron + " url: " + item_local.url)
|
||||
#logger.debug(data)
|
||||
|
||||
#Si es un lookup para cargar las urls de emergencia en la Videoteca...
|
||||
if item.videolibray_emergency_urls:
|
||||
if item.channel_host: del item.channel_host
|
||||
item.emergency_urls = []
|
||||
url = item_local.url
|
||||
if url == 'javascript:;': #No hay torrent...
|
||||
url = '' #... ignorar
|
||||
item.emergency_urls.append([url])
|
||||
item.emergency_urls.append([item_local.url]) #Guardamos el enlace del .torrent
|
||||
#... si no, ejecutamos el proceso normal
|
||||
else:
|
||||
#Ahora pintamos el link del Torrent, si lo hay
|
||||
if item_local.url: # Hay Torrent ?
|
||||
if item_local.url: # Hay Torrent ?
|
||||
if size:
|
||||
quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final del título
|
||||
else:
|
||||
@@ -1529,9 +1546,12 @@ def findvideos(item):
|
||||
if not item.armagedon: #Si es un proceso normal, seguimos
|
||||
enlaces_ver = re.compile(patron, re.DOTALL).findall(data)
|
||||
|
||||
if not enlaces_ver and item.emergency_urls[1]: #Si no hay enlaces, hay urls de emergencia?
|
||||
enlaces_ver = item.emergency_urls[1] #Guardamos los datos iniciales de los Servidores Directos
|
||||
item.armagedon = True #Activamos el modo catástrofe
|
||||
if not enlaces_ver: #Si no hay enlaces, hay urls de emergencia?
|
||||
try:
|
||||
enlaces_ver = item.emergency_urls[1] #Guardamos los datos iniciales de los Servidores Directos
|
||||
item.armagedon = True #Activamos el modo catástrofe
|
||||
except:
|
||||
pass
|
||||
|
||||
enlaces_descargar = enlaces_ver
|
||||
#logger.debug(enlaces_ver)
|
||||
|
||||
@@ -55,8 +55,11 @@ def list_movies(item, silent=False):
|
||||
new_item.path = raiz
|
||||
new_item.thumbnail = new_item.contentThumbnail
|
||||
new_item.text_color = "blue"
|
||||
strm_path = new_item.strm_path.replace("\\", "/").rstrip("/")
|
||||
if '/' in new_item.path:
|
||||
new_item.strm_path = strm_path
|
||||
|
||||
if not filetools.exists(filetools.join(new_item.path, filetools.basename(new_item.strm_path))):
|
||||
if not filetools.exists(filetools.join(new_item.path, filetools.basename(strm_path))):
|
||||
# Si se ha eliminado el strm desde la bilbioteca de kodi, no mostrarlo
|
||||
continue
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ def save_movie(item):
|
||||
try:
|
||||
channel = generictools.verify_channel(item.channel)
|
||||
if config.get_setting("emergency_urls", channel) in [1, 3]:
|
||||
item = emergency_urls(item)
|
||||
item = emergency_urls(item, None, json_path)
|
||||
if item_nfo.emergency_urls and not isinstance(item_nfo.emergency_urls, dict):
|
||||
del item_nfo.emergency_urls
|
||||
if not item_nfo.emergency_urls:
|
||||
@@ -396,6 +396,10 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
emergency_urls_stat = config.get_setting("emergency_urls", channel_alt) #El canal quiere urls de emergencia?
|
||||
emergency_urls_succ = False
|
||||
channel = __import__('channels.%s' % channel_alt, fromlist=["channels.%s" % channel_alt])
|
||||
if serie.torrent_caching_fail: #Si el proceso de conversión ha fallado, no se cachean
|
||||
emergency_urls_stat = 0
|
||||
del serie.torrent_caching_fail
|
||||
|
||||
new_episodelist = []
|
||||
# Obtenemos el numero de temporada y episodio y descartamos los q no lo sean
|
||||
tags = []
|
||||
@@ -410,24 +414,24 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
|
||||
# Si se ha marcado la opción de url de emergencia, se añade ésta a cada episodio después de haber ejecutado Findvideos del canal
|
||||
if e.emergency_urls and isinstance(e.emergency_urls, dict): del e.emergency_urls #Borramos trazas anterioires
|
||||
json_path = filetools.join(path, ("%s [%s].json" % (season_episode, e.channel)).lower()) #Path del .json del episodio
|
||||
if emergency_urls_stat == 1 and not e.emergency_urls and e.contentType == 'episode': #Guardamos urls de emergencia?
|
||||
json_path = filetools.join(path, ("%s [%s].json" % (season_episode, e.channel)).lower()) #Path del .json del episodio
|
||||
if json_path in ficheros: #Si existe el .json sacamos de ahí las urls
|
||||
if overwrite: #pero solo si se se sobrescriben los .json
|
||||
json_epi = Item().fromjson(filetools.read(json_path)) #Leemos el .json
|
||||
if json_epi.emergency_urls: #si existen las urls de emergencia...
|
||||
e.emergency_urls = json_epi.emergency_urls #... las copiamos
|
||||
else: #y si no...
|
||||
e = emergency_urls(e, channel) #... las generamos
|
||||
e = emergency_urls(e, channel, json_path) #... las generamos
|
||||
else:
|
||||
e = emergency_urls(e, channel) #Si el episodio no existe, generamos las urls
|
||||
e = emergency_urls(e, channel, json_path) #Si el episodio no existe, generamos las urls
|
||||
if e.emergency_urls: #Si ya tenemos urls...
|
||||
emergency_urls_succ = True #... es un éxito y vamos a marcar el .nfo
|
||||
elif emergency_urls_stat == 2 and e.contentType == 'episode': #Borramos urls de emergencia?
|
||||
if e.emergency_urls: del e.emergency_urls
|
||||
emergency_urls_succ = True #... es un éxito y vamos a marcar el .nfo
|
||||
elif emergency_urls_stat == 3 and e.contentType == 'episode': #Actualizamos urls de emergencia?
|
||||
e = emergency_urls(e, channel) #generamos las urls
|
||||
e = emergency_urls(e, channel, json_path) #generamos las urls
|
||||
if e.emergency_urls: #Si ya tenemos urls...
|
||||
emergency_urls_succ = True #... es un éxito y vamos a marcar el .nfo
|
||||
|
||||
@@ -711,22 +715,171 @@ def add_tvshow(item, channel=None):
|
||||
xbmc_videolibrary.sync_trakt_addon(path)
|
||||
|
||||
|
||||
def emergency_urls(item, channel=None):
|
||||
def emergency_urls(item, channel=None, path=None):
|
||||
logger.info()
|
||||
import re
|
||||
"""
|
||||
Llamamos a Findvideos del canal con la variable "item.videolibray_emergency_urls = True" para obtener la variable
|
||||
"item.matches" con la lista de listas de tuplas de los enlaces torrent y de servidores directos para ese episodio o película
|
||||
"item.emergency_urls" con la lista de listas de tuplas de los enlaces torrent y de servidores directos para ese episodio o película
|
||||
En la lista [0] siempre deben ir los enlaces torrents, si los hay. Si se desea cachear los .torrents, la búsqueda va contra esa lista.
|
||||
En la lista dos irán los enlaces de servidores directos, pero también pueden ir enlaces magnet (que no son cacheables)
|
||||
"""
|
||||
|
||||
#lanazamos un "lookup" en el "findvideos" del canal para obtener los enlaces de emergencia
|
||||
try:
|
||||
if channel == None:
|
||||
channel = generictools.verify_channel(item.channel)
|
||||
if channel == None: #Si el llamador no ha aportado la estructura de channel, se crea
|
||||
channel = generictools.verify_channel(item.channel) #Se verifica si es un clon, que devuelva "newpct1"
|
||||
channel = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel])
|
||||
if hasattr(channel, 'findvideos'):
|
||||
item.videolibray_emergency_urls = True
|
||||
item_res = getattr(channel, 'findvideos')(item)
|
||||
del item_res.videolibray_emergency_urls
|
||||
if hasattr(channel, 'findvideos'): #Si el canal tiene "findvideos"...
|
||||
item.videolibray_emergency_urls = True #... se marca como "lookup"
|
||||
item_res = getattr(channel, 'findvideos')(item) #... se procesa
|
||||
del item_res.videolibray_emergency_urls #... y se borra la marca de lookup
|
||||
except:
|
||||
item_res = item.clone()
|
||||
logger.error('ERROR al procesar el episodio')
|
||||
item_res = item.clone() #Si ha habido un error, se devuelve el Item original
|
||||
|
||||
#Si el usuario ha activado la opción "emergency_urls_torrents", se descargarán los archivos .torrent de cada título
|
||||
else: #Si se han cacheado con éxito los enlaces...
|
||||
logger.debug('HOLA')
|
||||
logger.debug(item_res.emergency_urls)
|
||||
try:
|
||||
channel_bis = generictools.verify_channel(item.channel)
|
||||
if config.get_setting("emergency_urls_torrents", channel_bis) and item_res.emergency_urls and path != None:
|
||||
videolibrary_path = config.get_videolibrary_path() #detectamos el path absoluto del título
|
||||
movies = config.get_setting("folder_movies")
|
||||
series = config.get_setting("folder_tvshows")
|
||||
if movies in path:
|
||||
folder = movies
|
||||
else:
|
||||
folder = series
|
||||
videolibrary_path = filetools.join(videolibrary_path, folder)
|
||||
i = 1
|
||||
for url in item_res.emergency_urls[0]: #Recorremos las urls de emergencia...
|
||||
torrents_path = re.sub(r'(?:\.\w+$)', '_%s.torrent' % str(i).zfill(2), path)
|
||||
path_real = caching_torrents(url, torrents_path=torrents_path) #... para descargar los .torrents
|
||||
if path_real: #Si ha tenido éxito...
|
||||
item_res.emergency_urls[0][i-1] = path_real.replace(videolibrary_path, '') #se guarda el "path" relativo
|
||||
i += 1
|
||||
except:
|
||||
item_res = item.clone() #Si ha habido un error, se devuelve el Item original
|
||||
|
||||
#logger.debug(item_res.emergency_urls)
|
||||
return item_res
|
||||
return item_res #Devolvemos el Item actualizado con los enlaces de emergencia
|
||||
|
||||
|
||||
def caching_torrents(url, torrents_path=None, decode_flag=False, timeout=10, lookup=False):
|
||||
if torrents_path != None:
|
||||
logger.info("path = " + torrents_path)
|
||||
else:
|
||||
logger.info()
|
||||
import urllib
|
||||
import re
|
||||
from core import httptools
|
||||
|
||||
"""
|
||||
Descarga en el path recibido el .torrent de la url recibida, y pasa el decode
|
||||
Devuelve el path real del .torrent, o el path vacío si la operación no ha tenido éxito
|
||||
"""
|
||||
|
||||
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
|
||||
|
||||
#Módulo PRINCIPAL
|
||||
try:
|
||||
if lookup:
|
||||
torrents_path = lookup
|
||||
else:
|
||||
if '.torrent' not in torrents_path:
|
||||
torrents_path += '.torrent' #path para dejar el .torrent
|
||||
|
||||
torrents_path_encode = filetools.encode(torrents_path) #encode utf-8 del path
|
||||
response = httptools.downloadpage(url, timeout=timeout) #Descargamos el .torrent
|
||||
if not response.sucess:
|
||||
logger.error('Archivo .torrent no encontrado: ' + url)
|
||||
torrents_path = ''
|
||||
return torrents_path #Si hay un error, devolvemos el "path" vacío
|
||||
torrent_file = response.data
|
||||
|
||||
if "used CloudFlare" in torrent_file: #Si tiene CloudFlare, usamos este proceso
|
||||
response = httptools.downloadpage("http://anonymouse.org/cgi-bin/anon-www.cgi/" + url.strip(), timeout=timeout)
|
||||
if not response.sucess:
|
||||
logger.error('Archivo .torrent no encontrado: ' + url)
|
||||
torrents_path = ''
|
||||
return torrents_path #Si hay un error, devolvemos el "path" vacío
|
||||
torrent_file = response.data
|
||||
|
||||
if decode_flag:
|
||||
torrent_file = decode(torrent_file) #decodificamos el .torrent
|
||||
|
||||
if not lookup:
|
||||
filetools.write(torrents_path_encode, torrent_file) #Salvamos el .torrent
|
||||
except:
|
||||
torrents_path = '' #Si hay un error, devolvemos el "path" vacío
|
||||
|
||||
#logger.debug(torrents_path)
|
||||
return torrents_path
|
||||
|
||||
|
||||
def verify_url_torrent(url, decode_flag=False, timeout=5):
|
||||
"""
|
||||
Verifica si el archivo .torrent al que apunta la url está disponible, descargándolo en un area temporal
|
||||
Entrada: url
|
||||
Salida: True o False dependiendo del resultado de la operación
|
||||
"""
|
||||
|
||||
if not url or url == 'javascript:;': #Si la url viene vacía...
|
||||
return False #... volvemos con error
|
||||
torrents_path = caching_torrents(url, timeout=timeout, lookup=True) #Descargamos el .torrent, sin decode
|
||||
if torrents_path: #Si ha tenido éxito...
|
||||
return True
|
||||
try:
|
||||
torrents_path = caching_torrents(url, timeout=timeout, lookup=True) #Descargamos el .torrent, sin decode
|
||||
if torrents_path: #Si ha tenido éxito...
|
||||
return True
|
||||
except:
|
||||
return False #en caso de error, False
|
||||
|
||||
@@ -296,6 +296,8 @@ def post_tmdb_listado(item, itemlist):
|
||||
del item_local.extra2
|
||||
if item_local.library_filter_show:
|
||||
del item_local.library_filter_show
|
||||
if item_local.channel_host:
|
||||
del item_local.channel_host
|
||||
|
||||
#Ajustamos el nombre de la categoría
|
||||
if item_local.channel == channel_py:
|
||||
@@ -718,6 +720,8 @@ def post_tmdb_episodios(item, itemlist):
|
||||
del item.from_channel
|
||||
if item.library_filter_show:
|
||||
del item.library_filter_show
|
||||
if item.channel_host:
|
||||
del item.channel_host
|
||||
|
||||
for item_local in itemlist: #Recorremos el Itemlist generado por el canal
|
||||
if item_local.add_videolibrary:
|
||||
@@ -741,7 +745,7 @@ def post_tmdb_episodios(item, itemlist):
|
||||
if item_local.update_next:
|
||||
del item_local.update_next
|
||||
if item_local.channel_host:
|
||||
del item_local.channel_host
|
||||
del item_local.channel_host
|
||||
if item_local.intervencion:
|
||||
del item_local.intervencion
|
||||
if item_local.ow_force:
|
||||
@@ -756,6 +760,8 @@ def post_tmdb_episodios(item, itemlist):
|
||||
del item_local.emergency_urls
|
||||
if item_local.library_filter_show:
|
||||
del item_local.library_filter_show
|
||||
if item_local.extra2:
|
||||
del item_local.extra2
|
||||
#logger.debug(item_local)
|
||||
|
||||
#Ajustamos el nombre de la categoría si es un clone de NewPct1
|
||||
@@ -1034,10 +1040,12 @@ def post_tmdb_findvideos(item, itemlist):
|
||||
|
||||
#Ajustamos el nombre de la categoría
|
||||
if item.channel == channel_py:
|
||||
item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
|
||||
category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
|
||||
if category:
|
||||
item.category = category
|
||||
|
||||
if item.armagedon: #Es una situación catastrófica?
|
||||
itemlist.append(item.clone(action='', title=item.category + ': [COLOR hotpink]VIDEOTECA: Usando enlaces de emergencia[/COLOR]'))
|
||||
itemlist.append(item.clone(action='', title=item.category + ': [COLOR hotpink]Usando enlaces de emergencia[/COLOR]'))
|
||||
|
||||
#Quitamos el la categoría o nombre del título, si lo tiene
|
||||
if item.contentTitle:
|
||||
@@ -1264,22 +1272,33 @@ def get_torrent_size(url):
|
||||
#Móludo principal
|
||||
size = ""
|
||||
try:
|
||||
torrents_path = config.get_videolibrary_path() + '/torrents' #path para dejar el .torrent
|
||||
#torrents_path = config.get_videolibrary_path() + '/torrents' #path para dejar el .torrent
|
||||
|
||||
if not os.path.exists(torrents_path):
|
||||
os.mkdir(torrents_path) #si no está la carpeta la creamos
|
||||
#if not os.path.exists(torrents_path):
|
||||
# os.mkdir(torrents_path) #si no está la carpeta la creamos
|
||||
|
||||
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 + "/generictools.torrent") #desacargamos el .torrent a la carpeta
|
||||
torrent_file = open(torrents_path + "/generictools.torrent", "rb").read() #leemos el .torrent
|
||||
#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 + "/generictools.torrent") #desacargamos el .torrent a la carpeta
|
||||
#torrent_file = open(torrents_path + "/generictools.torrent", "rb").read() #leemos el .torrent
|
||||
|
||||
response = httptools.downloadpage(url, timeout=2) #Descargamos el .torrent
|
||||
if not response.sucess:
|
||||
size = ''
|
||||
return size #Si hay un error, devolvemos el "size" vacío
|
||||
torrent_file = response.data
|
||||
|
||||
if "used CloudFlare" in torrent_file: #Si tiene CloudFlare, usamos este proceso
|
||||
try:
|
||||
urllib.urlretrieve("http://anonymouse.org/cgi-bin/anon-www.cgi/" + url.strip(),
|
||||
torrents_path + "/generictools.torrent")
|
||||
torrent_file = open(torrents_path + "/generictools.torrent", "rb").read()
|
||||
except:
|
||||
torrent_file = ""
|
||||
#try:
|
||||
# urllib.urlretrieve("http://anonymouse.org/cgi-bin/anon-www.cgi/" + url.strip(),
|
||||
# torrents_path + "/generictools.torrent")
|
||||
# torrent_file = open(torrents_path + "/generictools.torrent", "rb").read()
|
||||
#except:
|
||||
# torrent_file = ""
|
||||
response = httptools.downloadpage("http://anonymouse.org/cgi-bin/anon-www.cgi/" + url.strip())
|
||||
if not response.sucess:
|
||||
size = ''
|
||||
return size #Si hay un error, devolvemos el "size" vacío
|
||||
torrent_file = response.data
|
||||
|
||||
torrent = decode(torrent_file) #decodificamos el .torrent
|
||||
|
||||
@@ -1299,10 +1318,10 @@ def get_torrent_size(url):
|
||||
except:
|
||||
logger.error('ERROR al buscar el tamaño de un .Torrent: ' + str(url))
|
||||
|
||||
try:
|
||||
os.remove(torrents_path + "/generictools.torrent") #borramos el .torrent
|
||||
except:
|
||||
pass
|
||||
#try:
|
||||
# os.remove(torrents_path + "/generictools.torrent") #borramos el .torrent
|
||||
#except:
|
||||
# pass
|
||||
|
||||
#logger.debug(str(url) + ' / ' + str(size))
|
||||
|
||||
@@ -1429,6 +1448,15 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
if not item.extra2:
|
||||
item.extra2 = 'z9z8z7z6z5'
|
||||
|
||||
patron_alt = ''
|
||||
verify_torrent = ''
|
||||
if patron is not True and '|' in patron: #Comprobamos si hay dos patrones alternativos
|
||||
try:
|
||||
verify_torrent, patron1, patron_alt = patron.split('|') #Si es así, los separamos y los tratamos
|
||||
patron = patron1
|
||||
except:
|
||||
pass
|
||||
|
||||
#Array con los datos de los canales alternativos
|
||||
#Cargamos en .json del canal para ver las listas de valores en settings
|
||||
fail_over = channeltools.get_channel_json(channel_py)
|
||||
@@ -1451,6 +1479,7 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
channel_failed = channel #salvamos el nombre del canal o categoría
|
||||
channel_host_failed = channel_host #salvamos el nombre del host
|
||||
channel_url_failed = item.url #salvamos la url
|
||||
|
||||
if patron == True and active == '1': #solo nos han pedido verificar el clone
|
||||
return (item, data) #nos vamos, con el mismo clone, si está activo
|
||||
if (item.action == 'episodios' or item.action == 'findvideos') and item.contentType not in contentType: #soporta el fail_over de este contenido?
|
||||
@@ -1527,18 +1556,30 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
data_alt = scrapertools.find_single_match(data, patron)
|
||||
if not data_alt:
|
||||
data_alt = scrapertools.find_single_match(data_comillas, patron)
|
||||
if data_alt and patron_alt:
|
||||
data_alt = scrapertools.find_single_match(data, patron_alt)
|
||||
if not data_alt and patron_alt:
|
||||
data_alt = scrapertools.find_single_match(data_comillas, patron_alt)
|
||||
if patron2 != None:
|
||||
data_alt = scrapertools.find_single_match(data_alt, patron2)
|
||||
if not data_alt: #no ha habido suerte, probamos con el siguiente canal
|
||||
logger.error("ERROR 02: " + item.action + ": Ha cambiado la estructura de la Web: " + url + " / Patron: " + patron)
|
||||
logger.error("ERROR 02: " + item.action + ": Ha cambiado la estructura de la Web: " + url + " / Patron: " + patron + " / " +patron_alt)
|
||||
web_intervenida(item, data)
|
||||
data = ''
|
||||
continue
|
||||
else:
|
||||
item.url = url #guardamos la url que funciona
|
||||
#Función especial para encontrar en otro clone un .torrent válido
|
||||
if verify_torrent == 'torrent:check:status':
|
||||
from core import videolibrarytools
|
||||
if videolibrarytools.verify_url_torrent(data_alt): #verificamos si el .torrent existe
|
||||
item.url = url #guardamos la url que funciona
|
||||
break #nos vamos, con la nueva url del .torrent verificada
|
||||
data = ''
|
||||
continue #no vale el .torrent, continuamos
|
||||
item.url = url #guardamos la url que funciona, sin verificar
|
||||
break #por fin !!! Este canal parece que funciona
|
||||
else:
|
||||
logger.error("ERROR 02: " + item.action + ": Ha cambiado la estructura de la Web: " + url + " / Patron: " + patron)
|
||||
logger.error("ERROR 02: " + item.action + ": Ha cambiado la estructura de la Web: " + url + " / Patron: " + patron + " / " +patron_alt)
|
||||
web_intervenida(item, data)
|
||||
data = ''
|
||||
continue
|
||||
@@ -1715,6 +1756,8 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
|
||||
#if it != None: logger.debug(it)
|
||||
if not it:
|
||||
it = Item()
|
||||
item_back = item.clone()
|
||||
it_back = item.clone()
|
||||
ow_force_param = True
|
||||
channel_enabled = False
|
||||
update_stat = 0
|
||||
@@ -1746,10 +1789,10 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
|
||||
|
||||
#primero tratamos los clones de Newpct1
|
||||
channel_alt = item.channel
|
||||
if item.url:
|
||||
channel_alt = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').lower() #Salvamos en nombre del canal o clone
|
||||
if not channel_alt:
|
||||
channel_alt = item.channel
|
||||
#if item.url and not it.library_urls:
|
||||
# channel_alt = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').lower() #Salvamos en nombre del canal o clone
|
||||
# if not channel_alt:
|
||||
# channel_alt = item.channel
|
||||
channel = "'%s'" % channel_alt
|
||||
category = ''
|
||||
if channel_alt != 'videolibrary':
|
||||
@@ -1775,6 +1818,31 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
|
||||
|
||||
if it.emergency_urls:
|
||||
item.emergency_urls = it.emergency_urls #Refrescar desde el .nfo
|
||||
|
||||
#Arreglo temporal para Newpct1
|
||||
if channel in fail_over_list or channel_alt == 'videolibrary':
|
||||
channel_bis = channel_py
|
||||
if not item.url and it.library_urls and channel_alt == 'videolibrary':
|
||||
for canal_vid, url_vid in it.library_urls.items(): #Se recorre "item.library_urls" para buscar canales candidatos
|
||||
canal_vid_alt = "'%s'" % canal_vid
|
||||
if canal_vid_alt in fail_over_list: #Se busca si es un clone de newpct1
|
||||
channel_bis = channel_py
|
||||
channel_alt = canal_vid
|
||||
channel = "'%s'" % channel_alt
|
||||
break
|
||||
else:
|
||||
channel_bis = canal_vid
|
||||
if channel_bis == channel_py and config.get_setting("emergency_urls", channel_bis) == 1 and config.get_setting("emergency_urls_torrents", channel_bis) and item.emergency_urls and item.emergency_urls.get(channel_alt, False):
|
||||
raiz, carpetas_series, ficheros = filetools.walk(path).next()
|
||||
objetivo = '[%s]_01.torrent' % channel_alt
|
||||
encontrado = False
|
||||
for fichero in ficheros:
|
||||
if objetivo in fichero:
|
||||
encontrado = True
|
||||
break
|
||||
if not encontrado:
|
||||
logger.error('REGENERANDO: ' + str(item.emergency_urls))
|
||||
item.emergency_urls.pop(channel_alt, None)
|
||||
|
||||
if item.url: #Viene de actualización de videoteca de series
|
||||
#Analizamos si el canal ya tiene las urls de emergencia: guardar o borrar
|
||||
@@ -1935,6 +2003,21 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
|
||||
it.update_next = '1'
|
||||
del it.update_next
|
||||
|
||||
#Verificamos que las webs de los canales estén activas antes de borrar los .json, para asegurar que se pueden regenerar
|
||||
i = 0
|
||||
for canal_org_def, canal_des_def, url_total, opt_def, ow_force_def in canal_org_des_list: #pasamos por las "parejas" a borrar
|
||||
try:
|
||||
response = httptools.downloadpage(url_total, only_headers=True)
|
||||
except:
|
||||
pass
|
||||
if not response.sucess:
|
||||
logger.error('Web ' + canal_des_def.upper() + ' INACTIVA. Regla no procesada: ' + str(canal_org_des_list[i]))
|
||||
item = item_back.clone() #Restauro las imágenes inciales
|
||||
it = it_back.clone()
|
||||
item.torrent_caching_fail = True #Marcamos el proceso como fallido
|
||||
return (item, it, False)
|
||||
i += 1
|
||||
|
||||
# Listamos todos los ficheros de la serie, asi evitamos tener que comprobar si existe uno por uno
|
||||
canal_erase_list = []
|
||||
from core import videolibrarytools
|
||||
@@ -1951,44 +2034,29 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
|
||||
#logger.error(canal_erase + canal_new + archivo + archivo_alt)
|
||||
#Borramos los .json que sean de los canal afectados, incluidos todos los de los clones de newpct1 si éste es el canal
|
||||
if canal_erase in archivo or (ow_force_def == 'emerg' and canal_erase_alt in fail_over_list and archivo_alt in fail_over_list):
|
||||
if canal_des_def and it.contentType == 'movie': #Si es película ...
|
||||
if canal_des_def and it.contentType == 'movie' and not '.torrent' in archivo: #Si es película ...
|
||||
item_json = Item().fromjson(filetools.read(archivo)) #leemos el .json ante de borrarlo para salvar...
|
||||
title = item_json.title #... el título con su formato
|
||||
language = item_json.language #... los idiomas, que no están en el .nfo
|
||||
wanted = item_json.wanted #... y wanted con el título original
|
||||
json_path = archivo.replace(canal_erase, canal_new) #Salvamos el path del .json para luego crearlo
|
||||
|
||||
emer_urls = ''
|
||||
if ow_force_def == 'emerg' and opt_def in ['1', '3']: #Si era una op. para añadir/actualizar urls de emergencia ...
|
||||
item_json = videolibrarytools.emergency_urls(item_json) #... ejecutamos "findvideos" del canal para obtenerlas
|
||||
if item_json.emergency_urls: #... si las hay ...
|
||||
emer_urls = item_json.emergency_urls #... lo preparamos para el .json
|
||||
if it.emergency_urls and not isinstance(it.emergency_urls, dict):
|
||||
del it.emergency_urls
|
||||
if not it.emergency_urls: #... lo actualizamos en el .nfo
|
||||
it.emergency_urls = dict() #... iniciamos la variable si no existe
|
||||
it.emergency_urls.update({canal_des_def: True}) #... se marca como activo
|
||||
else:
|
||||
continue #Si no hay url, pasamos al siguiente, sin borrar el .json
|
||||
if ow_force_def == 'emerg' and opt_def == '2': #Si era una operación para borrar urls de emergencia ...
|
||||
emer_urls = '2' #borramos enlaces
|
||||
if it.emergency_urls and not isinstance(it.emergency_urls, dict):
|
||||
del it.emergency_urls
|
||||
if it.emergency_urls and it.emergency_urls.get(item_json.channel, False):
|
||||
it.emergency_urls.pop(item_json.channel, None) #borramos la entrada del .nfo
|
||||
|
||||
json_path_list += [(canal_org_def, canal_des_def, url_total, json_path, title, language, wanted, emer_urls)]
|
||||
filetools.remove(archivo) #Borramos el .json
|
||||
json_path_list += [(canal_org_def, canal_des_def, url_total, json_path, title, language, wanted, ow_force_def, opt_def, archivo)]
|
||||
filetools.remove(archivo) #Borramos el .json y el .torrent
|
||||
logger.error('** BORRAMOS: ' + str(archivo))
|
||||
if ow_force_def == 'del' or ow_force_def == 'emerg': #Si la función es 'del' or 'emerg' ...
|
||||
overwrite = True #Le decimos que sobreescriba todos los .jsons
|
||||
item.ow_force = '1' #Le decimos que revise todas las temporadas
|
||||
|
||||
#Si se ha cambiado algo, se actualizan los .nfo
|
||||
if it.nfo: del it.nfo #Borramos variables innecesarias
|
||||
if it.path: del it.path #Borramos variables innecesarias
|
||||
if it.text_color: del it.text_color #Borramos variables innecesarias
|
||||
if item.contentType == "movie" and ".nfo" in archivo: #Para películas
|
||||
archivo_nfo = archivo #Guardamos el path del .nfo para futuro uso
|
||||
if it.ow_force: del it.ow_force
|
||||
filetools.write(archivo, head_nfo + it.tojson()) #escribo el .nfo de la peli
|
||||
if item.contentType != "movie" and "tvshow.nfo" in archivo:
|
||||
archivo_nfo = archivo #Guardamos el path del .nfo para futuro uso
|
||||
filetools.write(archivo, head_nfo + it.tojson()) #escribo el tvshow.nfo por si aborta update
|
||||
|
||||
#Aquí convertimos las películas. Después de borrado el .json, dejamos que videolibrarytools lo regenere
|
||||
@@ -1996,19 +2064,20 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
|
||||
item_movie = item.clone()
|
||||
if item_movie.ow_force: del item_movie.ow_force
|
||||
item_movie.update_last = '1'
|
||||
del item_movie.update_last
|
||||
del item_movie.library_playcounts #Borramos lo que no es necesario en el .json
|
||||
del item_movie.library_urls
|
||||
del item_movie.nfo
|
||||
del item_movie.path
|
||||
if item_movie.update_last: del item_movie.update_last
|
||||
if item_movie.library_playcounts: del item_movie.library_playcounts #Borramos lo que no es necesario en el .json
|
||||
if item_movie.library_urls: del item_movie.library_urls
|
||||
if item_movie.nfo: del item_movie.nfo
|
||||
if item_movie.path: del item_movie.path
|
||||
if item_movie.strm_path: del item_movie.strm_path
|
||||
if item_movie.text_color: del item_movie.text_color
|
||||
if item_movie.channel_host: del item_movie.channel_host
|
||||
if not item_movie.context: item_movie.context = "['buscar_trailer']"
|
||||
if not item_movie.extra: item_movie.extra = "peliculas"
|
||||
|
||||
if json_path_list:
|
||||
logger.error('** .json LIST: ' + str(json_path_list))
|
||||
for canal_org_def, canal_des_def, url_total, json_path, title, language, wanted, emer_urls in json_path_list: #pasamos por todos canales
|
||||
for canal_org_def, canal_des_def, url_total, json_path, title, language, wanted, ow_force_def, opt_def, archivo in json_path_list: #pasamos por todos canales
|
||||
logger.error('** ESCRIBIMOS: ' + json_path)
|
||||
item_movie.emergency_urls = False
|
||||
del item_movie.emergency_urls
|
||||
@@ -2019,11 +2088,29 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
|
||||
if language: item_movie.language = language #restaurmos los idiomas
|
||||
if wanted: item_movie.wanted = wanted #restaurmos wanted
|
||||
item_movie.added_replacing = canal_org_def #guardamos la traza del canal reemplazado
|
||||
if emer_urls == '2': #si estamos borrando urls de emergencia ...
|
||||
if item_movie.emergency_urls:
|
||||
del item_movie.emergency_urls #... las borramos
|
||||
elif emer_urls: #si estamos añadiendo urls de emergencia ...
|
||||
item_movie.emergency_urls = emer_urls #... las copiamos al .json
|
||||
|
||||
if ow_force_def == 'emerg' and opt_def in ['1', '3']: #Si era una op. para añadir/actualizar urls de emergencia ...
|
||||
item_movie = videolibrarytools.emergency_urls(item_movie, None, archivo) #... ejecutamos "findvideos" del canal para obtenerlas
|
||||
if item_movie.channel_host: del item_movie.channel_host
|
||||
if item_movie.unify: del item_movie.unify
|
||||
if item_movie.extra2: del item_movie.extra2
|
||||
if item_movie.emergency_urls: #... si las hay ...
|
||||
if it.emergency_urls and not isinstance(it.emergency_urls, dict):
|
||||
del it.emergency_urls
|
||||
if not it.emergency_urls: #... lo actualizamos en el .nfo
|
||||
it.emergency_urls = dict() #... iniciamos la variable si no existe
|
||||
it.emergency_urls.update({canal_des_def: True}) #... se marca como activo
|
||||
filetools.write(archivo_nfo, head_nfo + it.tojson()) #actualizo el .nfo de la peli
|
||||
else:
|
||||
logger.error('Error en FINDVIDEOS: ' + archivo + ' / Regla: ' + canal_org_def + ', ' + opt_def + ', ' + ow_force_def)
|
||||
|
||||
if ow_force_def == 'emerg' and opt_def == '2': #Si era una operación para borrar urls de emergencia ...
|
||||
if it.emergency_urls and not isinstance(it.emergency_urls, dict):
|
||||
del it.emergency_urls
|
||||
if it.emergency_urls and it.emergency_urls.get(item_movie.channel, False):
|
||||
it.emergency_urls.pop(item_movie.channel, None) #borramos la entrada del .nfo
|
||||
filetools.write(archivo_nfo, head_nfo + it.tojson()) #actualizo el .nfo de la peli
|
||||
|
||||
filetools.write(json_path, item_movie.tojson()) #Salvamos el nuevo .json de la película
|
||||
|
||||
if (update_stat > 0 and path != False and ow_force_def in ['force', 'auto']) or item.ow_force == '1' or len(json_path_list) > 0:
|
||||
|
||||
@@ -1061,6 +1061,9 @@ def torrent_client_installed(show_tuple=False):
|
||||
def play_torrent(item, xlistitem, mediaurl):
|
||||
logger.info()
|
||||
import time
|
||||
from core import filetools
|
||||
from core import httptools
|
||||
from core import videolibrarytools
|
||||
|
||||
# Opciones disponibles para Reproducir torrents
|
||||
torrent_options = list()
|
||||
@@ -1090,6 +1093,36 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xlistitem) #Preparamos el entorno para evitar error Kod1 18
|
||||
time.sleep(0.5) #Dejamos tiempo para que se ejecute
|
||||
|
||||
#Nuevo método de descarga previa del .torrent. Si da error, miramos si hay alternatica local. Si ya es local, lo usamos
|
||||
url_stat = False
|
||||
videolibrary_path = config.get_videolibrary_path() #Calculamos el path absoluto a partir de la Videoteca
|
||||
if not filetools.exists(videolibrary_path): #Si no existe el path, pasamos al modo clásico
|
||||
url_stat = True
|
||||
elif not filetools.exists(videolibrary_path + 'temp_torrents_Alfa'): #Si no existe la carpeta temporal para .torrents, la creamos
|
||||
filetools.mkdir(videolibrary_path + 'temp_torrents_Alfa')
|
||||
torrents_path = filetools.join(videolibrary_path, 'temp_torrents_Alfa', 'cliente_torrent_Alfa.torrent') #path de descarga temporal
|
||||
|
||||
#identificamos si es una url o un path de archivo. Los Magnets los tratamos de la forma clásica
|
||||
if not item.url.startswith("\\") and not item.url.startswith("/") and not item.url.startswith("magnet:") and not url_stat:
|
||||
timeout = 10
|
||||
if item.torrent_alt:
|
||||
timeout = 5
|
||||
item.url = videolibrarytools.caching_torrents(item.url, torrents_path=torrents_path, timeout=timeout) #Descargamos el .torrent
|
||||
if item.url: url_stat = True
|
||||
|
||||
if not item.url and item.torrent_alt: #Si hay error, se busca un .torrent alternativo
|
||||
item.url = item.torrent_alt #El .torrent alternativo puede estar en una url o en local
|
||||
|
||||
#Si es un archivo .torrent local, actualizamos el path relativo a path absoluto
|
||||
if item.url.startswith("\\") or item.url.startswith("/") and not url_stat: #.torrent alternativo local
|
||||
movies = config.get_setting("folder_movies")
|
||||
series = config.get_setting("folder_tvshows")
|
||||
if item.contentType == 'movie':
|
||||
folder = movies #películas
|
||||
else:
|
||||
folder = series #o series
|
||||
item.url = filetools.join(videolibrary_path, folder, item.url) #dirección del .torrent local en la Videoteca
|
||||
|
||||
mediaurl = urllib.quote_plus(item.url)
|
||||
#Llamada con más parámetros para completar el título
|
||||
if ("quasar" in torrent_options[seleccion][1] or "elementum" in torrent_options[seleccion][1]) and item.infoLabels['tmdb_id']:
|
||||
|
||||
@@ -17,6 +17,7 @@ def update(path, p_dialog, i, t, serie, overwrite):
|
||||
insertados_total = 0
|
||||
|
||||
head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo')
|
||||
category = serie.category
|
||||
|
||||
# logger.debug("%s: %s" %(serie.contentSerieName,str(list_canales) ))
|
||||
for channel, url in serie.library_urls.items():
|
||||
@@ -28,6 +29,7 @@ def update(path, p_dialog, i, t, serie, overwrite):
|
||||
head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo') #Refresca el .nfo para recoger actualizaciones
|
||||
if it.emergency_urls:
|
||||
serie.emergency_urls = it.emergency_urls
|
||||
serie.category = category
|
||||
serie, it, overwrite = generictools.redirect_clone_newpct1(serie, head_nfo, it, path, overwrite)
|
||||
except:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user