Merge remote-tracking branch 'origin/master'

This commit is contained in:
Unknown
2018-06-24 17:33:56 +02:00
25 changed files with 1374 additions and 2323 deletions
+9 -7
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.alfa" name="Alfa" version="2.5.19" provider-name="Alfa Addon"> <addon id="plugin.video.alfa" name="Alfa" version="2.5.20" provider-name="Alfa Addon">
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.libtorrent" optional="true"/> <import addon="script.module.libtorrent" optional="true"/>
@@ -19,12 +19,14 @@
</assets> </assets>
<news>[B]Estos son los cambios para esta versión:[/B] <news>[B]Estos son los cambios para esta versión:[/B]
[COLOR green][B]Canales agregados y arreglos[/B][/COLOR] [COLOR green][B]Canales agregados y arreglos[/B][/COLOR]
» cinecalidad » animemovil » grantorrent » descargas2020
» seriesverde » animejl » torrentlocura » torrentrapid
» pelisipad » gmobi » tumejortorrent » tvsinpagar
» inkapelis » pelisgratis » mispelisyseries » kbagi
» pelispedia » animeyt » animemovil » pelismagnet
» qserie » pelisultra » seriesdanko
» seriespapaya » seriesverde
» ultrapeliculas » wikiseries
¤ arreglos internos ¤ arreglos internos
</news> </news>
+19 -18
View File
@@ -287,7 +287,6 @@ def findvideos(item):
strm_id = scrapertools.find_single_match(data, '"id": (.*?),') strm_id = scrapertools.find_single_match(data, '"id": (.*?),')
streams = scrapertools.find_single_match(data, '"stream": (.*?)};') streams = scrapertools.find_single_match(data, '"stream": (.*?)};')
dict_strm = jsontools.load(streams) dict_strm = jsontools.load(streams)
base_url = 'http:%s%s/' % (dict_strm['accessPoint'], strm_id) base_url = 'http:%s%s/' % (dict_strm['accessPoint'], strm_id)
for server in dict_strm['servers']: for server in dict_strm['servers']:
expire = dict_strm['expire'] expire = dict_strm['expire']
@@ -297,24 +296,26 @@ def findvideos(item):
strm_url = base_url +'%s?expire=%s&callback=%s&signature=%s&last_modify=%s' % (server, expire, callback, strm_url = base_url +'%s?expire=%s&callback=%s&signature=%s&last_modify=%s' % (server, expire, callback,
signature, last_modify) signature, last_modify)
try:
strm_data = httptools.downloadpage(strm_url).data strm_data = httptools.downloadpage(strm_url).data
strm_data = scrapertools.unescape(strm_data) strm_data = scrapertools.unescape(strm_data)
title = '%s' title = '%s'
language = '' language = ''
if server not in ['fire', 'meph']: if server not in ['fire', 'meph']:
urls = scrapertools.find_multiple_matches(strm_data, '"(?:file|src)"*?:.*?"(.*?)"') urls = scrapertools.find_multiple_matches(strm_data, '"(?:file|src)"*?:.*?"(.*?)"')
for url in urls: for url in urls:
if url != '':
url = url.replace ('\\/','/')
itemlist.append(Item(channel=item.channel, title=title, url=url, action='play'))
elif server in ['fire', 'mpeh']:
url = scrapertools.find_single_match(strm_data, 'xmlhttp.open(\"GET\", \"(.*?)\"')
if url != '': if url != '':
url = url.replace ('\\/','/') url = url.replace('\\/', '/')
itemlist.append(Item(channel=item.channel, title=title, url=url, action='play')) itemlist.append(Item(channel=item.channel, title=url, url=url, action='play'))
elif server in ['fire', 'mpeh']: else:
url = scrapertools.find_single_match(strm_data, 'xmlhttp.open(\"GET\", \"(.*?)\"') continue
if url != '': except:
url = url.replace('\\/', '/') pass
itemlist.append(Item(channel=item.channel, title=url, url=url, action='play'))
else:
continue
servertools.get_servers_itemlist(itemlist, lambda i: i.title % i.server) servertools.get_servers_itemlist(itemlist, lambda i: i.title % i.server)
+23 -3
View File
@@ -344,7 +344,7 @@ def start(itemlist, item):
return itemlist return itemlist
def init(channel, list_servers, list_quality): def init(channel, list_servers, list_quality, reset=False):
''' '''
Comprueba la existencia de canal en el archivo de configuracion de Autoplay y si no existe lo añade. Comprueba la existencia de canal en el archivo de configuracion de Autoplay y si no existe lo añade.
Es necesario llamar a esta funcion al entrar a cualquier canal que incluya la funcion Autoplay. Es necesario llamar a esta funcion al entrar a cualquier canal que incluya la funcion Autoplay.
@@ -360,6 +360,7 @@ def init(channel, list_servers, list_quality):
change = False change = False
result = True result = True
if not config.is_xbmc(): if not config.is_xbmc():
# platformtools.dialog_notification('AutoPlay ERROR', 'Sólo disponible para XBMC/Kodi') # platformtools.dialog_notification('AutoPlay ERROR', 'Sólo disponible para XBMC/Kodi')
result = False result = False
@@ -371,7 +372,7 @@ def init(channel, list_servers, list_quality):
change = True change = True
autoplay_node = {"AUTOPLAY": {}} autoplay_node = {"AUTOPLAY": {}}
if channel not in autoplay_node: if channel not in autoplay_node or reset:
change = True change = True
# Se comprueba que no haya calidades ni servidores duplicados # Se comprueba que no haya calidades ni servidores duplicados
@@ -573,9 +574,15 @@ def autoplay_config(item):
list_controls.append(set_priority) list_controls.append(set_priority)
dict_values["priority"] = settings_node.get("priority", 0) dict_values["priority"] = settings_node.get("priority", 0)
# Abrir cuadro de dialogo # Abrir cuadro de dialogo
platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, callback='save', platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, callback='save',
item=item, caption='%s - AutoPlay' % channel_name) item=item, caption='%s - AutoPlay' % channel_name,
custom_button={'visible': True,
'function': "reset",
'close': True,
'label': 'Reset'})
def save(item, dict_data_saved): def save(item, dict_data_saved):
@@ -654,3 +661,16 @@ def is_active():
settings_node = channel_node.get('settings', {}) settings_node = channel_node.get('settings', {})
return settings_node.get('active', False) return settings_node.get('active', False)
def reset(item, dict):
channel_name = item.from_channel
channel = __import__('channels.%s' % channel_name, fromlist=["channels.%s" % channel_name])
list_servers = channel.list_servers
list_quality = channel.list_quality
init(channel_name, list_servers, list_quality, reset=True)
platformtools.dialog_notification('AutoPlay', '%s: Los datos fueron reiniciados' % item.category)
return
+67 -295
View File
@@ -4,6 +4,7 @@ import re
import sys import sys
import urllib import urllib
import urlparse import urlparse
import datetime
from channelselector import get_thumb from channelselector import get_thumb
from core import httptools from core import httptools
@@ -12,6 +13,7 @@ from core import servertools
from core.item import Item from core.item import Item
from platformcode import config, logger from platformcode import config, logger
from core import tmdb from core import tmdb
from lib import generictools
host = 'http://descargas2020.com/' host = 'http://descargas2020.com/'
@@ -145,11 +147,7 @@ def listado(item):
clase = "pelilist" # etiqueta para localizar zona de listado de contenidos clase = "pelilist" # etiqueta para localizar zona de listado de contenidos
url_next_page ='' # Controlde paginación url_next_page ='' # Controlde paginación
cnt_tot = 30 # Poner el num. máximo de items por página cnt_tot = 30 # Poner el num. máximo de items por página
category = "" # Guarda la categoria que viene desde una busqueda global
if item.category:
category = item.category
del item.category
if item.totalItems: if item.totalItems:
del item.totalItems del item.totalItems
@@ -258,8 +256,10 @@ def listado(item):
del item_local.tipo del item_local.tipo
if item_local.totalItems: if item_local.totalItems:
del item_local.totalItems del item_local.totalItems
if item.post_num: if item_local.post_num:
del item.post_num del item_local.post_num
if item_local.category:
del item_local.category
item_local.title = '' item_local.title = ''
item_local.context = "['buscar_trailer']" item_local.context = "['buscar_trailer']"
@@ -336,8 +336,8 @@ def listado(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -347,7 +347,7 @@ def listado(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -403,65 +403,8 @@ def listado(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
if category == "newest": #Viene de Novedades. Marquemos el título con el nombre del canal
title += ' -%s-' % item_local.channel.capitalize()
if item_local.contentType == "movie":
item_local.contentTitle += ' -%s-' % item_local.channel.capitalize()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if len(itemlist) == 0: if len(itemlist) == 0:
itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado")) itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado"))
@@ -728,7 +671,7 @@ def listado_busqueda(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Esp", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -738,7 +681,7 @@ def listado_busqueda(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -868,64 +811,8 @@ def listado_busqueda(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
title += " -Serie-"
elif item_local.extra == "varios":
title += " -Varios-"
item_local.contentTitle += " -Varios-"
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + "[" + str(item_local.language) + "]" + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if post: if post:
itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag)) itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag))
@@ -1043,31 +930,6 @@ def findvideos(item):
verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?"
excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar
# Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal,
# con la función "play_from_library"
unify_status = False
try:
import xbmc
if xbmc.getCondVisibility('Window.IsMedia') == 1:
unify_status = config.get_setting("unify")
except:
unify_status = config.get_setting("unify")
#Salvamos la información de max num. de episodios por temporada para despues de TMDB
if item.infoLabels['temporada_num_episodios']:
num_episodios = item.infoLabels['temporada_num_episodios']
else:
num_episodios = 1
# Obtener la información actualizada del Episodio, si no la hay
if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'):
tmdb.set_infoLabels(item, __modo_grafico__)
elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary":
tmdb.set_infoLabels(item, __modo_grafico__)
#Restauramos la información de max num. de episodios por temporada despues de TMDB
if item.infoLabels['temporada_num_episodios'] and num_episodios > item.infoLabels['temporada_num_episodios']:
item.infoLabels['temporada_num_episodios'] = num_episodios
# Descarga la página # Descarga la página
try: try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data) data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
@@ -1081,17 +943,15 @@ def findvideos(item):
#Añadimos el tamaño para todos #Añadimos el tamaño para todos
size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>') size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>')
size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra
item.quality = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía if not size:
if size: size = scrapertools.find_single_match(item.quality, '\s\[(\d+,?\d*?\s\w[b|B])\]')
item.title = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.title) #Quitamos size de título, si lo traía else:
item.title = '%s [%s]' % (item.title, size) #Agregamos size al final del título 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
item.quality = re.sub(r'\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía
#Limpiamos de año y rating de episodios #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
if item.infoLabels['episodio_titulo']: item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
item.infoLabels['episodio_titulo'] = re.sub(r'\s?\[.*?\]', '', item.infoLabels['episodio_titulo'])
item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '')
if item.infoLabels['aired'] and item.contentType == "episode":
item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})')
#Generamos una copia de Item para trabajar sobre ella #Generamos una copia de Item para trabajar sobre ella
item_local = item.clone() item_local = item.clone()
@@ -1100,57 +960,29 @@ def findvideos(item):
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";'
item_local.url = scrapertools.find_single_match(data, patron) item_local.url = scrapertools.find_single_match(data, patron)
if not item_local.url: #error if not item_local.url: #error
logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) 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: Ha cambiado la estructura de la Web. Reportar el error con el log')) 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 return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
item_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso 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("Patron: " + patron + " url: " + item_local.url)
#logger.debug(data) #logger.debug(data)
#Pintamos el pseudo-título con toda la información disponible del vídeo
item_local.action = ""
item_local.server = "torrent"
rating = '' #Ponemos el rating
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
if item_local.contentType == "episode":
title = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2))
if item_local.infoLabels['temporada_num_episodios']:
title = '%s (de %s)' % (title, str(item_local.infoLabels['temporada_num_episodios']))
title = '%s %s' % (title, item_local.infoLabels['episodio_titulo'])
title_gen = '%s, %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR] [%s]' % (title, item_local.contentSerieName, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language), size)
else:
title = item_local.title
title_gen = title
title_gen = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title_gen).strip() #Quitamos etiquetas vacías
title_gen = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title_gen).strip() #Quitamos colores vacíos
title_gen = title_gen.replace(" []", "").strip() #Quitamos etiquetas vacías
if not unify_status: #Si Titulos Inteligentes NO seleccionados:
title_gen = '**- [COLOR gold]Enlaces Ver: [/COLOR]%s[COLOR gold] -**[/COLOR]' % (title_gen)
else:
title_gen = '[COLOR gold]Enlaces Ver: [/COLOR]%s' % (title_gen)
if config.get_setting("quit_channel_name", "videolibrary") == 1 and item_local.contentChannel == "videolibrary":
title_gen = '%s: %s' % (item_local.channel.capitalize(), title_gen)
itemlist.append(item_local.clone(title=title_gen)) #Título con todos los datos del vídeo
#Ahora pintamos el link del Torrent, si lo hay #Ahora pintamos el link del Torrent, si lo hay
if item_local.url: # Hay Torrent ? if item_local.url: # Hay Torrent ?
item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos
item_local.alive = "??" #Calidad del link sin verificar item_local.alive = "??" #Calidad del link sin verificar
item_local.action = "play" #Visualizar vídeo item_local.action = "play" #Visualizar vídeo
item_local.server = "torrent" #Servidor
if size:
quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final del título
else:
quality = item_local.quality
itemlist.append(item_local.clone()) #Pintar pantalla itemlist.append(item_local.clone(quality=quality)) #Pintar pantalla
logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + title_gen + " / " + title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName)
#logger.debug(item_local) #logger.debug(item_local)
# VER vídeos, descargar vídeos un link, o múltiples links # VER vídeos, descargar vídeos un link, o múltiples links
@@ -1236,7 +1068,7 @@ def findvideos(item):
if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0: if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0:
#Pintamos un pseudo-título de Descargas #Pintamos un pseudo-título de Descargas
if not unify_status: #Si Titulos Inteligentes NO seleccionados: if not item.unify: #Si Titulos Inteligentes NO seleccionados:
itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action=""))
else: else:
itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action=""))
@@ -1261,7 +1093,7 @@ def findvideos(item):
#Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace #Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace
p = 1 p = 1
for enlace in partes: for enlace in partes:
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
else: else:
parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
@@ -1303,12 +1135,12 @@ def findvideos(item):
break #Si se ha agotado el contador de verificación, se sale de "Enlace" break #Si se ha agotado el contador de verificación, se sale de "Enlace"
if item_local.alive == "??": #dudoso if item_local.alive == "??": #dudoso
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title) parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title)
else: else:
parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title)
elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title) parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title)
else: else:
parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title)
@@ -1377,7 +1209,7 @@ def episodios(item):
list_pages = [item.url] list_pages = [item.url]
season = max_temp season = max_temp
if item.library_playcounts: #Comprobamos si realmente sabemos el num. máximo de temporadas if item.library_playcounts or item.tmdb_stat: #Comprobamos si realmente sabemos el num. máximo de temporadas
num_temporadas_flag = True num_temporadas_flag = True
else: else:
num_temporadas_flag = False num_temporadas_flag = False
@@ -1441,10 +1273,15 @@ def episodios(item):
if scrapertools.find_single_match(info, '\[\d{3}\]'): if scrapertools.find_single_match(info, '\[\d{3}\]'):
info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info) info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info)
elif scrapertools.find_single_match(info, 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'):
pattern = 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'
elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'): elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'):
info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info) info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info)
elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'): elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'):
info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info) info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info)
elif "completa" in info.lower():
info = info.replace("COMPLETA", "Caps. 01_99")
pattern = 'Temp.*?(?P<season>\d+).*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<quality>.*?)\].*?\[(?P<lang>\w+)\]?'
if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'): if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'):
pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \ pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \
"(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?" "(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?"
@@ -1475,15 +1312,18 @@ def episodios(item):
except: except:
logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches))
#logger.error("TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / " + str(match['episode2']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1: if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1:
#Si el num de temporada está fuera de control, se trata pone en num. de temporada actual #Si el num de temporada está fuera de control, se trata pone en num. de temporada actual
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) #logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern + " / MATCHES: " + str(matches))
#logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
match['season'] = season match['season'] = season
item_local.contentSeason = season item_local.contentSeason = season
else: else:
item_local.contentSeason = match['season'] item_local.contentSeason = match['season']
season = match['season'] season = match['season']
num_temporadas_flag = True if match['episode'] > 0:
num_temporadas_flag = True
if season > max_temp: if season > max_temp:
max_temp = season max_temp = season
@@ -1496,13 +1336,14 @@ def episodios(item):
item_local.infoLabels['episodio_titulo'] = match['lang'] item_local.infoLabels['episodio_titulo'] = match['lang']
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo'] item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.contentEpisodeNumber = match['episode']
if match['episode'] == 0: match['episode'] = 1 #Evitar errores en Videoteca
if match["episode2"]: #Hay episodio dos? es una entrada múltiple? if match["episode2"]: #Hay episodio dos? es una entrada múltiple?
item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios
else: #Si es un solo episodio, se formatea ya else: #Si es un solo episodio, se formatea ya
item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2)) item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2))
item_local.contentEpisodeNumber = match['episode']
if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca
if item_local.contentSeason < max_temp: if item_local.contentSeason < max_temp:
list_pages = [] #Sale del bucle de leer páginas list_pages = [] #Sale del bucle de leer páginas
@@ -1541,93 +1382,24 @@ def episodios(item):
# Pasada por TMDB y clasificación de lista por temporada y episodio # Pasada por TMDB y clasificación de lista por temporada y episodio
tmdb.set_infoLabels(itemlist, True) tmdb.set_infoLabels(itemlist, True)
# Pasada para maqullaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
num_episodios = 1 item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
num_episodios_lista = []
for i in range(0, 50): num_episodios_lista += [0]
num_temporada = 1
num_temporada_max = 99
num_episodios_flag = True
for item_local in itemlist:
# Si no hay datos de TMDB, pongo los datos locales que conozco
if item_local.infoLabels['aired']:
item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})')
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Salvamos en número de episodios de la temporada
if item_local.infoLabels['number_of_seasons']:
#Si el num de temporada está fuera de control, se pone 0, y se reclasifica itemlist
if item_local.contentSeason > item_local.infoLabels['number_of_seasons'] + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(item_local.infoLabels['number_of_seasons']) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
else:
num_temporada_max = item_local.infoLabels['number_of_seasons']
else:
if item_local.contentSeason > num_temporada_max + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
if num_temporada != item_local.contentSeason:
num_temporada = item_local.contentSeason
num_episodios = 0
if item_local.infoLabels['temporada_num_episodios']:
num_episodios = item_local.infoLabels['temporada_num_episodios']
#Preparamos el título para que sea compatible con Añadir Serie a Videoteca
if item_local.infoLabels['episodio_titulo']:
if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName)
else:
item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo'])
if item_local.infoLabels['year']:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.infoLabels['year'])
if rating:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], rating)
else:
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.contentSerieName, item_local.infoLabels['year'], rating)
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.title = '%s [%s] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.title, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language))
#Quitamos campos vacíos
item_local.infoLabels['episodio_titulo'] = item_local.infoLabels['episodio_titulo'].replace(" []", "").strip()
item_local.title = item_local.title.replace(" []", "").strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]-\[\/COLOR\]', '', item_local.title).strip()
if num_episodios < item_local.contentEpisodeNumber:
num_episodios = item_local.contentEpisodeNumber
if num_episodios and not item_local.infoLabels['temporada_num_episodios']:
item_local.infoLabels['temporada_num_episodios'] = num_episodios
num_episodios_flag = False
num_episodios_lista[item_local.contentSeason] = [num_episodios]
#logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag))
#logger.debug(item_local)
try:
if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie
for item_local in itemlist:
item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason]
except:
logger.error("ERROR 07: EPISODIOS: Num de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
if config.get_videolibrary_support() and len(itemlist) > 0:
title = ''
if item_local.infoLabels['temporada_num_episodios']:
title = ' [Temp. de %s ep.]' % item_local.infoLabels['temporada_num_episodios']
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta serie a la videoteca[/COLOR]" + title, action="add_serie_to_library", extra="episodios"))
return itemlist return itemlist
def actualizar_titulos(item):
logger.info()
itemlist = []
from platformcode import launcher
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 launcher.run(item)
def search(item, texto): def search(item, texto):
logger.info("search:" + texto) logger.info("search:" + texto)
# texto = texto.replace(" ", "+") # texto = texto.replace(" ", "+")
+29 -228
View File
@@ -12,6 +12,7 @@ from core import servertools
from core.item import Item from core.item import Item
from platformcode import config, logger from platformcode import config, logger
from core import tmdb from core import tmdb
from lib import generictools
host = "https://grantorrent.net/" host = "https://grantorrent.net/"
@@ -320,46 +321,8 @@ def listado(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season":
item_local.contentTitle= ''
if scrapertools.find_single_match(item_local.url, '-(\d+)x'):
title = '%s -Temporada %s' % (title, scrapertools.find_single_match(item_local.url, '-(\d+)x'))
if scrapertools.find_single_match(item_local.url, '-temporadas?-(\d+)'):
title = '%s -Temporada %s' % (title, scrapertools.find_single_match(item_local.url, '-temporadas?-(\d+)'))
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteligentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
item_local.title = title
#logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + "[" + str(item_local.language) + "]" + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
#Gestionamos el paginador #Gestionamos el paginador
patron = '<div class="nav-links">.*?<a class="next page.*?href="(.*?)"' patron = '<div class="nav-links">.*?<a class="next page.*?href="(.*?)"'
@@ -385,38 +348,6 @@ def findvideos(item):
logger.info() logger.info()
itemlist = [] itemlist = []
# Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal,
# con la función "play_from_library"
unify_status = False
try:
import xbmc
if xbmc.getCondVisibility('Window.IsMedia') == 1:
unify_status = config.get_setting("unify")
except:
unify_status = config.get_setting("unify")
#Salvamos la información de max num. de episodios por temporada para despues de TMDB
if item.infoLabels['temporada_num_episodios']:
num_episodios = item.infoLabels['temporada_num_episodios']
else:
num_episodios = 1
# Obtener la información actualizada del Episodio, si no la hay
if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'):
tmdb.set_infoLabels(item, __modo_grafico__)
elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary":
tmdb.set_infoLabels(item, __modo_grafico__)
#Restauramos la información de max num. de episodios por temporada despues de TMDB
if item.infoLabels['temporada_num_episodios'] and num_episodios > item.infoLabels['temporada_num_episodios']:
item.infoLabels['temporada_num_episodios'] = num_episodios
#Limpiamos de año y rating de episodios
if item.infoLabels['episodio_titulo']:
item.infoLabels['episodio_titulo'] = re.sub(r'\s?\[.*?\]', '', item.infoLabels['episodio_titulo'])
item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(' - ' + item.contentSerieName, '')
if item.infoLabels['aired'] and item.contentType == "episode":
item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})')
#Bajamos los datos de la página #Bajamos los datos de la página
try: try:
data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data)
@@ -430,53 +361,16 @@ def findvideos(item):
patron = '\/icono_.*?png" title="(?P<lang>.*?)?" [^>]+><\/td><td>(?P<quality>.*?)?<?\/td>.*?<td>(?P<size>.*?)?<\/td><td><a class="link" href="(?P<url>.*?)?"' 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) matches = re.compile(patron, re.DOTALL).findall(data)
if not matches: #error if not matches: #error
logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) 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: Ha cambiado la estructura de la Web. Reportar el error con el log')) 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 return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
#logger.debug("PATRON: " + patron) #logger.debug("PATRON: " + patron)
#logger.debug(matches) #logger.debug(matches)
#logger.debug(data) #logger.debug(data)
#Generamos una copia de Item para trabajar sobre ella #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
item_local = item.clone() item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
#Pintamos el pseudo-título con toda la información disponible del vídeo
item_local.action = ""
item_local.server = "torrent"
rating = '' #Ponemos el rating
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Pintamos el pseudo-título con toda la información disponible del vídeo
item_local.action = ""
item_local.server = "torrent"
if item_local.contentType == "episode":
title = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2))
if item_local.infoLabels['temporada_num_episodios']:
title = '%s (de %s)' % (title, str(item_local.infoLabels['temporada_num_episodios']))
title = '%s %s' % (title, item_local.infoLabels['episodio_titulo'])
title_gen = '%s, %s [COLOR yellow][%s][/COLOR] [%s] [COLOR red]%s[/COLOR]' % (title, item_local.contentSerieName, item_local.infoLabels['year'], rating, str(item_local.language))
else:
title = item_local.contentTitle
title_gen = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR red]%s[/COLOR]' % (title, item_local.infoLabels['year'], rating, str(item_local.language))
title_gen = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title_gen).strip() #Quitamos etiquetas vacías
title_gen = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title_gen).strip() #Quitamos colores vacíos
title_gen = title_gen.replace(" []", "").strip() #Quitamos etiquetas vacías
if not unify_status: #Si Titulos Inteligentes NO seleccionados:
title_gen = '**- [COLOR gold]Enlaces Ver: [/COLOR]%s[COLOR gold] -**[/COLOR]' % (title_gen)
else:
title_gen = '[COLOR gold]Enlaces Ver: [/COLOR]%s' % (title_gen)
if config.get_setting("quit_channel_name", "videolibrary") == 1 and item_local.contentChannel == "videolibrary":
title_gen = '%s: %s' % (item_local.channel.capitalize(), title_gen)
itemlist.append(item_local.clone(title=title_gen)) #Título con todos los datos del vídeo
#Ahora recorremos todos los links por calidades #Ahora recorremos todos los links por calidades
for lang, quality, size, scrapedurl in matches: for lang, quality, size, scrapedurl in matches:
@@ -552,7 +446,7 @@ def findvideos(item):
itemlist.append(item_local.clone()) #Pintar pantalla itemlist.append(item_local.clone()) #Pintar pantalla
logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + title_gen + " / " + title + " / calidad: " + item_local.quality) logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality)
#logger.debug(item_local) #logger.debug(item_local)
return itemlist return itemlist
@@ -805,7 +699,7 @@ def episodios(item):
item_local.language[0:0] = ["DUAL"] item_local.language[0:0] = ["DUAL"]
try: try:
if "temporada" in temp_epi.lower(): #si es una temporada en vez de un episodio, lo aceptamos como episodio 1 if "temporada" in temp_epi.lower() or "completa" in temp_epi.lower(): #si es una temporada en vez de un episodio, lo aceptamos como episodio 1
item_local.contentSeason = scrapertools.find_single_match(temp_epi, r'[t|T]emporada.*?(\d+)') item_local.contentSeason = scrapertools.find_single_match(temp_epi, r'[t|T]emporada.*?(\d+)')
if not item_local.contentSeason: if not item_local.contentSeason:
item_local.contentSeason = temp_actual_num item_local.contentSeason = temp_actual_num
@@ -833,14 +727,15 @@ def episodios(item):
if "-" in temp_epi: #episodios múltiples if "-" in temp_epi: #episodios múltiples
episode2 = scrapertools.find_single_match(temp_epi, r'-(\d+)') episode2 = scrapertools.find_single_match(temp_epi, r'-(\d+)')
item_local.title = "%sx%s al %s -" % (item_local.contentSeason, str(item_local.contentEpisodeNumber).zfill(2), str(episode2).zfill(2)) #Creamos un título con el rango de episodios item_local.title = "%sx%s al %s -" % (item_local.contentSeason, str(item_local.contentEpisodeNumber).zfill(2), str(episode2).zfill(2)) #Creamos un título con el rango de episodios
elif "temporada" in temp_epi.lower(): #Temporada completa elif "temporada" in temp_epi.lower() or "completa" in temp_epi.lower(): #Temporada completa
item_local.title = '%sx%s - Temporada %s Completa -' % (item_local.contentSeason, str(item_local.contentEpisodeNumber).zfill(2), item_local.contentSeason) episode2 = 99
item_local.title = "%sx%s al %s -" % (item_local.contentSeason, str(item_local.contentEpisodeNumber).zfill(2), str(episode2).zfill(2)) #Creamos un título con el rango ficticio de episodios
elif item_local.contentEpisodeNumber == 0: #episodio extraño elif item_local.contentEpisodeNumber == 0: #episodio extraño
item_local.title = '%sx%s - %s' % (item_local.contentSeason, str(item_local.contentEpisodeNumber).zfill(2), temp_epi) item_local.title = '%sx%s - %s' % (item_local.contentSeason, str(item_local.contentEpisodeNumber).zfill(2), temp_epi)
else: #episodio normal else: #episodio normal
item_local.title = '%sx%s -' % (item_local.contentSeason, str(item_local.contentEpisodeNumber).zfill(2)) item_local.title = '%sx%s -' % (item_local.contentSeason, str(item_local.contentEpisodeNumber).zfill(2))
if len(itemlist) > 0 and item_local.contentSeason == itemlist[-1].contentSeason and item_local.contentEpisodeNumber == itemlist[-1].contentEpisodeNumber and not "Temporada" in itemlist[-1].title and itemlist[-1].contentEpisodeNumber != 0: #solo guardamos un episodio ... if len(itemlist) > 0 and item_local.contentSeason == itemlist[-1].contentSeason and item_local.contentEpisodeNumber == itemlist[-1].contentEpisodeNumber and item_local.title == itemlist[-1].title and itemlist[-1].contentEpisodeNumber != 0: #solo guardamos un episodio ...
if itemlist[-1].quality: if itemlist[-1].quality:
itemlist[-1].quality += ", " + quality #... pero acumulamos las calidades itemlist[-1].quality += ", " + quality #... pero acumulamos las calidades
else: else:
@@ -864,126 +759,32 @@ def episodios(item):
data = '' #Limpiamos data para forzar la lectura en la próxima pasada data = '' #Limpiamos data para forzar la lectura en la próxima pasada
item.contentSeason_save = contentSeason #Guardamos temporalemente este contador
if len(itemlist) > 1: if len(itemlist) > 1:
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) #clasificamos 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 # Pasada por TMDB y clasificación de lista por temporada y episodio
tmdb.set_infoLabels(itemlist, True) tmdb.set_infoLabels(itemlist, True)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
num_episodios = 1 item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
num_episodios_lista = []
for i in range(0, 50): num_episodios_lista += [0]
num_temporada = 1
num_temporada_max = 99
num_episodios_flag = True
for item_local in itemlist:
# Si no hay datos de TMDB, pongo los datos locales que conozco
if item_local.infoLabels['aired']:
item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})')
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Salvamos en número de episodios de la temporada
if item_local.infoLabels['number_of_seasons']:
#Si el num de temporada está fuera de control, se pone 0, y se reclasifica itemlist
if item_local.contentSeason > item_local.infoLabels['number_of_seasons'] + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(item_local.infoLabels['number_of_seasons']) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
else:
num_temporada_max = item_local.infoLabels['number_of_seasons']
else:
if item_local.contentSeason > num_temporada_max + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
if num_temporada != item_local.contentSeason:
num_temporada = item_local.contentSeason
num_episodios = 0
if item_local.infoLabels['temporada_num_episodios']:
num_episodios = item_local.infoLabels['temporada_num_episodios']
#Preparamos el título para que sea compatible con Añadir Serie a Videoteca
if item_local.infoLabels['episodio_titulo'] and not "Temporada" in item_local.title:
if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName)
else:
item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo'])
if item_local.infoLabels['year']:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.infoLabels['year'])
if rating:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], rating)
else:
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
if "Temporada" in item_local.title:
item_local.infoLabels['episodio_titulo'] = '%s - %s [%s] [%s]' % (scrapertools.find_single_match(item_local.title, r'(Temporada \d+ Completa)'), item_local.contentSerieName, item_local.infoLabels['year'], rating)
else:
item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.contentSerieName, item_local.infoLabels['year'], rating)
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.title = '%s [%s] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.title, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language))
#Quitamos campos vacíos
item_local.infoLabels['episodio_titulo'] = item_local.infoLabels['episodio_titulo'].replace(" []", "").strip()
item_local.title = item_local.title.replace(" []", "").strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]-\[\/COLOR\]', '', item_local.title).strip()
#logger.debug(str(num_episodios) + " / " + str(item_local.contentEpisodeNumber) + " / " + str(item_local.infoLabels['temporada_num_episodios']) + str(num_episodios_lista))
if num_episodios < item_local.contentEpisodeNumber:
num_episodios = item_local.contentEpisodeNumber
if num_episodios and not item_local.infoLabels['temporada_num_episodios']:
item_local.infoLabels['temporada_num_episodios'] = num_episodios
num_episodios_flag = False
num_episodios_lista[item_local.contentSeason] = [num_episodios]
#logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag))
#logger.debug(item_local)
try:
if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie
for item_local in itemlist:
item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason]
except:
logger.error("ERROR 07: EPISODIOS: Num de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
if config.get_videolibrary_support() and len(itemlist) > 0:
title = ''
if item_local.infoLabels['temporada_num_episodios']:
title = ' [Temp. de %s ep.]' % item_local.infoLabels['temporada_num_episodios']
if item_local.quality: #La Videoteca no toma la calidad del episodio, sino de la serie. Pongo del episodio
item.quality = item_local.quality
if item.action == 'get_seasons': #si es actualización de videoteca, título estándar
#Si hay una nueva Temporada, se activa como la actual
if item.library_urls[item.channel] != item.url and (item.contentType == "season" or modo_ultima_temp):
item.library_urls[item.channel] = item.url #Se actualiza la url apuntando a la última Temporada
try:
from core import videolibrarytools #Se fuerza la actualización de la url en el .nfo
itemlist_fake = [] #Se crea un Itemlist vacio para actualizar solo el .nfo
videolibrarytools.save_tvshow(item, itemlist_fake) #Se actualiza el .nfo
except:
logger.error("ERROR 08: EPISODIOS: No se ha podido actualizar la URL a la nueva Temporada")
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a la Videoteca[/COLOR]" + title, action="add_serie_to_library"))
elif modo_serie_temp == 1: #si es Serie damos la opción de guardar la última temporada o la serie completa
itemlist.append(item.clone(title="[COLOR yellow]Añadir última Temp. a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="season", contentSeason=contentSeason, url=item_local.url))
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="tvshow"))
else: #si no, damos la opción de guardar la temporada actual o la serie completa
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="tvshow"))
item.contentSeason = contentSeason
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Temp. a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="season", contentSeason=contentSeason))
return itemlist return itemlist
def actualizar_titulos(item):
logger.info()
itemlist = []
from platformcode import launcher
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 launcher.run(item)
def search(item, texto): def search(item, texto):
logger.info("texto:" + texto) logger.info("texto:" + texto)
texto = texto.replace(" ", "+") texto = texto.replace(" ", "+")
+6 -4
View File
@@ -35,6 +35,8 @@ def login(pagina):
dom = pagina.split(".")[0] dom = pagina.split(".")[0]
user = config.get_setting("%suser" %dom, "kbagi") user = config.get_setting("%suser" %dom, "kbagi")
password = config.get_setting("%spassword" %dom, "kbagi") password = config.get_setting("%spassword" %dom, "kbagi")
if "kbagi" in pagina:
pagina = "k-bagi.com"
if not user: if not user:
return False, "Para ver los enlaces de %s es necesario registrarse en %s" %(dom, pagina) return False, "Para ver los enlaces de %s es necesario registrarse en %s" %(dom, pagina)
data = httptools.downloadpage("http://%s" % pagina).data data = httptools.downloadpage("http://%s" % pagina).data
@@ -65,14 +67,14 @@ def mainlist(item):
if not logueado: if not logueado:
itemlist.append(item.clone(title=error_message, action="configuracion", folder=False)) itemlist.append(item.clone(title=error_message, action="configuracion", folder=False))
else: else:
item.extra = "http://kbagi.com" item.extra = "http://k-bagi.com"
itemlist.append(item.clone(title="kbagi", action="", text_color=color2)) itemlist.append(item.clone(title="kbagi", action="", text_color=color2))
itemlist.append( itemlist.append(
item.clone(title=" Búsqueda", action="search", url="http://kbagi.com/action/SearchFiles")) item.clone(title=" Búsqueda", action="search", url="http://k-bagi.com/action/SearchFiles"))
itemlist.append(item.clone(title=" Colecciones", action="colecciones", itemlist.append(item.clone(title=" Colecciones", action="colecciones",
url="http://kbagi.com/action/home/MoreNewestCollections?pageNumber=1")) url="http://k-bagi.com/action/home/MoreNewestCollections?pageNumber=1"))
itemlist.append(item.clone(title=" Búsqueda personalizada", action="filtro", itemlist.append(item.clone(title=" Búsqueda personalizada", action="filtro",
url="http://kbagi.com/action/SearchFiles")) url="http://k-bagi.com/action/SearchFiles"))
itemlist.append(item.clone(title=" Mi cuenta", action="cuenta")) itemlist.append(item.clone(title=" Mi cuenta", action="cuenta"))
logueado, error_message = login("diskokosmiko.mx") logueado, error_message = login("diskokosmiko.mx")
if not logueado: if not logueado:
+67 -295
View File
@@ -4,6 +4,7 @@ import re
import sys import sys
import urllib import urllib
import urlparse import urlparse
import datetime
from channelselector import get_thumb from channelselector import get_thumb
from core import httptools from core import httptools
@@ -12,6 +13,7 @@ from core import servertools
from core.item import Item from core.item import Item
from platformcode import config, logger from platformcode import config, logger
from core import tmdb from core import tmdb
from lib import generictools
host = 'http://mispelisyseries.com/' host = 'http://mispelisyseries.com/'
@@ -145,11 +147,7 @@ def listado(item):
clase = "pelilist" # etiqueta para localizar zona de listado de contenidos clase = "pelilist" # etiqueta para localizar zona de listado de contenidos
url_next_page ='' # Controlde paginación url_next_page ='' # Controlde paginación
cnt_tot = 30 # Poner el num. máximo de items por página cnt_tot = 30 # Poner el num. máximo de items por página
category = "" # Guarda la categoria que viene desde una busqueda global
if item.category:
category = item.category
del item.category
if item.totalItems: if item.totalItems:
del item.totalItems del item.totalItems
@@ -258,8 +256,10 @@ def listado(item):
del item_local.tipo del item_local.tipo
if item_local.totalItems: if item_local.totalItems:
del item_local.totalItems del item_local.totalItems
if item.post_num: if item_local.post_num:
del item.post_num del item_local.post_num
if item_local.category:
del item_local.category
item_local.title = '' item_local.title = ''
item_local.context = "['buscar_trailer']" item_local.context = "['buscar_trailer']"
@@ -336,8 +336,8 @@ def listado(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -347,7 +347,7 @@ def listado(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -403,65 +403,8 @@ def listado(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
if category == "newest": #Viene de Novedades. Marquemos el título con el nombre del canal
title += ' -%s-' % item_local.channel.capitalize()
if item_local.contentType == "movie":
item_local.contentTitle += ' -%s-' % item_local.channel.capitalize()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if len(itemlist) == 0: if len(itemlist) == 0:
itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado")) itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado"))
@@ -728,7 +671,7 @@ def listado_busqueda(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Esp", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -738,7 +681,7 @@ def listado_busqueda(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -868,64 +811,8 @@ def listado_busqueda(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
title += " -Serie-"
elif item_local.extra == "varios":
title += " -Varios-"
item_local.contentTitle += " -Varios-"
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + "[" + str(item_local.language) + "]" + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if post: if post:
itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag)) itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag))
@@ -1043,31 +930,6 @@ def findvideos(item):
verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?"
excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar
# Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal,
# con la función "play_from_library"
unify_status = False
try:
import xbmc
if xbmc.getCondVisibility('Window.IsMedia') == 1:
unify_status = config.get_setting("unify")
except:
unify_status = config.get_setting("unify")
#Salvamos la información de max num. de episodios por temporada para despues de TMDB
if item.infoLabels['temporada_num_episodios']:
num_episodios = item.infoLabels['temporada_num_episodios']
else:
num_episodios = 1
# Obtener la información actualizada del Episodio, si no la hay
if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'):
tmdb.set_infoLabels(item, __modo_grafico__)
elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary":
tmdb.set_infoLabels(item, __modo_grafico__)
#Restauramos la información de max num. de episodios por temporada despues de TMDB
if item.infoLabels['temporada_num_episodios'] and num_episodios > item.infoLabels['temporada_num_episodios']:
item.infoLabels['temporada_num_episodios'] = num_episodios
# Descarga la página # Descarga la página
try: try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data) data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
@@ -1081,17 +943,15 @@ def findvideos(item):
#Añadimos el tamaño para todos #Añadimos el tamaño para todos
size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>') size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>')
size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra
item.quality = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía if not size:
if size: size = scrapertools.find_single_match(item.quality, '\s\[(\d+,?\d*?\s\w[b|B])\]')
item.title = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.title) #Quitamos size de título, si lo traía else:
item.title = '%s [%s]' % (item.title, size) #Agregamos size al final del título 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
item.quality = re.sub(r'\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía
#Limpiamos de año y rating de episodios #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
if item.infoLabels['episodio_titulo']: item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
item.infoLabels['episodio_titulo'] = re.sub(r'\s?\[.*?\]', '', item.infoLabels['episodio_titulo'])
item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '')
if item.infoLabels['aired'] and item.contentType == "episode":
item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})')
#Generamos una copia de Item para trabajar sobre ella #Generamos una copia de Item para trabajar sobre ella
item_local = item.clone() item_local = item.clone()
@@ -1100,57 +960,29 @@ def findvideos(item):
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";'
item_local.url = scrapertools.find_single_match(data, patron) item_local.url = scrapertools.find_single_match(data, patron)
if not item_local.url: #error if not item_local.url: #error
logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) 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: Ha cambiado la estructura de la Web. Reportar el error con el log')) 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 return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
item_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso 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("Patron: " + patron + " url: " + item_local.url)
#logger.debug(data) #logger.debug(data)
#Pintamos el pseudo-título con toda la información disponible del vídeo
item_local.action = ""
item_local.server = "torrent"
rating = '' #Ponemos el rating
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
if item_local.contentType == "episode":
title = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2))
if item_local.infoLabels['temporada_num_episodios']:
title = '%s (de %s)' % (title, str(item_local.infoLabels['temporada_num_episodios']))
title = '%s %s' % (title, item_local.infoLabels['episodio_titulo'])
title_gen = '%s, %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR] [%s]' % (title, item_local.contentSerieName, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language), size)
else:
title = item_local.title
title_gen = title
title_gen = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title_gen).strip() #Quitamos etiquetas vacías
title_gen = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title_gen).strip() #Quitamos colores vacíos
title_gen = title_gen.replace(" []", "").strip() #Quitamos etiquetas vacías
if not unify_status: #Si Titulos Inteligentes NO seleccionados:
title_gen = '**- [COLOR gold]Enlaces Ver: [/COLOR]%s[COLOR gold] -**[/COLOR]' % (title_gen)
else:
title_gen = '[COLOR gold]Enlaces Ver: [/COLOR]%s' % (title_gen)
if config.get_setting("quit_channel_name", "videolibrary") == 1 and item_local.contentChannel == "videolibrary":
title_gen = '%s: %s' % (item_local.channel.capitalize(), title_gen)
itemlist.append(item_local.clone(title=title_gen)) #Título con todos los datos del vídeo
#Ahora pintamos el link del Torrent, si lo hay #Ahora pintamos el link del Torrent, si lo hay
if item_local.url: # Hay Torrent ? if item_local.url: # Hay Torrent ?
item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos
item_local.alive = "??" #Calidad del link sin verificar item_local.alive = "??" #Calidad del link sin verificar
item_local.action = "play" #Visualizar vídeo item_local.action = "play" #Visualizar vídeo
item_local.server = "torrent" #Servidor
if size:
quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final del título
else:
quality = item_local.quality
itemlist.append(item_local.clone()) #Pintar pantalla itemlist.append(item_local.clone(quality=quality)) #Pintar pantalla
logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + title_gen + " / " + title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName)
#logger.debug(item_local) #logger.debug(item_local)
# VER vídeos, descargar vídeos un link, o múltiples links # VER vídeos, descargar vídeos un link, o múltiples links
@@ -1236,7 +1068,7 @@ def findvideos(item):
if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0: if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0:
#Pintamos un pseudo-título de Descargas #Pintamos un pseudo-título de Descargas
if not unify_status: #Si Titulos Inteligentes NO seleccionados: if not item.unify: #Si Titulos Inteligentes NO seleccionados:
itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action=""))
else: else:
itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action=""))
@@ -1261,7 +1093,7 @@ def findvideos(item):
#Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace #Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace
p = 1 p = 1
for enlace in partes: for enlace in partes:
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
else: else:
parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
@@ -1303,12 +1135,12 @@ def findvideos(item):
break #Si se ha agotado el contador de verificación, se sale de "Enlace" break #Si se ha agotado el contador de verificación, se sale de "Enlace"
if item_local.alive == "??": #dudoso if item_local.alive == "??": #dudoso
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title) parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title)
else: else:
parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title)
elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title) parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title)
else: else:
parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title)
@@ -1377,7 +1209,7 @@ def episodios(item):
list_pages = [item.url] list_pages = [item.url]
season = max_temp season = max_temp
if item.library_playcounts: #Comprobamos si realmente sabemos el num. máximo de temporadas if item.library_playcounts or item.tmdb_stat: #Comprobamos si realmente sabemos el num. máximo de temporadas
num_temporadas_flag = True num_temporadas_flag = True
else: else:
num_temporadas_flag = False num_temporadas_flag = False
@@ -1441,10 +1273,15 @@ def episodios(item):
if scrapertools.find_single_match(info, '\[\d{3}\]'): if scrapertools.find_single_match(info, '\[\d{3}\]'):
info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info) info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info)
elif scrapertools.find_single_match(info, 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'):
pattern = 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'
elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'): elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'):
info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info) info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info)
elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'): elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'):
info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info) info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info)
elif "completa" in info.lower():
info = info.replace("COMPLETA", "Caps. 01_99")
pattern = 'Temp.*?(?P<season>\d+).*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<quality>.*?)\].*?\[(?P<lang>\w+)\]?'
if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'): if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'):
pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \ pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \
"(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?" "(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?"
@@ -1475,15 +1312,18 @@ def episodios(item):
except: except:
logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches))
#logger.error("TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / " + str(match['episode2']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1: if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1:
#Si el num de temporada está fuera de control, se trata pone en num. de temporada actual #Si el num de temporada está fuera de control, se trata pone en num. de temporada actual
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) #logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern + " / MATCHES: " + str(matches))
#logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
match['season'] = season match['season'] = season
item_local.contentSeason = season item_local.contentSeason = season
else: else:
item_local.contentSeason = match['season'] item_local.contentSeason = match['season']
season = match['season'] season = match['season']
num_temporadas_flag = True if match['episode'] > 0:
num_temporadas_flag = True
if season > max_temp: if season > max_temp:
max_temp = season max_temp = season
@@ -1496,13 +1336,14 @@ def episodios(item):
item_local.infoLabels['episodio_titulo'] = match['lang'] item_local.infoLabels['episodio_titulo'] = match['lang']
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo'] item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.contentEpisodeNumber = match['episode']
if match['episode'] == 0: match['episode'] = 1 #Evitar errores en Videoteca
if match["episode2"]: #Hay episodio dos? es una entrada múltiple? if match["episode2"]: #Hay episodio dos? es una entrada múltiple?
item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios
else: #Si es un solo episodio, se formatea ya else: #Si es un solo episodio, se formatea ya
item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2)) item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2))
item_local.contentEpisodeNumber = match['episode']
if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca
if item_local.contentSeason < max_temp: if item_local.contentSeason < max_temp:
list_pages = [] #Sale del bucle de leer páginas list_pages = [] #Sale del bucle de leer páginas
@@ -1541,93 +1382,24 @@ def episodios(item):
# Pasada por TMDB y clasificación de lista por temporada y episodio # Pasada por TMDB y clasificación de lista por temporada y episodio
tmdb.set_infoLabels(itemlist, True) tmdb.set_infoLabels(itemlist, True)
# Pasada para maqullaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
num_episodios = 1 item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
num_episodios_lista = []
for i in range(0, 50): num_episodios_lista += [0]
num_temporada = 1
num_temporada_max = 99
num_episodios_flag = True
for item_local in itemlist:
# Si no hay datos de TMDB, pongo los datos locales que conozco
if item_local.infoLabels['aired']:
item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})')
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Salvamos en número de episodios de la temporada
if item_local.infoLabels['number_of_seasons']:
#Si el num de temporada está fuera de control, se pone 0, y se reclasifica itemlist
if item_local.contentSeason > item_local.infoLabels['number_of_seasons'] + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(item_local.infoLabels['number_of_seasons']) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
else:
num_temporada_max = item_local.infoLabels['number_of_seasons']
else:
if item_local.contentSeason > num_temporada_max + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
if num_temporada != item_local.contentSeason:
num_temporada = item_local.contentSeason
num_episodios = 0
if item_local.infoLabels['temporada_num_episodios']:
num_episodios = item_local.infoLabels['temporada_num_episodios']
#Preparamos el título para que sea compatible con Añadir Serie a Videoteca
if item_local.infoLabels['episodio_titulo']:
if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName)
else:
item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo'])
if item_local.infoLabels['year']:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.infoLabels['year'])
if rating:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], rating)
else:
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.contentSerieName, item_local.infoLabels['year'], rating)
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.title = '%s [%s] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.title, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language))
#Quitamos campos vacíos
item_local.infoLabels['episodio_titulo'] = item_local.infoLabels['episodio_titulo'].replace(" []", "").strip()
item_local.title = item_local.title.replace(" []", "").strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]-\[\/COLOR\]', '', item_local.title).strip()
if num_episodios < item_local.contentEpisodeNumber:
num_episodios = item_local.contentEpisodeNumber
if num_episodios and not item_local.infoLabels['temporada_num_episodios']:
item_local.infoLabels['temporada_num_episodios'] = num_episodios
num_episodios_flag = False
num_episodios_lista[item_local.contentSeason] = [num_episodios]
#logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag))
#logger.debug(item_local)
try:
if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie
for item_local in itemlist:
item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason]
except:
logger.error("ERROR 07: EPISODIOS: Num de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
if config.get_videolibrary_support() and len(itemlist) > 0:
title = ''
if item_local.infoLabels['temporada_num_episodios']:
title = ' [Temp. de %s ep.]' % item_local.infoLabels['temporada_num_episodios']
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta serie a la videoteca[/COLOR]" + title, action="add_serie_to_library", extra="episodios"))
return itemlist return itemlist
def actualizar_titulos(item):
logger.info()
itemlist = []
from platformcode import launcher
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 launcher.run(item)
def search(item, texto): def search(item, texto):
logger.info("search:" + texto) logger.info("search:" + texto)
# texto = texto.replace(" ", "+") # texto = texto.replace(" ", "+")
+57 -38
View File
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re
import urlparse import urlparse
@@ -17,33 +17,33 @@ def mainlist(item):
itemlist = list() itemlist = list()
itemlist.append( #itemlist.append(
Item(channel=item.channel, action="lista", title="Top Películas", url=urlparse.urljoin(host, "top"))) # Item(channel=item.channel, action="lista", title="Top Películas", url=urlparse.urljoin(host, "top")))
itemlist.append(Item(channel=item.channel, action="lista", title="Novedades", url=host)) #itemlist.append(Item(channel=item.channel, action="lista", title="Novedades", url=host))
itemlist.append(Item(channel=item.channel, action="explorar", title="Género", url=urlparse.urljoin(host, "genero"))) itemlist.append(Item(channel=item.channel, action="explorar", title="Género", url=urlparse.urljoin(host, "genero")))
itemlist.append(Item(channel=item.channel, action="explorar", title="Listado Alfabético", #itemlist.append(Item(channel=item.channel, action="explorar", title="Listado Alfabético",
url=urlparse.urljoin(host, "alfabetico"))) # url=urlparse.urljoin(host, "alfabetico")))
# itemlist.append(Item(channel=item.channel, action="explorar", title="Listado por año", url=urlparse.urljoin(host, "año"))) itemlist.append(Item(channel=item.channel, action="explorar", title="Listado por Año", url=urlparse.urljoin(host, "genero")))
itemlist.append(Item(channel=item.channel, action="lista", title="Otras Películas (No Bollywood)", #itemlist.append(Item(channel=item.channel, action="lista", title="Otras Películas (No Bollywood)",
url=urlparse.urljoin(host, "estrenos"))) # url=urlparse.urljoin(host, "estrenos")))
itemlist.append(Item(channel=item.channel, title="Buscar", action="search", url=urlparse.urljoin(host, "buscar-"))) #itemlist.append(Item(channel=item.channel, title="Buscar", action="search", url=urlparse.urljoin(host, "buscar-")))
return itemlist return itemlist
def explorar(item): def explorar(item):
logger.info() logger.info()
itemlist = list() itemlist = list()
url1 = item.title urltitle = item.title
data = httptools.downloadpage(host).data data = httptools.downloadpage(item.url).data
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data) data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data)
if 'Género' in url1: if 'Género' in urltitle:
patron = '<div class="d">.+?<h3>Pel.+?neros<\/h3>(.+?)<\/h3>' patron = "var accion = '<div .+?>(.+?)<\/div>'"
if 'Listado Alfabético' in url1: #if 'Listado Alfabético' in urltitle:
patron = '<\/li><\/ul>.+?<h3>Pel.+?tico<\/h3>(.+?)<\/h3>' # patron = '<\/li><\/ul>.+?<h3>Pel.+?tico<\/h3>(.+?)<\/h3>'
if 'Año' in url1: if 'Año' in urltitle:
patron = '<ul class="anio"><li>(.+?)<\/ul>' patron = "var anho = '<div .+?>(.+?)<\/div>'"
data_explorar = scrapertools.find_single_match(data, patron) data_explorar = scrapertools.find_single_match(data, patron)
patron_explorar = '<a href="([^"]+)">([^"]+)<\/a>' patron_explorar = '<li class=".+?"><a class=".+?" href="(.+?)">(.+?)<\/a><\/li>'
matches = scrapertools.find_multiple_matches(data_explorar, patron_explorar) matches = scrapertools.find_multiple_matches(data_explorar, patron_explorar)
for scrapedurl, scrapedtitle in matches: for scrapedurl, scrapedtitle in matches:
if 'Acci' in scrapedtitle: if 'Acci' in scrapedtitle:
@@ -56,7 +56,9 @@ def explorar(item):
scrapedtitle = 'Histórico' scrapedtitle = 'Histórico'
if 'lico Guerra' in scrapedtitle: if 'lico Guerra' in scrapedtitle:
scrapedtitle = 'Bélico Guerra' scrapedtitle = 'Bélico Guerra'
if 'Ciencia' in scrapedtitle: if 'Biogra' in scrapedtitle:
scrapedtitle = 'Biografía'
if 'Ficcion' in scrapedtitle:
scrapedtitle = 'Ciencia Ficción' scrapedtitle = 'Ciencia Ficción'
itemlist.append(item.clone(action='lista', title=scrapedtitle, url=scrapedurl)) itemlist.append(item.clone(action='lista', title=scrapedtitle, url=scrapedurl))
return itemlist return itemlist
@@ -78,17 +80,22 @@ def lista(item):
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data) # Eliminamos tabuladores, dobles espacios saltos de linea, etc... data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data) # Eliminamos tabuladores, dobles espacios saltos de linea, etc...
data_mov= scrapertools.find_single_match(data,'<div id="cuerpo"><div class="iz">(.+)<ul class="pag">') data_mov= scrapertools.find_single_match(data,'<div class="lista-anime">(.+?)<section class="paginacion">')
patron = '<a href="([^"]+)"><img src="([^"]+)" alt="([^"]+)"' # scrapedurl, scrapedthumbnail, scrapedtitle patron = "<figure class='figure-peliculas'>" #generico
patron += " <a href='(.+?)' .+?>.+?" #scrapedurl
patron += "<img .+? src=(.+?) alt.+?> " #scrapedthumbnail
patron += "<p>(.+?)<\/p>.+?" #scrapedplot
patron += "<p class='.+?anho'>(.+?)" #scrapedyear
patron += "<\/p>.+?<h2>(.+?)<\/h2>" #scrapedtitle
matches = scrapertools.find_multiple_matches(data_mov, patron) matches = scrapertools.find_multiple_matches(data_mov, patron)
for scrapedurl, scrapedthumbnail, scrapedtitle in matches: # scrapedthumbnail, scrapedtitle in matches: for scrapedurl, scrapedthumbnail, scrapedplot, scrapedyear, scrapedtitle in matches:
itemlist.append(item.clone(title=scrapedtitle, url=scrapedurl, thumbnail=scrapedthumbnail, action="findvideos", if '"' in scrapedthumbnail:
scrapedthumbnail=scrapedthumbnail.replace('"','')
itemlist.append(item.clone(title=scrapedtitle+' ['+scrapedyear+']', url=scrapedurl, plot=scrapedplot, thumbnail=scrapedthumbnail, action="opcion",
show=scrapedtitle)) show=scrapedtitle))
# Paginacion # Paginacion
patron_pag = '<a href="([^"]+)" title="Siguiente .+?">' patron_pag = '<a href="([^"]+)" title="Siguiente .+?">'
paginasig = scrapertools.find_single_match(data, patron_pag) paginasig = scrapertools.find_single_match(data, patron_pag)
logger.info("algoooosadf "+paginasig)
next_page_url = host + paginasig next_page_url = host + paginasig
if paginasig != "": if paginasig != "":
@@ -97,23 +104,35 @@ def lista(item):
thumbnail='https://s32.postimg.cc/4zppxf5j9/siguiente.png')) thumbnail='https://s32.postimg.cc/4zppxf5j9/siguiente.png'))
return itemlist return itemlist
def opcion(item):
def findvideos(item):
logger.info() logger.info()
itemlist = [] itemlist = []
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data) data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data)
itemlist.extend(servertools.find_video_items(data=data)) logger.info("inflos"+data)
logger.info("holaa" + data) patron = '<\/div> <\/div> <a href="(.+?)" class="a-play-cartelera"'
patron_show = '<strong>Ver Pel.+?a([^<]+) online<\/strong>' scrapedurl = scrapertools.find_single_match(data, patron)
show = scrapertools.find_single_match(data, patron_show) #for scrapedurl in match:
for videoitem in itemlist: itemlist.append(item.clone(url=host+scrapedurl, action="findvideos"))
videoitem.channel = item.channel
if config.get_videolibrary_support() and len(itemlist) > 0 and item.contentChannel!='videolibrary':
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=show))
return itemlist return itemlist
# #def findvideos(item):
# logger.info()
# itemlist = []
# data = httptools.downloadpage(item.url).data
# data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data)
# itemlist.extend(servertools.find_video_items(data=data))
# patron_show = '<strong>Ver Pel.+?a([^<]+) online<\/strong>'
# show = scrapertools.find_single_match(data, patron_show)
# for videoitem in itemlist:
# videoitem.channel = item.channel
# if config.get_videolibrary_support() and len(itemlist) > 0 and item.contentChannel!='videolibrary':
# 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=show))
# return itemlist
+7 -1
View File
@@ -74,7 +74,11 @@ def menu_alf(item):
for letra in ['[0-9]', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', for letra in ['[0-9]', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']: 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']:
itemlist.append(Item(channel=item.channel, action="series", title=letra, if 'series' in item.url:
action = 'series'
else:
action = 'pelis'
itemlist.append(Item(channel=item.channel, action=action, title=letra,
url=item.url + "?keywords=^" + letra + "&page=0")) url=item.url + "?keywords=^" + letra + "&page=0"))
return itemlist return itemlist
@@ -117,6 +121,7 @@ def series(item):
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
lista = jsontools.load(data) lista = jsontools.load(data)
logger.debug(lista)
if item.extra == "next": if item.extra == "next":
lista_ = lista[25:] lista_ = lista[25:]
else: else:
@@ -171,6 +176,7 @@ def episodios(item):
# post = "page=%s&x=34&y=14" % urllib.quote(item.url) # post = "page=%s&x=34&y=14" % urllib.quote(item.url)
# response = httptools.downloadpage(url, post, follow_redirects=False).data # response = httptools.downloadpage(url, post, follow_redirects=False).data
# url = scrapertools.find_single_match(response, '<meta http-equiv="refresh".*?url=([^"]+)"') # url = scrapertools.find_single_match(response, '<meta http-equiv="refresh".*?url=([^"]+)"')
logger.debug(item)
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
data = jsontools.load(data) data = jsontools.load(data)
+234 -207
View File
@@ -9,274 +9,301 @@ from platformcode import config, logger
__perfil__ = int(config.get_setting('perfil', 'pelisultra')) __perfil__ = int(config.get_setting('perfil', 'pelisultra'))
# Fijar perfil de color # Fijar perfil de color
perfil = [['0xFFFFE6CC', '0xFFFFCE9C', '0xFF994D00'], perfil = [['0xFFFFE6CC', '0xFFFFCE9C', '0xFF994D00'], ['0xFFA5F6AF', '0xFF5FDA6D', '0xFF11811E'],
['0xFFA5F6AF', '0xFF5FDA6D', '0xFF11811E'],
['0xFF58D3F7', '0xFF2E9AFE', '0xFF2E64FE']] ['0xFF58D3F7', '0xFF2E9AFE', '0xFF2E64FE']]
if __perfil__ < 3: if __perfil__ < 3:
color1, color2, color3 = perfil[__perfil__] color1, color2, color3 = perfil[__perfil__]
else: else:
color1 = color2 = color3 = "" color1 = color2 = color3 = ""
host = "http://www.pelisultra.com"
host="http://www.pelisultra.com"
def mainlist(item): def mainlist(item):
logger.info() logger.info()
itemlist = [] itemlist = []
item.thumbnail = "https://github.com/master-1970/resources/raw/master/images/genres/0/Directors%20Chair.png" item.thumbnail = "https://github.com/master-1970/resources/raw/master/images/genres/0/Directors%20Chair.png"
itemlist.append(item.clone(title="Películas:", folder=False, text_color="0xFFD4AF37", text_bold=True)) itemlist.append(item.clone(title="Películas:", folder=False, text_color="0xFFD4AF37", text_bold=True))
itemlist.append(Item(channel = item.channel, title = " Novedades", action = "peliculas", url = host)) itemlist.append(Item(channel=item.channel, title=" Novedades", action="peliculas", url=host))
itemlist.append(Item(channel = item.channel, title = " Estrenos", action = "peliculas", url = host + "/genero/estrenos/" )) itemlist.append(
itemlist.append(Item(channel = item.channel, title = " Por género", action = "genero", url = host + "/genero/" )) Item(channel=item.channel, title=" Estrenos", action="peliculas", url=host + "/genero/estrenos/"))
item.thumbnail = "https://github.com/master-1970/resources/raw/master/images/genres/0/TV%20Series.png" itemlist.append(Item(channel=item.channel, title=" Por género", action="genero", url=host))
itemlist.append(item.clone(title="Series:", folder=False, text_color="0xFFD4AF37", text_bold=True)) item.thumbnail = "https://github.com/master-1970/resources/raw/master/images/genres/0/TV%20Series.png"
itemlist.append(Item(channel = item.channel, title = " Todas las series", action = "series", url = host + "/series/" )) itemlist.append(item.clone(title="Series:", folder=False, text_color="0xFFD4AF37", text_bold=True))
itemlist.append(Item(channel = item.channel, title = " Nuevos episodios", action = "nuevos_episodios", url = host + "/episodio/" )) itemlist.append(Item(channel=item.channel, title=" Todas las series", action="series", url=host + "/series/"))
itemlist.append(Item(channel = item.channel, title = "Buscar...", action = "search", url = host, text_color="red", text_bold=True)) itemlist.append(
itemlist.append(item.clone(title="Configurar canal...", text_color="green", action="configuracion", text_bold=True)) Item(channel=item.channel, title=" Nuevos episodios", action="nuevos_episodios", url=host + "/episodio/"))
return itemlist itemlist.append(
Item(channel=item.channel, title="Buscar...", action="search", url=host, text_color="red", text_bold=True))
itemlist.append(item.clone(title="Configurar canal...", text_color="green", action="configuracion", text_bold=True))
return itemlist
def configuracion(item): def configuracion(item):
from platformcode import platformtools from platformcode import platformtools
ret = platformtools.show_channel_settings() ret = platformtools.show_channel_settings()
platformtools.itemlist_refresh() platformtools.itemlist_refresh()
return ret return ret
def newest(categoria): def newest(categoria):
logger.info() logger.info()
itemlist = [] itemlist = []
item = Item() item = Item()
try: try:
if categoria in ["peliculas", "latino"]: if categoria in ["peliculas", "latino"]:
item.url = host item.url = host
itemlist = peliculas(item) itemlist = peliculas(item)
elif categoria == 'terror': elif categoria == 'terror':
item.url = host + '/genero/terror/' item.url = host + '/genero/terror/'
itemlist = peliculas(item) itemlist = peliculas(item)
elif categoria == "series": elif categoria == "series":
item.url = host + "/episodio/" item.url = host + "/episodio/"
itemlist = nuevos_episodios(item) itemlist = nuevos_episodios(item)
if "Pagina" in itemlist[-1].title: if "Pagina" in itemlist[-1].title:
itemlist.pop() itemlist.pop()
# Se captura la excepción, para no interrumpir al canal novedades si un canal falla # Se captura la excepción, para no interrumpir al canal novedades si un canal falla
except: except:
import sys import sys
for line in sys.exc_info(): for line in sys.exc_info():
logger.error("{0}".format(line)) logger.error("{0}".format(line))
return [] return []
return itemlist
return itemlist
def peliculas(item): def peliculas(item):
#logger.info() # logger.info()
logger.info(item) logger.info(item)
itemlist = [] itemlist = []
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
data2 = scrapertools.find_single_match(data,'(?s)<div class="item_1.*?>(.*?)id="paginador">') data2 = scrapertools.find_single_match(data, '(?s)<div class="item_1.*?>(.*?)id="paginador">')
# Se saca la info # Se saca la info
#(?s)class="ml-item.*?a href="([^"]+).*?img src="([^"]+).*?alt="([^"]+).*?class="year">(\d{4})</span>(.*?)<div # (?s)class="ml-item.*?a href="([^"]+).*?img src="([^"]+).*?alt="([^"]+).*?class="year">(\d{4})</span>(.*?)<div
patron = '(?s)class="ml-item.*?' # base patron = '(?s)class="ml-item.*?' # base
patron += 'a href="([^"]+).*?' # url patron += 'a href="([^"]+).*?' # url
patron += 'img src="([^"]+).*?' # imagen patron += 'img src="([^"]+).*?' # imagen
patron += 'alt="([^"]+).*?' # titulo patron += 'alt="([^"]+).*?' # titulo
patron += 'class="year">(\d{4})' # año patron += 'class="year">(\d{4})' # año
patron += '</span>(.*?)<div' # calidad patron += '</span>(.*?)<div' # calidad
matches = scrapertools.find_multiple_matches(data2, patron) matches = scrapertools.find_multiple_matches(data2, patron)
scrapertools.printMatches(matches) scrapertools.printMatches(matches)
for scrapedurl, scrapedthumbnail, scrapedtitle, scrapedyear, scrapedquality in matches: for scrapedurl, scrapedthumbnail, scrapedtitle, scrapedyear, scrapedquality in matches:
if not "/series/" in scrapedurl: if not "/series/" in scrapedurl:
scrapedquality = scrapertools.find_single_match(scrapedquality, '<span class="calidad2">(.*?)</span>') scrapedquality = scrapertools.find_single_match(scrapedquality, '<span class="calidad2">(.*?)</span>')
itemlist.append(Item(action = "findvideos", channel = item.channel, title = scrapedtitle + " (" + scrapedyear + ") [" + scrapedquality + "]", contentTitle=scrapedtitle, thumbnail = scrapedthumbnail, url = scrapedurl, quality=scrapedquality, infoLabels={'year':scrapedyear})) itemlist.append(Item(action="findvideos", channel=item.channel,
else: title=scrapedtitle + " (" + scrapedyear + ") [" + scrapedquality + "]",
if item.action == "search": contentTitle=scrapedtitle, thumbnail=scrapedthumbnail, url=scrapedurl,
itemlist.append(Item(action = "temporadas", channel = item.channel, title = scrapedtitle + " (" + scrapedyear + ")", contentSerieName=scrapedtitle, contentType="tvshow", thumbnail = scrapedthumbnail, url = scrapedurl, infoLabels={'year':scrapedyear})) quality=scrapedquality, infoLabels={'year': scrapedyear}))
else:
if item.action == "search":
itemlist.append(
Item(action="temporadas", channel=item.channel, title=scrapedtitle + " (" + scrapedyear + ")",
contentSerieName=scrapedtitle, contentType="tvshow", thumbnail=scrapedthumbnail,
url=scrapedurl, infoLabels={'year': scrapedyear}))
# InfoLabels:
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
# InfoLabels: # Pagina siguiente
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) patron_siguiente = 'class="pag_b"><a href="([^"]+)'
url_pagina_siguiente = scrapertools.find_single_match(data, patron_siguiente)
# Pagina siguiente if url_pagina_siguiente != "":
patron_siguiente='class="pag_b"><a href="([^"]+)' pagina = ">>> Pagina: " + scrapertools.find_single_match(url_pagina_siguiente, '\d+')
url_pagina_siguiente=scrapertools.find_single_match(data, patron_siguiente) itemlist.append(Item(channel=item.channel, action="peliculas", title=pagina, url=url_pagina_siguiente))
if url_pagina_siguiente != "": return itemlist
pagina = ">>> Pagina: " + scrapertools.find_single_match(url_pagina_siguiente, '\d+')
itemlist.append(Item(channel = item.channel, action = "peliculas", title = pagina, url = url_pagina_siguiente))
return itemlist
def genero(item): def genero(item):
logger.info() logger.info()
itemlist = [] itemlist = []
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
# Delimita la búsqueda a la lista donde estan los géneros # Delimita la búsqueda a la lista donde estan los géneros
data = scrapertools.find_single_match(data,'(?s)<ul id="menu-generos" class="">(.*?)</ul>') data = scrapertools.find_single_match(data, '(?s)<ul id="menu-generos" class="">(.*?)</ul>')
# Extrae la url y el género # Extrae la url y el género
patron = '<a href="(.*?)">(.*?)</a></li>' patron = '<a href="(.*?)">(.*?)</a></li>'
matches = scrapertools.find_multiple_matches(data, patron) matches = scrapertools.find_multiple_matches(data, patron)
# Se quita "Estrenos" de la lista porque tiene su propio menu # Se quita "Estrenos" de la lista porque tiene su propio menu
matches.pop(0) matches.pop(0)
for scrapedurl, scrapedtitle in matches: for scrapedurl, scrapedtitle in matches:
itemlist.append(Item(action = "peliculas", channel = item.channel, title = scrapedtitle, url = scrapedurl)) itemlist.append(Item(action="peliculas", channel=item.channel, title=scrapedtitle, url=scrapedurl))
return itemlist
return itemlist
def series(item): def series(item):
logger.info() logger.info()
itemlist = [] itemlist = []
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
# Se saca la info # Se saca la info
patron = '(?s)class="ml-item.*?' # base patron = '(?s)class="ml-item.*?' # base
patron += 'a href="([^"]+).*?' # url patron += 'a href="([^"]+).*?' # url
patron += 'img src="([^"]+).*?' # imagen patron += 'img src="([^"]+).*?' # imagen
patron += 'alt="([^"]+).*?' # titulo patron += 'alt="([^"]+).*?' # titulo
patron += 'class="year">(\d{4})' # año patron += 'class="year">(\d{4})' # año
matches = scrapertools.find_multiple_matches(data, patron) matches = scrapertools.find_multiple_matches(data, patron)
#if config.get_setting('temporada_o_todos', 'pelisultra') == 0: # if config.get_setting('temporada_o_todos', 'pelisultra') == 0:
if config.get_setting('temporada_o_todos', 'pelisultra'): if config.get_setting('temporada_o_todos', 'pelisultra'):
accion="temporadas" accion = "temporadas"
else: else:
accion="episodios" accion = "episodios"
for scrapedurl, scrapedthumbnail, scrapedtitle, scrapedyear in matches: for scrapedurl, scrapedthumbnail, scrapedtitle, scrapedyear in matches:
itemlist.append(Item(action = accion, channel = item.channel, title = scrapedtitle + " (" + scrapedyear + ")", contentSerieName=scrapedtitle, contentType="tvshow", thumbnail = scrapedthumbnail, url = scrapedurl, infoLabels={'year':scrapedyear})) itemlist.append(Item(action=accion, channel=item.channel, title=scrapedtitle + " (" + scrapedyear + ")",
contentSerieName=scrapedtitle, contentType="tvshow", thumbnail=scrapedthumbnail,
url=scrapedurl, infoLabels={'year': scrapedyear}))
# InfoLabels: # InfoLabels:
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
# Pagina siguiente # Pagina siguiente
patron_siguiente='class="pag_b"><a href="([^"]+)' patron_siguiente = 'class="pag_b"><a href="([^"]+)'
url_pagina_siguiente=scrapertools.find_single_match(data, patron_siguiente) url_pagina_siguiente = scrapertools.find_single_match(data, patron_siguiente)
if url_pagina_siguiente != "": if url_pagina_siguiente != "":
pagina = ">>> Pagina: " + scrapertools.find_single_match(url_pagina_siguiente, '\d+') pagina = ">>> Pagina: " + scrapertools.find_single_match(url_pagina_siguiente, '\d+')
itemlist.append(Item(channel = item.channel, action = "series", title = pagina, url = url_pagina_siguiente)) itemlist.append(Item(channel=item.channel, action="series", title=pagina, url=url_pagina_siguiente))
return itemlist
return itemlist
def temporadas(item): def temporadas(item):
logger.info() logger.info()
itemlist = [] itemlist = []
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
# Extrae las temporadas # Extrae las temporadas
patron = '<span class="se-t.*?>(.*?)</span>' patron = '<span class="se-t.*?>(.*?)</span>'
matches = scrapertools.find_multiple_matches(data, patron) matches = scrapertools.find_multiple_matches(data, patron)
# Excepción para la serie Sin Límites # Excepción para la serie Sin Límites
if item.contentTitle == 'Amar sin límites': if item.contentTitle == 'Amar sin límites':
item.contentSerieName = "limitless" item.contentSerieName = "limitless"
item.infoLabels['tmdb_id']='' item.infoLabels['tmdb_id'] = ''
for scrapedseason in matches: for scrapedseason in matches:
itemlist.append(item.clone(action = "episodios", title = "Temporada " + scrapedseason, contentSeason=scrapedseason)) itemlist.append(item.clone(action="episodios", title="Temporada " + scrapedseason, contentSeason=scrapedseason))
# InfoLabels: # InfoLabels:
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
return itemlist
return itemlist
def episodios(item): def episodios(item):
logger.info() logger.info()
itemlist = [] itemlist = []
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
patron = '(?s)class="episodiotitle">.*?a href="(.*?)">(.*?)</a>' patron = '(?s)class="episodiotitle">.*?a href="(.*?)">(.*?)</a>'
matches = scrapertools.find_multiple_matches(data, patron) matches = scrapertools.find_multiple_matches(data, patron)
for scrapedurl, scrapedtitle in matches: for scrapedurl, scrapedtitle in matches:
# Saco el numero de capitulo de la url # Saco el numero de capitulo de la url
numero_capitulo=scrapertools.get_season_and_episode(scrapedurl) numero_capitulo = scrapertools.get_season_and_episode(scrapedurl)
if numero_capitulo != "": if numero_capitulo != "":
temporada=numero_capitulo.split("x")[0] temporada = numero_capitulo.split("x")[0]
capitulo=numero_capitulo.split("x")[1] capitulo = numero_capitulo.split("x")[1]
else: else:
temporada="_" temporada = "_"
capitulo="_" capitulo = "_"
if item.contentSeason and str(item.contentSeason) != temporada: if item.contentSeason and str(item.contentSeason) != temporada:
continue continue
itemlist.append(item.clone(action = "findvideos", title = numero_capitulo + " - " + scrapedtitle.strip(), url = scrapedurl, contentSeason=temporada, contentEpisodeNumber=capitulo)) itemlist.append(
item.clone(action="findvideos", title=numero_capitulo + " - " + scrapedtitle.strip(), url=scrapedurl,
contentSeason=temporada, contentEpisodeNumber=capitulo))
# if item.contentTitle.startswith('Temporada'): # if item.contentTitle.startswith('Temporada'):
# if str(item.contentSeason) == temporada: # if str(item.contentSeason) == temporada:
# itemlist.append(item.clone(action = "findvideos", title = numero_capitulo + " - " + scrapedtitle.strip(), url = scrapedurl, contentSeason=temporada, contentEpisodeNumber=capitulo)) # itemlist.append(item.clone(action = "findvideos", title = numero_capitulo + " - " + scrapedtitle.strip(),
# else: # url = scrapedurl, contentSeason=temporada, contentEpisodeNumber=capitulo))
# itemlist.append(item.clone(action = "findvideos", title = numero_capitulo + " - " + scrapedtitle.strip(), url = scrapedurl, contentSeason=temporada, contentEpisodeNumber=capitulo)) # else:
# itemlist.append(item.clone(action = "findvideos", title = numero_capitulo + " - " + scrapedtitle.strip(),
# url = scrapedurl, contentSeason=temporada, contentEpisodeNumber=capitulo))
#episodios_por_pagina=20
# if config.get_setting('episodios_x_pag', 'pelisultra').isdigit():
# episodios_por_pagina=int(config.get_setting('episodios_x_pag', 'pelisultra'))
# else:
# episodios_por_pagina=20
# config.set_setting('episodios_x_pag', '20', 'pelisultra')
episodios_por_pagina= int(config.get_setting('episodios_x_pag', 'pelisultra')) * 5 + 10 # episodios_por_pagina=20
# if config.get_setting('episodios_x_pag', 'pelisultra').isdigit():
# episodios_por_pagina=int(config.get_setting('episodios_x_pag', 'pelisultra'))
# else:
# episodios_por_pagina=20
# config.set_setting('episodios_x_pag', '20', 'pelisultra')
if not item.page: episodios_por_pagina = int(config.get_setting('episodios_x_pag', 'pelisultra')) * 5 + 10
item.page = 0
itemlist_page = itemlist[item.page: item.page + episodios_por_pagina] if not item.page:
item.page = 0
if len(itemlist) > item.page + episodios_por_pagina: itemlist_page = itemlist[item.page: item.page + episodios_por_pagina]
itemlist_page.append(item.clone(title = ">>> Pagina siguiente", page = item.page + episodios_por_pagina))
# InfoLabels: if len(itemlist) > item.page + episodios_por_pagina:
tmdb.set_infoLabels_itemlist(itemlist_page, seekTmdb=True) itemlist_page.append(item.clone(title=">>> Pagina siguiente", page=item.page + episodios_por_pagina))
# InfoLabels:
tmdb.set_infoLabels_itemlist(itemlist_page, seekTmdb=True)
return itemlist_page
return itemlist_page
def nuevos_episodios(item): def nuevos_episodios(item):
logger.info() logger.info()
itemlist = [] itemlist = []
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
patron = '(?s)<td class="bb">.*?' # base patron = '(?s)<td class="bb">.*?' # base
patron += '<a href="(.*?)">' # url patron += '<a href="(.*?)">' # url
patron += '(.*?)</a>.*?' # nombre_serie patron += '(.*?)</a>.*?' # nombre_serie
patron += '<img src="(.*?)>.*?' # imagen patron += '<img src="(.*?)>.*?' # imagen
patron += '<h2>(.*?)</h2>' # titulo patron += '<h2>(.*?)</h2>' # titulo
matches = scrapertools.find_multiple_matches(data, patron) matches = scrapertools.find_multiple_matches(data, patron)
for scrapedurl, scrapedseriename, scrapedthumbnail, scrapedtitle in matches: for scrapedurl, scrapedseriename, scrapedthumbnail, scrapedtitle in matches:
numero_capitulo=scrapertools.get_season_and_episode(scrapedurl) numero_capitulo = scrapertools.get_season_and_episode(scrapedurl)
if numero_capitulo != "": if numero_capitulo != "":
temporada=numero_capitulo.split("x")[0] temporada = numero_capitulo.split("x")[0]
capitulo=numero_capitulo.split("x")[1] capitulo = numero_capitulo.split("x")[1]
else: else:
temporada="_" temporada = "_"
capitulo="_" capitulo = "_"
itemlist.append(Item(channel = item.channel, action = "findvideos", title = scrapedseriename +": " + numero_capitulo + " - " + scrapedtitle.strip(), url = scrapedurl, thumbnail = scrapedthumbnail, contentSerieName=scrapedseriename, contentSeason=temporada, contentEpisodeNumber=capitulo)) itemlist.append(Item(channel=item.channel, action="findvideos",
title=scrapedseriename + ": " + numero_capitulo + " - " + scrapedtitle.strip(),
url=scrapedurl, thumbnail=scrapedthumbnail, contentSerieName=scrapedseriename,
contentSeason=temporada, contentEpisodeNumber=capitulo))
# InfoLabels: # InfoLabels:
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
# Pagina siguiente # Pagina siguiente
patron_siguiente='class="pag_b"><a href="([^"]+)' patron_siguiente = 'class="pag_b"><a href="([^"]+)'
url_pagina_siguiente=scrapertools.find_single_match(data, patron_siguiente) url_pagina_siguiente = scrapertools.find_single_match(data, patron_siguiente)
if url_pagina_siguiente != "": if url_pagina_siguiente != "":
pagina = ">>> Pagina: " + scrapertools.find_single_match(url_pagina_siguiente, '\d+') pagina = ">>> Pagina: " + scrapertools.find_single_match(url_pagina_siguiente, '\d+')
itemlist.append(Item(channel = item.channel, action = "nuevos_episodios", title = pagina, url = url_pagina_siguiente)) itemlist.append(Item(channel=item.channel, action="nuevos_episodios", title=pagina, url=url_pagina_siguiente))
return itemlist
return itemlist
def search(item, texto): def search(item, texto):
logger.info() logger.info()
itemlist = [] itemlist = []
texto = texto.replace(" ", "+") texto = texto.replace(" ", "+")
try: try:
item.url = host + "/?s=%s" % texto item.url = host + "/?s=%s" % texto
itemlist.extend(peliculas(item)) itemlist.extend(peliculas(item))
return itemlist return itemlist
# Se captura la excepción, para no interrumpir al buscador global si un canal falla # Se captura la excepción, para no interrumpir al buscador global si un canal falla
except: except:
import sys import sys
for line in sys.exc_info(): for line in sys.exc_info():
logger.error("%s" % line) logger.error("%s" % line)
return [] return []
+1 -1
View File
@@ -38,7 +38,7 @@ def mainlist(item):
itemlist.append(Item(channel=item.channel, action="opciones", title="Opciones", itemlist.append(Item(channel=item.channel, action="opciones", title="Opciones",
thumbnail=get_thumb("search.png"))) thumbnail=get_thumb("search.png")))
itemlist.append(Item(channel="tvmoviedb", action="mainlist", title="Busquèda alternativa", itemlist.append(Item(channel="tvmoviedb", action="mainlist", title="Búsqueda alternativa",
thumbnail=get_thumb("search.png"))) thumbnail=get_thumb("search.png")))
saved_searches_list = get_saved_searches() saved_searches_list = get_saved_searches()
+9 -9
View File
@@ -16,14 +16,14 @@ HOST = 'http://seriesdanko.to/'
IDIOMAS = {'es': 'Español', 'la': 'Latino', 'vos': 'VOS', 'vo': 'VO'} IDIOMAS = {'es': 'Español', 'la': 'Latino', 'vos': 'VOS', 'vo': 'VO'}
list_idiomas = IDIOMAS.values() list_idiomas = IDIOMAS.values()
list_servers = ['streamcloud', 'powvideo', 'gamovideo', 'streamplay', 'openload', 'flashx', 'nowvideo', 'thevideo'] list_servers = ['streamcloud', 'powvideo', 'gamovideo', 'streamplay', 'openload', 'flashx', 'nowvideo', 'thevideo']
CALIDADES = ['SD', 'MicroHD', 'HD/MKV'] list_quality = ['SD', 'MicroHD', 'HD/MKV']
def mainlist(item): def mainlist(item):
logger.info() logger.info()
autoplay.init(item.channel, list_servers, CALIDADES) autoplay.init(item.channel, list_servers, list_quality)
itemlist = list() itemlist = list()
itemlist.append(Item(channel=item.channel, title="Novedades", action="novedades", url=HOST)) itemlist.append(Item(channel=item.channel, title="Novedades", action="novedades", url=HOST))
@@ -33,7 +33,7 @@ def mainlist(item):
itemlist.append(Item(channel=item.channel, title="Buscar...", action="search", itemlist.append(Item(channel=item.channel, title="Buscar...", action="search",
url=urlparse.urljoin(HOST, "all.php"))) url=urlparse.urljoin(HOST, "all.php")))
itemlist = filtertools.show_option(itemlist, item.channel, list_idiomas, CALIDADES) itemlist = filtertools.show_option(itemlist, item.channel, list_idiomas, list_quality)
autoplay.show_option(item.channel, itemlist) autoplay.show_option(item.channel, itemlist)
@@ -76,7 +76,7 @@ def novedades(item):
itemlist.append(Item(channel=item.channel, title=title, url=urlparse.urljoin(HOST, scrapedurl), show=show, itemlist.append(Item(channel=item.channel, title=title, url=urlparse.urljoin(HOST, scrapedurl), show=show,
action="episodios", thumbnail=scrapedthumb, action="episodios", thumbnail=scrapedthumb,
context=filtertools.context(item, list_idiomas, CALIDADES), language=language)) context=filtertools.context(item, list_idiomas, list_quality), language=language))
return itemlist return itemlist
@@ -124,7 +124,7 @@ def series_seccion(item):
for scrapedurl, scrapedtitle in matches[item.first:limit]: for scrapedurl, scrapedtitle in matches[item.first:limit]:
itemlist.append(Item(channel=item.channel, action="episodios", title=scrapedtitle, show=scrapedtitle, itemlist.append(Item(channel=item.channel, action="episodios", title=scrapedtitle, show=scrapedtitle,
url=urlparse.urljoin(HOST, scrapedurl), url=urlparse.urljoin(HOST, scrapedurl),
context=filtertools.context(item, list_idiomas, CALIDADES))) context=filtertools.context(item, list_idiomas, list_quality)))
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
#pagination #pagination
@@ -157,7 +157,7 @@ def series_por_letra(item):
itemlist = [] itemlist = []
for url, title, img in shows: for url, title, img in shows:
itemlist.append(item.clone(title=title, url=urlparse.urljoin(HOST, url), action="episodios", thumbnail=img, itemlist.append(item.clone(title=title, url=urlparse.urljoin(HOST, url), action="episodios", thumbnail=img,
show=title, context=filtertools.context(item, list_idiomas, CALIDADES))) show=title, context=filtertools.context(item, list_idiomas, list_quality)))
return itemlist return itemlist
@@ -172,7 +172,7 @@ def search(item, texto):
data, re.IGNORECASE) data, re.IGNORECASE)
for url, title in shows: for url, title in shows:
itemlist.append(item.clone(title=title, url=urlparse.urljoin(HOST, url), action="episodios", show=title, itemlist.append(item.clone(title=title, url=urlparse.urljoin(HOST, url), action="episodios", show=title,
context=filtertools.context(item, list_idiomas, CALIDADES))) context=filtertools.context(item, list_idiomas, list_quality)))
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
# Se captura la excepción, para no interrumpir al buscador global si un canal falla # Se captura la excepción, para no interrumpir al buscador global si un canal falla
@@ -228,7 +228,7 @@ def episodios(item):
infoLabels=infoLabels)) infoLabels=infoLabels))
itemlist = filtertools.get_links(itemlist, item, list_idiomas, CALIDADES) itemlist = filtertools.get_links(itemlist, item, list_idiomas, list_quality)
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
# Opción "Añadir esta serie a la videoteca de XBMC" # Opción "Añadir esta serie a la videoteca de XBMC"
@@ -266,7 +266,7 @@ def findvideos(item):
# Requerido para FilterTools # Requerido para FilterTools
itemlist = filtertools.get_links(itemlist, item, list_idiomas, CALIDADES) itemlist = filtertools.get_links(itemlist, item, list_idiomas, list_quality)
# Requerido para AutoPlay # Requerido para AutoPlay
+7 -7
View File
@@ -21,7 +21,7 @@ HOST = "http://www.seriespapaya.com"
IDIOMAS = {'es': 'Español', 'lat': 'Latino', 'in': 'Inglés', 'ca': 'Catalán', 'sub': 'VOSE', 'Español Latino':'lat', IDIOMAS = {'es': 'Español', 'lat': 'Latino', 'in': 'Inglés', 'ca': 'Catalán', 'sub': 'VOSE', 'Español Latino':'lat',
'Español Castellano':'es', 'Sub Español':'VOSE'} 'Español Castellano':'es', 'Sub Español':'VOSE'}
list_idiomas = IDIOMAS.values() list_idiomas = IDIOMAS.values()
CALIDADES = ['360p', '480p', '720p HD', '1080p HD', 'default'] list_quality = ['360p', '480p', '720p HD', '1080p HD', 'default']
list_servers = ['powvideo', 'streamplay', 'filebebo', 'flashx', 'gamovideo', 'nowvideo', 'openload', 'streamango', list_servers = ['powvideo', 'streamplay', 'filebebo', 'flashx', 'gamovideo', 'nowvideo', 'openload', 'streamango',
'streamcloud', 'vidzi', 'clipwatching', ] 'streamcloud', 'vidzi', 'clipwatching', ]
@@ -29,7 +29,7 @@ list_servers = ['powvideo', 'streamplay', 'filebebo', 'flashx', 'gamovideo', 'no
def mainlist(item): def mainlist(item):
logger.info() logger.info()
autoplay.init(item.channel, list_servers, CALIDADES) autoplay.init(item.channel, list_servers, list_quality)
thumb_series = get_thumb("channels_tvshow.png") thumb_series = get_thumb("channels_tvshow.png")
thumb_series_az = get_thumb("channels_tvshow_az.png") thumb_series_az = get_thumb("channels_tvshow_az.png")
@@ -42,7 +42,7 @@ def mainlist(item):
Item(action="novedades", title="Capítulos de estreno", channel=item.channel, thumbnail=thumb_series)) Item(action="novedades", title="Capítulos de estreno", channel=item.channel, thumbnail=thumb_series))
itemlist.append(Item(action="search", title="Buscar", channel=item.channel, thumbnail=thumb_buscar)) itemlist.append(Item(action="search", title="Buscar", channel=item.channel, thumbnail=thumb_buscar))
itemlist = filtertools.show_option(itemlist, item.channel, list_idiomas, CALIDADES) itemlist = filtertools.show_option(itemlist, item.channel, list_idiomas, list_quality)
autoplay.show_option(item.channel, itemlist) autoplay.show_option(item.channel, itemlist)
@@ -92,7 +92,7 @@ def series_por_letra_y_grupo(item):
show=name, show=name,
url=urlparse.urljoin(HOST, url), url=urlparse.urljoin(HOST, url),
thumbnail=urlparse.urljoin(HOST, img), thumbnail=urlparse.urljoin(HOST, img),
context=filtertools.context(item, list_idiomas, CALIDADES), context=filtertools.context(item, list_idiomas, list_quality),
plot = plot, plot = plot,
infoLabels={'year':year} infoLabels={'year':year}
) )
@@ -153,7 +153,7 @@ def episodios(item):
language=filter_lang language=filter_lang
)) ))
itemlist = filtertools.get_links(itemlist, item, list_idiomas, CALIDADES) itemlist = filtertools.get_links(itemlist, item, list_idiomas, list_quality)
# Opción "Añadir esta serie a la videoteca de XBMC" # Opción "Añadir esta serie a la videoteca de XBMC"
if config.get_videolibrary_support() and len(itemlist) > 0: if config.get_videolibrary_support() and len(itemlist) > 0:
@@ -177,7 +177,7 @@ def search(item, texto):
show=show["titulo"], show=show["titulo"],
url=urlparse.urljoin(HOST, show["urla"]), url=urlparse.urljoin(HOST, show["urla"]),
thumbnail=urlparse.urljoin(HOST, show["img"]), thumbnail=urlparse.urljoin(HOST, show["img"]),
context=filtertools.context(item, list_idiomas, CALIDADES) context=filtertools.context(item, list_idiomas, list_quality)
) for show in tvshows] ) for show in tvshows]
@@ -227,7 +227,7 @@ def findvideos(item):
# Requerido para FilterTools # Requerido para FilterTools
itemlist = filtertools.get_links(itemlist, item, list_idiomas, CALIDADES) itemlist = filtertools.get_links(itemlist, item, list_idiomas, list_quality)
# Requerido para AutoPlay # Requerido para AutoPlay
+6 -4
View File
@@ -83,7 +83,7 @@ def list_all(item):
url = host + scrapedurl url = host + scrapedurl
thumbnail = scrapedthumbnail thumbnail = scrapedthumbnail
title = scrapedtitle title = scrapertools.decodeHtmlentities(scrapedtitle)
itemlist.append(Item(channel=item.channel, itemlist.append(Item(channel=item.channel,
action='seasons', action='seasons',
@@ -125,7 +125,10 @@ def section(item):
for scrapedurl, scrapedtitle in matches: for scrapedurl, scrapedtitle in matches:
url = host + scrapedurl if item.title == 'Generos':
url = host + scrapedurl
else:
url = scrapedurl
title = scrapedtitle title = scrapedtitle
itemlist.append(Item(channel=item.channel, itemlist.append(Item(channel=item.channel,
action='list_all', action='list_all',
@@ -211,7 +214,6 @@ def add_language(title, string):
languages = scrapertools.find_multiple_matches(string, '/banderas/(.*?).png') languages = scrapertools.find_multiple_matches(string, '/banderas/(.*?).png')
language = [] language = []
for lang in languages: for lang in languages:
@@ -219,7 +221,7 @@ def add_language(title, string):
lang = 'vos' lang = 'vos'
if len(languages) == 1: if len(languages) == 1:
language = IDIOMAS[languages[0]] language = IDIOMAS[lang]
title = '%s [%s]' % (title, language) title = '%s [%s]' % (title, language)
else: else:
language.append(IDIOMAS[lang]) language.append(IDIOMAS[lang])
+67 -295
View File
@@ -4,6 +4,7 @@ import re
import sys import sys
import urllib import urllib
import urlparse import urlparse
import datetime
from channelselector import get_thumb from channelselector import get_thumb
from core import httptools from core import httptools
@@ -12,6 +13,7 @@ from core import servertools
from core.item import Item from core.item import Item
from platformcode import config, logger from platformcode import config, logger
from core import tmdb from core import tmdb
from lib import generictools
host = 'http://torrentlocura.com/' host = 'http://torrentlocura.com/'
@@ -145,11 +147,7 @@ def listado(item):
clase = "pelilist" # etiqueta para localizar zona de listado de contenidos clase = "pelilist" # etiqueta para localizar zona de listado de contenidos
url_next_page ='' # Controlde paginación url_next_page ='' # Controlde paginación
cnt_tot = 30 # Poner el num. máximo de items por página cnt_tot = 30 # Poner el num. máximo de items por página
category = "" # Guarda la categoria que viene desde una busqueda global
if item.category:
category = item.category
del item.category
if item.totalItems: if item.totalItems:
del item.totalItems del item.totalItems
@@ -258,8 +256,10 @@ def listado(item):
del item_local.tipo del item_local.tipo
if item_local.totalItems: if item_local.totalItems:
del item_local.totalItems del item_local.totalItems
if item.post_num: if item_local.post_num:
del item.post_num del item_local.post_num
if item_local.category:
del item_local.category
item_local.title = '' item_local.title = ''
item_local.context = "['buscar_trailer']" item_local.context = "['buscar_trailer']"
@@ -336,8 +336,8 @@ def listado(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -347,7 +347,7 @@ def listado(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -403,65 +403,8 @@ def listado(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
if category == "newest": #Viene de Novedades. Marquemos el título con el nombre del canal
title += ' -%s-' % item_local.channel.capitalize()
if item_local.contentType == "movie":
item_local.contentTitle += ' -%s-' % item_local.channel.capitalize()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if len(itemlist) == 0: if len(itemlist) == 0:
itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado")) itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado"))
@@ -728,7 +671,7 @@ def listado_busqueda(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Esp", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -738,7 +681,7 @@ def listado_busqueda(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -868,64 +811,8 @@ def listado_busqueda(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
title += " -Serie-"
elif item_local.extra == "varios":
title += " -Varios-"
item_local.contentTitle += " -Varios-"
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + "[" + str(item_local.language) + "]" + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if post: if post:
itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag)) itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag))
@@ -1043,31 +930,6 @@ def findvideos(item):
verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?"
excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar
# Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal,
# con la función "play_from_library"
unify_status = False
try:
import xbmc
if xbmc.getCondVisibility('Window.IsMedia') == 1:
unify_status = config.get_setting("unify")
except:
unify_status = config.get_setting("unify")
#Salvamos la información de max num. de episodios por temporada para despues de TMDB
if item.infoLabels['temporada_num_episodios']:
num_episodios = item.infoLabels['temporada_num_episodios']
else:
num_episodios = 1
# Obtener la información actualizada del Episodio, si no la hay
if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'):
tmdb.set_infoLabels(item, __modo_grafico__)
elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary":
tmdb.set_infoLabels(item, __modo_grafico__)
#Restauramos la información de max num. de episodios por temporada despues de TMDB
if item.infoLabels['temporada_num_episodios'] and num_episodios > item.infoLabels['temporada_num_episodios']:
item.infoLabels['temporada_num_episodios'] = num_episodios
# Descarga la página # Descarga la página
try: try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data) data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
@@ -1081,17 +943,15 @@ def findvideos(item):
#Añadimos el tamaño para todos #Añadimos el tamaño para todos
size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>') size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>')
size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra
item.quality = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía if not size:
if size: size = scrapertools.find_single_match(item.quality, '\s\[(\d+,?\d*?\s\w[b|B])\]')
item.title = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.title) #Quitamos size de título, si lo traía else:
item.title = '%s [%s]' % (item.title, size) #Agregamos size al final del título 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
item.quality = re.sub(r'\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía
#Limpiamos de año y rating de episodios #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
if item.infoLabels['episodio_titulo']: item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
item.infoLabels['episodio_titulo'] = re.sub(r'\s?\[.*?\]', '', item.infoLabels['episodio_titulo'])
item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '')
if item.infoLabels['aired'] and item.contentType == "episode":
item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})')
#Generamos una copia de Item para trabajar sobre ella #Generamos una copia de Item para trabajar sobre ella
item_local = item.clone() item_local = item.clone()
@@ -1100,57 +960,29 @@ def findvideos(item):
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";'
item_local.url = scrapertools.find_single_match(data, patron) item_local.url = scrapertools.find_single_match(data, patron)
if not item_local.url: #error if not item_local.url: #error
logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) 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: Ha cambiado la estructura de la Web. Reportar el error con el log')) 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 return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
item_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso 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("Patron: " + patron + " url: " + item_local.url)
#logger.debug(data) #logger.debug(data)
#Pintamos el pseudo-título con toda la información disponible del vídeo
item_local.action = ""
item_local.server = "torrent"
rating = '' #Ponemos el rating
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
if item_local.contentType == "episode":
title = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2))
if item_local.infoLabels['temporada_num_episodios']:
title = '%s (de %s)' % (title, str(item_local.infoLabels['temporada_num_episodios']))
title = '%s %s' % (title, item_local.infoLabels['episodio_titulo'])
title_gen = '%s, %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR] [%s]' % (title, item_local.contentSerieName, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language), size)
else:
title = item_local.title
title_gen = title
title_gen = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title_gen).strip() #Quitamos etiquetas vacías
title_gen = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title_gen).strip() #Quitamos colores vacíos
title_gen = title_gen.replace(" []", "").strip() #Quitamos etiquetas vacías
if not unify_status: #Si Titulos Inteligentes NO seleccionados:
title_gen = '**- [COLOR gold]Enlaces Ver: [/COLOR]%s[COLOR gold] -**[/COLOR]' % (title_gen)
else:
title_gen = '[COLOR gold]Enlaces Ver: [/COLOR]%s' % (title_gen)
if config.get_setting("quit_channel_name", "videolibrary") == 1 and item_local.contentChannel == "videolibrary":
title_gen = '%s: %s' % (item_local.channel.capitalize(), title_gen)
itemlist.append(item_local.clone(title=title_gen)) #Título con todos los datos del vídeo
#Ahora pintamos el link del Torrent, si lo hay #Ahora pintamos el link del Torrent, si lo hay
if item_local.url: # Hay Torrent ? if item_local.url: # Hay Torrent ?
item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos
item_local.alive = "??" #Calidad del link sin verificar item_local.alive = "??" #Calidad del link sin verificar
item_local.action = "play" #Visualizar vídeo item_local.action = "play" #Visualizar vídeo
item_local.server = "torrent" #Servidor
if size:
quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final del título
else:
quality = item_local.quality
itemlist.append(item_local.clone()) #Pintar pantalla itemlist.append(item_local.clone(quality=quality)) #Pintar pantalla
logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + title_gen + " / " + title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName)
#logger.debug(item_local) #logger.debug(item_local)
# VER vídeos, descargar vídeos un link, o múltiples links # VER vídeos, descargar vídeos un link, o múltiples links
@@ -1236,7 +1068,7 @@ def findvideos(item):
if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0: if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0:
#Pintamos un pseudo-título de Descargas #Pintamos un pseudo-título de Descargas
if not unify_status: #Si Titulos Inteligentes NO seleccionados: if not item.unify: #Si Titulos Inteligentes NO seleccionados:
itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action=""))
else: else:
itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action=""))
@@ -1261,7 +1093,7 @@ def findvideos(item):
#Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace #Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace
p = 1 p = 1
for enlace in partes: for enlace in partes:
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
else: else:
parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
@@ -1303,12 +1135,12 @@ def findvideos(item):
break #Si se ha agotado el contador de verificación, se sale de "Enlace" break #Si se ha agotado el contador de verificación, se sale de "Enlace"
if item_local.alive == "??": #dudoso if item_local.alive == "??": #dudoso
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title) parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title)
else: else:
parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title)
elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title) parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title)
else: else:
parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title)
@@ -1377,7 +1209,7 @@ def episodios(item):
list_pages = [item.url] list_pages = [item.url]
season = max_temp season = max_temp
if item.library_playcounts: #Comprobamos si realmente sabemos el num. máximo de temporadas if item.library_playcounts or item.tmdb_stat: #Comprobamos si realmente sabemos el num. máximo de temporadas
num_temporadas_flag = True num_temporadas_flag = True
else: else:
num_temporadas_flag = False num_temporadas_flag = False
@@ -1441,10 +1273,15 @@ def episodios(item):
if scrapertools.find_single_match(info, '\[\d{3}\]'): if scrapertools.find_single_match(info, '\[\d{3}\]'):
info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info) info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info)
elif scrapertools.find_single_match(info, 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'):
pattern = 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'
elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'): elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'):
info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info) info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info)
elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'): elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'):
info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info) info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info)
elif "completa" in info.lower():
info = info.replace("COMPLETA", "Caps. 01_99")
pattern = 'Temp.*?(?P<season>\d+).*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<quality>.*?)\].*?\[(?P<lang>\w+)\]?'
if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'): if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'):
pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \ pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \
"(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?" "(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?"
@@ -1475,15 +1312,18 @@ def episodios(item):
except: except:
logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches))
#logger.error("TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / " + str(match['episode2']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1: if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1:
#Si el num de temporada está fuera de control, se trata pone en num. de temporada actual #Si el num de temporada está fuera de control, se trata pone en num. de temporada actual
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) #logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern + " / MATCHES: " + str(matches))
#logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
match['season'] = season match['season'] = season
item_local.contentSeason = season item_local.contentSeason = season
else: else:
item_local.contentSeason = match['season'] item_local.contentSeason = match['season']
season = match['season'] season = match['season']
num_temporadas_flag = True if match['episode'] > 0:
num_temporadas_flag = True
if season > max_temp: if season > max_temp:
max_temp = season max_temp = season
@@ -1496,13 +1336,14 @@ def episodios(item):
item_local.infoLabels['episodio_titulo'] = match['lang'] item_local.infoLabels['episodio_titulo'] = match['lang']
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo'] item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.contentEpisodeNumber = match['episode']
if match['episode'] == 0: match['episode'] = 1 #Evitar errores en Videoteca
if match["episode2"]: #Hay episodio dos? es una entrada múltiple? if match["episode2"]: #Hay episodio dos? es una entrada múltiple?
item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios
else: #Si es un solo episodio, se formatea ya else: #Si es un solo episodio, se formatea ya
item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2)) item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2))
item_local.contentEpisodeNumber = match['episode']
if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca
if item_local.contentSeason < max_temp: if item_local.contentSeason < max_temp:
list_pages = [] #Sale del bucle de leer páginas list_pages = [] #Sale del bucle de leer páginas
@@ -1541,93 +1382,24 @@ def episodios(item):
# Pasada por TMDB y clasificación de lista por temporada y episodio # Pasada por TMDB y clasificación de lista por temporada y episodio
tmdb.set_infoLabels(itemlist, True) tmdb.set_infoLabels(itemlist, True)
# Pasada para maqullaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
num_episodios = 1 item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
num_episodios_lista = []
for i in range(0, 50): num_episodios_lista += [0]
num_temporada = 1
num_temporada_max = 99
num_episodios_flag = True
for item_local in itemlist:
# Si no hay datos de TMDB, pongo los datos locales que conozco
if item_local.infoLabels['aired']:
item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})')
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Salvamos en número de episodios de la temporada
if item_local.infoLabels['number_of_seasons']:
#Si el num de temporada está fuera de control, se pone 0, y se reclasifica itemlist
if item_local.contentSeason > item_local.infoLabels['number_of_seasons'] + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(item_local.infoLabels['number_of_seasons']) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
else:
num_temporada_max = item_local.infoLabels['number_of_seasons']
else:
if item_local.contentSeason > num_temporada_max + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
if num_temporada != item_local.contentSeason:
num_temporada = item_local.contentSeason
num_episodios = 0
if item_local.infoLabels['temporada_num_episodios']:
num_episodios = item_local.infoLabels['temporada_num_episodios']
#Preparamos el título para que sea compatible con Añadir Serie a Videoteca
if item_local.infoLabels['episodio_titulo']:
if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName)
else:
item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo'])
if item_local.infoLabels['year']:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.infoLabels['year'])
if rating:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], rating)
else:
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.contentSerieName, item_local.infoLabels['year'], rating)
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.title = '%s [%s] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.title, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language))
#Quitamos campos vacíos
item_local.infoLabels['episodio_titulo'] = item_local.infoLabels['episodio_titulo'].replace(" []", "").strip()
item_local.title = item_local.title.replace(" []", "").strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]-\[\/COLOR\]', '', item_local.title).strip()
if num_episodios < item_local.contentEpisodeNumber:
num_episodios = item_local.contentEpisodeNumber
if num_episodios and not item_local.infoLabels['temporada_num_episodios']:
item_local.infoLabels['temporada_num_episodios'] = num_episodios
num_episodios_flag = False
num_episodios_lista[item_local.contentSeason] = [num_episodios]
#logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag))
#logger.debug(item_local)
try:
if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie
for item_local in itemlist:
item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason]
except:
logger.error("ERROR 07: EPISODIOS: Num de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
if config.get_videolibrary_support() and len(itemlist) > 0:
title = ''
if item_local.infoLabels['temporada_num_episodios']:
title = ' [Temp. de %s ep.]' % item_local.infoLabels['temporada_num_episodios']
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta serie a la videoteca[/COLOR]" + title, action="add_serie_to_library", extra="episodios"))
return itemlist return itemlist
def actualizar_titulos(item):
logger.info()
itemlist = []
from platformcode import launcher
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 launcher.run(item)
def search(item, texto): def search(item, texto):
logger.info("search:" + texto) logger.info("search:" + texto)
# texto = texto.replace(" ", "+") # texto = texto.replace(" ", "+")
+67 -295
View File
@@ -4,6 +4,7 @@ import re
import sys import sys
import urllib import urllib
import urlparse import urlparse
import datetime
from channelselector import get_thumb from channelselector import get_thumb
from core import httptools from core import httptools
@@ -12,6 +13,7 @@ from core import servertools
from core.item import Item from core.item import Item
from platformcode import config, logger from platformcode import config, logger
from core import tmdb from core import tmdb
from lib import generictools
host = 'http://torrentrapid.com/' host = 'http://torrentrapid.com/'
@@ -145,11 +147,7 @@ def listado(item):
clase = "pelilist" # etiqueta para localizar zona de listado de contenidos clase = "pelilist" # etiqueta para localizar zona de listado de contenidos
url_next_page ='' # Controlde paginación url_next_page ='' # Controlde paginación
cnt_tot = 30 # Poner el num. máximo de items por página cnt_tot = 30 # Poner el num. máximo de items por página
category = "" # Guarda la categoria que viene desde una busqueda global
if item.category:
category = item.category
del item.category
if item.totalItems: if item.totalItems:
del item.totalItems del item.totalItems
@@ -258,8 +256,10 @@ def listado(item):
del item_local.tipo del item_local.tipo
if item_local.totalItems: if item_local.totalItems:
del item_local.totalItems del item_local.totalItems
if item.post_num: if item_local.post_num:
del item.post_num del item_local.post_num
if item_local.category:
del item_local.category
item_local.title = '' item_local.title = ''
item_local.context = "['buscar_trailer']" item_local.context = "['buscar_trailer']"
@@ -336,8 +336,8 @@ def listado(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -347,7 +347,7 @@ def listado(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -403,65 +403,8 @@ def listado(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
if category == "newest": #Viene de Novedades. Marquemos el título con el nombre del canal
title += ' -%s-' % item_local.channel.capitalize()
if item_local.contentType == "movie":
item_local.contentTitle += ' -%s-' % item_local.channel.capitalize()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if len(itemlist) == 0: if len(itemlist) == 0:
itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado")) itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado"))
@@ -728,7 +671,7 @@ def listado_busqueda(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Esp", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -738,7 +681,7 @@ def listado_busqueda(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -868,64 +811,8 @@ def listado_busqueda(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
title += " -Serie-"
elif item_local.extra == "varios":
title += " -Varios-"
item_local.contentTitle += " -Varios-"
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + "[" + str(item_local.language) + "]" + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if post: if post:
itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag)) itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag))
@@ -1043,31 +930,6 @@ def findvideos(item):
verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?"
excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar
# Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal,
# con la función "play_from_library"
unify_status = False
try:
import xbmc
if xbmc.getCondVisibility('Window.IsMedia') == 1:
unify_status = config.get_setting("unify")
except:
unify_status = config.get_setting("unify")
#Salvamos la información de max num. de episodios por temporada para despues de TMDB
if item.infoLabels['temporada_num_episodios']:
num_episodios = item.infoLabels['temporada_num_episodios']
else:
num_episodios = 1
# Obtener la información actualizada del Episodio, si no la hay
if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'):
tmdb.set_infoLabels(item, __modo_grafico__)
elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary":
tmdb.set_infoLabels(item, __modo_grafico__)
#Restauramos la información de max num. de episodios por temporada despues de TMDB
if item.infoLabels['temporada_num_episodios'] and num_episodios > item.infoLabels['temporada_num_episodios']:
item.infoLabels['temporada_num_episodios'] = num_episodios
# Descarga la página # Descarga la página
try: try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data) data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
@@ -1081,17 +943,15 @@ def findvideos(item):
#Añadimos el tamaño para todos #Añadimos el tamaño para todos
size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>') size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>')
size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra
item.quality = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía if not size:
if size: size = scrapertools.find_single_match(item.quality, '\s\[(\d+,?\d*?\s\w[b|B])\]')
item.title = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.title) #Quitamos size de título, si lo traía else:
item.title = '%s [%s]' % (item.title, size) #Agregamos size al final del título 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
item.quality = re.sub(r'\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía
#Limpiamos de año y rating de episodios #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
if item.infoLabels['episodio_titulo']: item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
item.infoLabels['episodio_titulo'] = re.sub(r'\s?\[.*?\]', '', item.infoLabels['episodio_titulo'])
item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '')
if item.infoLabels['aired'] and item.contentType == "episode":
item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})')
#Generamos una copia de Item para trabajar sobre ella #Generamos una copia de Item para trabajar sobre ella
item_local = item.clone() item_local = item.clone()
@@ -1100,57 +960,29 @@ def findvideos(item):
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";'
item_local.url = scrapertools.find_single_match(data, patron) item_local.url = scrapertools.find_single_match(data, patron)
if not item_local.url: #error if not item_local.url: #error
logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) 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: Ha cambiado la estructura de la Web. Reportar el error con el log')) 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 return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
item_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso 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("Patron: " + patron + " url: " + item_local.url)
#logger.debug(data) #logger.debug(data)
#Pintamos el pseudo-título con toda la información disponible del vídeo
item_local.action = ""
item_local.server = "torrent"
rating = '' #Ponemos el rating
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
if item_local.contentType == "episode":
title = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2))
if item_local.infoLabels['temporada_num_episodios']:
title = '%s (de %s)' % (title, str(item_local.infoLabels['temporada_num_episodios']))
title = '%s %s' % (title, item_local.infoLabels['episodio_titulo'])
title_gen = '%s, %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR] [%s]' % (title, item_local.contentSerieName, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language), size)
else:
title = item_local.title
title_gen = title
title_gen = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title_gen).strip() #Quitamos etiquetas vacías
title_gen = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title_gen).strip() #Quitamos colores vacíos
title_gen = title_gen.replace(" []", "").strip() #Quitamos etiquetas vacías
if not unify_status: #Si Titulos Inteligentes NO seleccionados:
title_gen = '**- [COLOR gold]Enlaces Ver: [/COLOR]%s[COLOR gold] -**[/COLOR]' % (title_gen)
else:
title_gen = '[COLOR gold]Enlaces Ver: [/COLOR]%s' % (title_gen)
if config.get_setting("quit_channel_name", "videolibrary") == 1 and item_local.contentChannel == "videolibrary":
title_gen = '%s: %s' % (item_local.channel.capitalize(), title_gen)
itemlist.append(item_local.clone(title=title_gen)) #Título con todos los datos del vídeo
#Ahora pintamos el link del Torrent, si lo hay #Ahora pintamos el link del Torrent, si lo hay
if item_local.url: # Hay Torrent ? if item_local.url: # Hay Torrent ?
item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos
item_local.alive = "??" #Calidad del link sin verificar item_local.alive = "??" #Calidad del link sin verificar
item_local.action = "play" #Visualizar vídeo item_local.action = "play" #Visualizar vídeo
item_local.server = "torrent" #Servidor
if size:
quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final del título
else:
quality = item_local.quality
itemlist.append(item_local.clone()) #Pintar pantalla itemlist.append(item_local.clone(quality=quality)) #Pintar pantalla
logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + title_gen + " / " + title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName)
#logger.debug(item_local) #logger.debug(item_local)
# VER vídeos, descargar vídeos un link, o múltiples links # VER vídeos, descargar vídeos un link, o múltiples links
@@ -1236,7 +1068,7 @@ def findvideos(item):
if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0: if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0:
#Pintamos un pseudo-título de Descargas #Pintamos un pseudo-título de Descargas
if not unify_status: #Si Titulos Inteligentes NO seleccionados: if not item.unify: #Si Titulos Inteligentes NO seleccionados:
itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action=""))
else: else:
itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action=""))
@@ -1261,7 +1093,7 @@ def findvideos(item):
#Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace #Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace
p = 1 p = 1
for enlace in partes: for enlace in partes:
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
else: else:
parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
@@ -1303,12 +1135,12 @@ def findvideos(item):
break #Si se ha agotado el contador de verificación, se sale de "Enlace" break #Si se ha agotado el contador de verificación, se sale de "Enlace"
if item_local.alive == "??": #dudoso if item_local.alive == "??": #dudoso
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title) parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title)
else: else:
parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title)
elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title) parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title)
else: else:
parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title)
@@ -1377,7 +1209,7 @@ def episodios(item):
list_pages = [item.url] list_pages = [item.url]
season = max_temp season = max_temp
if item.library_playcounts: #Comprobamos si realmente sabemos el num. máximo de temporadas if item.library_playcounts or item.tmdb_stat: #Comprobamos si realmente sabemos el num. máximo de temporadas
num_temporadas_flag = True num_temporadas_flag = True
else: else:
num_temporadas_flag = False num_temporadas_flag = False
@@ -1441,10 +1273,15 @@ def episodios(item):
if scrapertools.find_single_match(info, '\[\d{3}\]'): if scrapertools.find_single_match(info, '\[\d{3}\]'):
info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info) info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info)
elif scrapertools.find_single_match(info, 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'):
pattern = 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'
elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'): elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'):
info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info) info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info)
elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'): elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'):
info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info) info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info)
elif "completa" in info.lower():
info = info.replace("COMPLETA", "Caps. 01_99")
pattern = 'Temp.*?(?P<season>\d+).*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<quality>.*?)\].*?\[(?P<lang>\w+)\]?'
if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'): if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'):
pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \ pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \
"(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?" "(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?"
@@ -1475,15 +1312,18 @@ def episodios(item):
except: except:
logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches))
#logger.error("TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / " + str(match['episode2']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1: if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1:
#Si el num de temporada está fuera de control, se trata pone en num. de temporada actual #Si el num de temporada está fuera de control, se trata pone en num. de temporada actual
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) #logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern + " / MATCHES: " + str(matches))
#logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
match['season'] = season match['season'] = season
item_local.contentSeason = season item_local.contentSeason = season
else: else:
item_local.contentSeason = match['season'] item_local.contentSeason = match['season']
season = match['season'] season = match['season']
num_temporadas_flag = True if match['episode'] > 0:
num_temporadas_flag = True
if season > max_temp: if season > max_temp:
max_temp = season max_temp = season
@@ -1496,13 +1336,14 @@ def episodios(item):
item_local.infoLabels['episodio_titulo'] = match['lang'] item_local.infoLabels['episodio_titulo'] = match['lang']
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo'] item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.contentEpisodeNumber = match['episode']
if match['episode'] == 0: match['episode'] = 1 #Evitar errores en Videoteca
if match["episode2"]: #Hay episodio dos? es una entrada múltiple? if match["episode2"]: #Hay episodio dos? es una entrada múltiple?
item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios
else: #Si es un solo episodio, se formatea ya else: #Si es un solo episodio, se formatea ya
item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2)) item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2))
item_local.contentEpisodeNumber = match['episode']
if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca
if item_local.contentSeason < max_temp: if item_local.contentSeason < max_temp:
list_pages = [] #Sale del bucle de leer páginas list_pages = [] #Sale del bucle de leer páginas
@@ -1541,93 +1382,24 @@ def episodios(item):
# Pasada por TMDB y clasificación de lista por temporada y episodio # Pasada por TMDB y clasificación de lista por temporada y episodio
tmdb.set_infoLabels(itemlist, True) tmdb.set_infoLabels(itemlist, True)
# Pasada para maqullaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
num_episodios = 1 item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
num_episodios_lista = []
for i in range(0, 50): num_episodios_lista += [0]
num_temporada = 1
num_temporada_max = 99
num_episodios_flag = True
for item_local in itemlist:
# Si no hay datos de TMDB, pongo los datos locales que conozco
if item_local.infoLabels['aired']:
item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})')
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Salvamos en número de episodios de la temporada
if item_local.infoLabels['number_of_seasons']:
#Si el num de temporada está fuera de control, se pone 0, y se reclasifica itemlist
if item_local.contentSeason > item_local.infoLabels['number_of_seasons'] + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(item_local.infoLabels['number_of_seasons']) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
else:
num_temporada_max = item_local.infoLabels['number_of_seasons']
else:
if item_local.contentSeason > num_temporada_max + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
if num_temporada != item_local.contentSeason:
num_temporada = item_local.contentSeason
num_episodios = 0
if item_local.infoLabels['temporada_num_episodios']:
num_episodios = item_local.infoLabels['temporada_num_episodios']
#Preparamos el título para que sea compatible con Añadir Serie a Videoteca
if item_local.infoLabels['episodio_titulo']:
if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName)
else:
item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo'])
if item_local.infoLabels['year']:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.infoLabels['year'])
if rating:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], rating)
else:
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.contentSerieName, item_local.infoLabels['year'], rating)
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.title = '%s [%s] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.title, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language))
#Quitamos campos vacíos
item_local.infoLabels['episodio_titulo'] = item_local.infoLabels['episodio_titulo'].replace(" []", "").strip()
item_local.title = item_local.title.replace(" []", "").strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]-\[\/COLOR\]', '', item_local.title).strip()
if num_episodios < item_local.contentEpisodeNumber:
num_episodios = item_local.contentEpisodeNumber
if num_episodios and not item_local.infoLabels['temporada_num_episodios']:
item_local.infoLabels['temporada_num_episodios'] = num_episodios
num_episodios_flag = False
num_episodios_lista[item_local.contentSeason] = [num_episodios]
#logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag))
#logger.debug(item_local)
try:
if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie
for item_local in itemlist:
item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason]
except:
logger.error("ERROR 07: EPISODIOS: Num de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
if config.get_videolibrary_support() and len(itemlist) > 0:
title = ''
if item_local.infoLabels['temporada_num_episodios']:
title = ' [Temp. de %s ep.]' % item_local.infoLabels['temporada_num_episodios']
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta serie a la videoteca[/COLOR]" + title, action="add_serie_to_library", extra="episodios"))
return itemlist return itemlist
def actualizar_titulos(item):
logger.info()
itemlist = []
from platformcode import launcher
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 launcher.run(item)
def search(item, texto): def search(item, texto):
logger.info("search:" + texto) logger.info("search:" + texto)
# texto = texto.replace(" ", "+") # texto = texto.replace(" ", "+")
+67 -295
View File
@@ -4,6 +4,7 @@ import re
import sys import sys
import urllib import urllib
import urlparse import urlparse
import datetime
from channelselector import get_thumb from channelselector import get_thumb
from core import httptools from core import httptools
@@ -12,6 +13,7 @@ from core import servertools
from core.item import Item from core.item import Item
from platformcode import config, logger from platformcode import config, logger
from core import tmdb from core import tmdb
from lib import generictools
host = 'http://tumejortorrent.com/' host = 'http://tumejortorrent.com/'
@@ -145,11 +147,7 @@ def listado(item):
clase = "pelilist" # etiqueta para localizar zona de listado de contenidos clase = "pelilist" # etiqueta para localizar zona de listado de contenidos
url_next_page ='' # Controlde paginación url_next_page ='' # Controlde paginación
cnt_tot = 30 # Poner el num. máximo de items por página cnt_tot = 30 # Poner el num. máximo de items por página
category = "" # Guarda la categoria que viene desde una busqueda global
if item.category:
category = item.category
del item.category
if item.totalItems: if item.totalItems:
del item.totalItems del item.totalItems
@@ -258,8 +256,10 @@ def listado(item):
del item_local.tipo del item_local.tipo
if item_local.totalItems: if item_local.totalItems:
del item_local.totalItems del item_local.totalItems
if item.post_num: if item_local.post_num:
del item.post_num del item_local.post_num
if item_local.category:
del item_local.category
item_local.title = '' item_local.title = ''
item_local.context = "['buscar_trailer']" item_local.context = "['buscar_trailer']"
@@ -336,8 +336,8 @@ def listado(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -347,7 +347,7 @@ def listado(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -403,65 +403,8 @@ def listado(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
if category == "newest": #Viene de Novedades. Marquemos el título con el nombre del canal
title += ' -%s-' % item_local.channel.capitalize()
if item_local.contentType == "movie":
item_local.contentTitle += ' -%s-' % item_local.channel.capitalize()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if len(itemlist) == 0: if len(itemlist) == 0:
itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado")) itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado"))
@@ -728,7 +671,7 @@ def listado_busqueda(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Esp", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -738,7 +681,7 @@ def listado_busqueda(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -868,64 +811,8 @@ def listado_busqueda(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
title += " -Serie-"
elif item_local.extra == "varios":
title += " -Varios-"
item_local.contentTitle += " -Varios-"
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + "[" + str(item_local.language) + "]" + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if post: if post:
itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag)) itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag))
@@ -1043,31 +930,6 @@ def findvideos(item):
verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?"
excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar
# Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal,
# con la función "play_from_library"
unify_status = False
try:
import xbmc
if xbmc.getCondVisibility('Window.IsMedia') == 1:
unify_status = config.get_setting("unify")
except:
unify_status = config.get_setting("unify")
#Salvamos la información de max num. de episodios por temporada para despues de TMDB
if item.infoLabels['temporada_num_episodios']:
num_episodios = item.infoLabels['temporada_num_episodios']
else:
num_episodios = 1
# Obtener la información actualizada del Episodio, si no la hay
if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'):
tmdb.set_infoLabels(item, __modo_grafico__)
elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary":
tmdb.set_infoLabels(item, __modo_grafico__)
#Restauramos la información de max num. de episodios por temporada despues de TMDB
if item.infoLabels['temporada_num_episodios'] and num_episodios > item.infoLabels['temporada_num_episodios']:
item.infoLabels['temporada_num_episodios'] = num_episodios
# Descarga la página # Descarga la página
try: try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data) data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
@@ -1081,17 +943,15 @@ def findvideos(item):
#Añadimos el tamaño para todos #Añadimos el tamaño para todos
size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>') size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>')
size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra
item.quality = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía if not size:
if size: size = scrapertools.find_single_match(item.quality, '\s\[(\d+,?\d*?\s\w[b|B])\]')
item.title = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.title) #Quitamos size de título, si lo traía else:
item.title = '%s [%s]' % (item.title, size) #Agregamos size al final del título 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
item.quality = re.sub(r'\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía
#Limpiamos de año y rating de episodios #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
if item.infoLabels['episodio_titulo']: item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
item.infoLabels['episodio_titulo'] = re.sub(r'\s?\[.*?\]', '', item.infoLabels['episodio_titulo'])
item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '')
if item.infoLabels['aired'] and item.contentType == "episode":
item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})')
#Generamos una copia de Item para trabajar sobre ella #Generamos una copia de Item para trabajar sobre ella
item_local = item.clone() item_local = item.clone()
@@ -1100,57 +960,29 @@ def findvideos(item):
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";'
item_local.url = scrapertools.find_single_match(data, patron) item_local.url = scrapertools.find_single_match(data, patron)
if not item_local.url: #error if not item_local.url: #error
logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) 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: Ha cambiado la estructura de la Web. Reportar el error con el log')) 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 return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
item_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso 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("Patron: " + patron + " url: " + item_local.url)
#logger.debug(data) #logger.debug(data)
#Pintamos el pseudo-título con toda la información disponible del vídeo
item_local.action = ""
item_local.server = "torrent"
rating = '' #Ponemos el rating
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
if item_local.contentType == "episode":
title = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2))
if item_local.infoLabels['temporada_num_episodios']:
title = '%s (de %s)' % (title, str(item_local.infoLabels['temporada_num_episodios']))
title = '%s %s' % (title, item_local.infoLabels['episodio_titulo'])
title_gen = '%s, %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR] [%s]' % (title, item_local.contentSerieName, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language), size)
else:
title = item_local.title
title_gen = title
title_gen = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title_gen).strip() #Quitamos etiquetas vacías
title_gen = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title_gen).strip() #Quitamos colores vacíos
title_gen = title_gen.replace(" []", "").strip() #Quitamos etiquetas vacías
if not unify_status: #Si Titulos Inteligentes NO seleccionados:
title_gen = '**- [COLOR gold]Enlaces Ver: [/COLOR]%s[COLOR gold] -**[/COLOR]' % (title_gen)
else:
title_gen = '[COLOR gold]Enlaces Ver: [/COLOR]%s' % (title_gen)
if config.get_setting("quit_channel_name", "videolibrary") == 1 and item_local.contentChannel == "videolibrary":
title_gen = '%s: %s' % (item_local.channel.capitalize(), title_gen)
itemlist.append(item_local.clone(title=title_gen)) #Título con todos los datos del vídeo
#Ahora pintamos el link del Torrent, si lo hay #Ahora pintamos el link del Torrent, si lo hay
if item_local.url: # Hay Torrent ? if item_local.url: # Hay Torrent ?
item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos
item_local.alive = "??" #Calidad del link sin verificar item_local.alive = "??" #Calidad del link sin verificar
item_local.action = "play" #Visualizar vídeo item_local.action = "play" #Visualizar vídeo
item_local.server = "torrent" #Servidor
if size:
quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final del título
else:
quality = item_local.quality
itemlist.append(item_local.clone()) #Pintar pantalla itemlist.append(item_local.clone(quality=quality)) #Pintar pantalla
logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + title_gen + " / " + title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName)
#logger.debug(item_local) #logger.debug(item_local)
# VER vídeos, descargar vídeos un link, o múltiples links # VER vídeos, descargar vídeos un link, o múltiples links
@@ -1236,7 +1068,7 @@ def findvideos(item):
if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0: if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0:
#Pintamos un pseudo-título de Descargas #Pintamos un pseudo-título de Descargas
if not unify_status: #Si Titulos Inteligentes NO seleccionados: if not item.unify: #Si Titulos Inteligentes NO seleccionados:
itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action=""))
else: else:
itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action=""))
@@ -1261,7 +1093,7 @@ def findvideos(item):
#Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace #Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace
p = 1 p = 1
for enlace in partes: for enlace in partes:
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
else: else:
parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
@@ -1303,12 +1135,12 @@ def findvideos(item):
break #Si se ha agotado el contador de verificación, se sale de "Enlace" break #Si se ha agotado el contador de verificación, se sale de "Enlace"
if item_local.alive == "??": #dudoso if item_local.alive == "??": #dudoso
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title) parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title)
else: else:
parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title)
elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title) parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title)
else: else:
parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title)
@@ -1377,7 +1209,7 @@ def episodios(item):
list_pages = [item.url] list_pages = [item.url]
season = max_temp season = max_temp
if item.library_playcounts: #Comprobamos si realmente sabemos el num. máximo de temporadas if item.library_playcounts or item.tmdb_stat: #Comprobamos si realmente sabemos el num. máximo de temporadas
num_temporadas_flag = True num_temporadas_flag = True
else: else:
num_temporadas_flag = False num_temporadas_flag = False
@@ -1441,10 +1273,15 @@ def episodios(item):
if scrapertools.find_single_match(info, '\[\d{3}\]'): if scrapertools.find_single_match(info, '\[\d{3}\]'):
info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info) info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info)
elif scrapertools.find_single_match(info, 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'):
pattern = 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'
elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'): elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'):
info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info) info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info)
elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'): elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'):
info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info) info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info)
elif "completa" in info.lower():
info = info.replace("COMPLETA", "Caps. 01_99")
pattern = 'Temp.*?(?P<season>\d+).*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<quality>.*?)\].*?\[(?P<lang>\w+)\]?'
if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'): if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'):
pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \ pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \
"(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?" "(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?"
@@ -1475,15 +1312,18 @@ def episodios(item):
except: except:
logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches))
#logger.error("TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / " + str(match['episode2']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1: if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1:
#Si el num de temporada está fuera de control, se trata pone en num. de temporada actual #Si el num de temporada está fuera de control, se trata pone en num. de temporada actual
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) #logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern + " / MATCHES: " + str(matches))
#logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
match['season'] = season match['season'] = season
item_local.contentSeason = season item_local.contentSeason = season
else: else:
item_local.contentSeason = match['season'] item_local.contentSeason = match['season']
season = match['season'] season = match['season']
num_temporadas_flag = True if match['episode'] > 0:
num_temporadas_flag = True
if season > max_temp: if season > max_temp:
max_temp = season max_temp = season
@@ -1496,13 +1336,14 @@ def episodios(item):
item_local.infoLabels['episodio_titulo'] = match['lang'] item_local.infoLabels['episodio_titulo'] = match['lang']
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo'] item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.contentEpisodeNumber = match['episode']
if match['episode'] == 0: match['episode'] = 1 #Evitar errores en Videoteca
if match["episode2"]: #Hay episodio dos? es una entrada múltiple? if match["episode2"]: #Hay episodio dos? es una entrada múltiple?
item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios
else: #Si es un solo episodio, se formatea ya else: #Si es un solo episodio, se formatea ya
item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2)) item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2))
item_local.contentEpisodeNumber = match['episode']
if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca
if item_local.contentSeason < max_temp: if item_local.contentSeason < max_temp:
list_pages = [] #Sale del bucle de leer páginas list_pages = [] #Sale del bucle de leer páginas
@@ -1541,93 +1382,24 @@ def episodios(item):
# Pasada por TMDB y clasificación de lista por temporada y episodio # Pasada por TMDB y clasificación de lista por temporada y episodio
tmdb.set_infoLabels(itemlist, True) tmdb.set_infoLabels(itemlist, True)
# Pasada para maqullaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
num_episodios = 1 item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
num_episodios_lista = []
for i in range(0, 50): num_episodios_lista += [0]
num_temporada = 1
num_temporada_max = 99
num_episodios_flag = True
for item_local in itemlist:
# Si no hay datos de TMDB, pongo los datos locales que conozco
if item_local.infoLabels['aired']:
item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})')
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Salvamos en número de episodios de la temporada
if item_local.infoLabels['number_of_seasons']:
#Si el num de temporada está fuera de control, se pone 0, y se reclasifica itemlist
if item_local.contentSeason > item_local.infoLabels['number_of_seasons'] + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(item_local.infoLabels['number_of_seasons']) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
else:
num_temporada_max = item_local.infoLabels['number_of_seasons']
else:
if item_local.contentSeason > num_temporada_max + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
if num_temporada != item_local.contentSeason:
num_temporada = item_local.contentSeason
num_episodios = 0
if item_local.infoLabels['temporada_num_episodios']:
num_episodios = item_local.infoLabels['temporada_num_episodios']
#Preparamos el título para que sea compatible con Añadir Serie a Videoteca
if item_local.infoLabels['episodio_titulo']:
if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName)
else:
item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo'])
if item_local.infoLabels['year']:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.infoLabels['year'])
if rating:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], rating)
else:
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.contentSerieName, item_local.infoLabels['year'], rating)
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.title = '%s [%s] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.title, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language))
#Quitamos campos vacíos
item_local.infoLabels['episodio_titulo'] = item_local.infoLabels['episodio_titulo'].replace(" []", "").strip()
item_local.title = item_local.title.replace(" []", "").strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]-\[\/COLOR\]', '', item_local.title).strip()
if num_episodios < item_local.contentEpisodeNumber:
num_episodios = item_local.contentEpisodeNumber
if num_episodios and not item_local.infoLabels['temporada_num_episodios']:
item_local.infoLabels['temporada_num_episodios'] = num_episodios
num_episodios_flag = False
num_episodios_lista[item_local.contentSeason] = [num_episodios]
#logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag))
#logger.debug(item_local)
try:
if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie
for item_local in itemlist:
item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason]
except:
logger.error("ERROR 07: EPISODIOS: Num de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
if config.get_videolibrary_support() and len(itemlist) > 0:
title = ''
if item_local.infoLabels['temporada_num_episodios']:
title = ' [Temp. de %s ep.]' % item_local.infoLabels['temporada_num_episodios']
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta serie a la videoteca[/COLOR]" + title, action="add_serie_to_library", extra="episodios"))
return itemlist return itemlist
def actualizar_titulos(item):
logger.info()
itemlist = []
from platformcode import launcher
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 launcher.run(item)
def search(item, texto): def search(item, texto):
logger.info("search:" + texto) logger.info("search:" + texto)
# texto = texto.replace(" ", "+") # texto = texto.replace(" ", "+")
+67 -295
View File
@@ -4,6 +4,7 @@ import re
import sys import sys
import urllib import urllib
import urlparse import urlparse
import datetime
from channelselector import get_thumb from channelselector import get_thumb
from core import httptools from core import httptools
@@ -12,6 +13,7 @@ from core import servertools
from core.item import Item from core.item import Item
from platformcode import config, logger from platformcode import config, logger
from core import tmdb from core import tmdb
from lib import generictools
host = 'http://www.tvsinpagar.com/' host = 'http://www.tvsinpagar.com/'
@@ -145,11 +147,7 @@ def listado(item):
clase = "pelilist" # etiqueta para localizar zona de listado de contenidos clase = "pelilist" # etiqueta para localizar zona de listado de contenidos
url_next_page ='' # Controlde paginación url_next_page ='' # Controlde paginación
cnt_tot = 30 # Poner el num. máximo de items por página cnt_tot = 30 # Poner el num. máximo de items por página
category = "" # Guarda la categoria que viene desde una busqueda global
if item.category:
category = item.category
del item.category
if item.totalItems: if item.totalItems:
del item.totalItems del item.totalItems
@@ -258,8 +256,10 @@ def listado(item):
del item_local.tipo del item_local.tipo
if item_local.totalItems: if item_local.totalItems:
del item_local.totalItems del item_local.totalItems
if item.post_num: if item_local.post_num:
del item.post_num del item_local.post_num
if item_local.category:
del item_local.category
item_local.title = '' item_local.title = ''
item_local.context = "['buscar_trailer']" item_local.context = "['buscar_trailer']"
@@ -336,8 +336,8 @@ def listado(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Espa", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "") title_alt = title_alt.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ingl", "").replace("Engl", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -347,7 +347,7 @@ def listado(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -403,65 +403,8 @@ def listado(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
if category == "newest": #Viene de Novedades. Marquemos el título con el nombre del canal
title += ' -%s-' % item_local.channel.capitalize()
if item_local.contentType == "movie":
item_local.contentTitle += ' -%s-' % item_local.channel.capitalize()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if len(itemlist) == 0: if len(itemlist) == 0:
itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado")) itemlist.append(Item(channel=item.channel, action="mainlist", title="No se ha podido cargar el listado"))
@@ -728,7 +671,7 @@ def listado_busqueda(item):
title_subs += ["[Miniserie]"] title_subs += ["[Miniserie]"]
#Limpiamos restos en título #Limpiamos restos en título
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Esp", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "") title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "").replace("Ing", "").replace("Eng", "").replace("Calidad", "").replace("de la Serie", "")
#Limpiamos cabeceras y colas del título #Limpiamos cabeceras y colas del título
title = re.sub(r'Descargar\s\w+\-\w+', '', title) title = re.sub(r'Descargar\s\w+\-\w+', '', title)
@@ -738,7 +681,7 @@ def listado_busqueda(item):
title = re.sub(r' \d+x\d+', '', title) title = re.sub(r' \d+x\d+', '', title)
title = re.sub(r' x\d+', '', title) title = re.sub(r' x\d+', '', title)
title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVB", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip() title = title.replace("Ver online ", "").replace("Descarga Serie HD ", "").replace("Descargar Serie HD ", "").replace("Descarga Serie ", "").replace("Descargar Serie ", "").replace("Ver en linea ", "").replace("Ver en linea", "").replace("HD ", "").replace("(Proper)", "").replace("RatDVD", "").replace("DVDRiP", "").replace("DVDRIP", "").replace("DVDRip", "").replace("DVDR", "").replace("DVD9", "").replace("DVD", "").replace("DVBRIP", "").replace("DVB", "").replace("LINE", "").replace("- ES ", "").replace("ES ", "").replace("COMPLETA", "").replace("(", "-").replace(")", "-").replace(".", " ").strip()
title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip() title = title.replace("Descargar torrent ", "").replace("Descarga Gratis ", "").replace("Descargar Estreno ", "").replace("Descargar Estrenos ", "").replace("Pelicula en latino ", "").replace("Descargar Pelicula ", "").replace("Descargar Peliculas ", "").replace("Descargar peliculas ", "").replace("Descargar Todas ", "").replace("Descargar Otras ", "").replace("Descargar ", "").replace("Descarga ", "").replace("Bajar ", "").replace("HDRIP ", "").replace("HDRiP ", "").replace("HDRip ", "").replace("RIP ", "").replace("Rip", "").replace("RiP", "").replace("XviD", "").replace("AC3 5.1", "").replace("AC3", "").replace("1080p ", "").replace("720p ", "").replace("DVD-Screener ", "").replace("TS-Screener ", "").replace("Screener ", "").replace("BdRemux ", "").replace("BR ", "").replace("4KULTRA", "").replace("FULLBluRay", "").replace("FullBluRay", "").replace("BluRay", "").replace("Bonus Disc", "").replace("de Cine ", "").replace("TeleCine ", "").replace("latino", "").replace("Latino", "").replace("argentina", "").replace("Argentina", "").strip()
@@ -868,64 +811,8 @@ def listado_busqueda(item):
#Pasamos a TMDB la lista completa Itemlist #Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, __modo_grafico__) tmdb.set_infoLabels(itemlist, __modo_grafico__)
# Pasada para maquillaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
for item_local in itemlist: item, itemlist = generictools.post_tmdb_listado(item, itemlist)
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if len(item_local.title_subs) > 0:
title += " "
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower():
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'):
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs)
else:
title = '%s -%s-' % (title, title_subs)
del item_local.title_subs
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
item_local.contentTitle= ''
title += " -Serie-"
elif item_local.extra == "varios":
title += " -Varios-"
item_local.contentTitle += " -Varios-"
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
item_local.title = title
logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + "[" + str(item_local.language) + "]" + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
if post: if post:
itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag)) itemlist.append(item.clone(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >> [/B][/COLOR]" + str(post_num) + " de " + str(total_pag), thumbnail=get_thumb("next.png"), title_lista=title_lista, cnt_pag=cnt_pag))
@@ -1043,31 +930,6 @@ def findvideos(item):
verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?" verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?"
excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar
# Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal,
# con la función "play_from_library"
unify_status = False
try:
import xbmc
if xbmc.getCondVisibility('Window.IsMedia') == 1:
unify_status = config.get_setting("unify")
except:
unify_status = config.get_setting("unify")
#Salvamos la información de max num. de episodios por temporada para despues de TMDB
if item.infoLabels['temporada_num_episodios']:
num_episodios = item.infoLabels['temporada_num_episodios']
else:
num_episodios = 1
# Obtener la información actualizada del Episodio, si no la hay
if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'):
tmdb.set_infoLabels(item, __modo_grafico__)
elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary":
tmdb.set_infoLabels(item, __modo_grafico__)
#Restauramos la información de max num. de episodios por temporada despues de TMDB
if item.infoLabels['temporada_num_episodios'] and num_episodios > item.infoLabels['temporada_num_episodios']:
item.infoLabels['temporada_num_episodios'] = num_episodios
# Descarga la página # Descarga la página
try: try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data) data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
@@ -1081,17 +943,15 @@ def findvideos(item):
#Añadimos el tamaño para todos #Añadimos el tamaño para todos
size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>') size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>')
size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra size = size.replace(".", ",") #sustituimos . por , porque Unify lo borra
item.quality = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía if not size:
if size: size = scrapertools.find_single_match(item.quality, '\s\[(\d+,?\d*?\s\w[b|B])\]')
item.title = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item.title) #Quitamos size de título, si lo traía else:
item.title = '%s [%s]' % (item.title, size) #Agregamos size al final del título 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
item.quality = re.sub(r'\s\[\d+,?\d*?\s\w[b|B]\]', '', item.quality) #Quitamos size de calidad, si lo traía
#Limpiamos de año y rating de episodios #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
if item.infoLabels['episodio_titulo']: item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
item.infoLabels['episodio_titulo'] = re.sub(r'\s?\[.*?\]', '', item.infoLabels['episodio_titulo'])
item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.wanted, '')
if item.infoLabels['aired'] and item.contentType == "episode":
item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})')
#Generamos una copia de Item para trabajar sobre ella #Generamos una copia de Item para trabajar sobre ella
item_local = item.clone() item_local = item.clone()
@@ -1100,57 +960,29 @@ def findvideos(item):
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";'
item_local.url = scrapertools.find_single_match(data, patron) item_local.url = scrapertools.find_single_match(data, patron)
if not item_local.url: #error if not item_local.url: #error
logger.error("ERROR 02: FINDVIDEOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) 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: Ha cambiado la estructura de la Web. Reportar el error con el log')) 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 return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
item_local.url = item_local.url.replace(" ", "%20") #sustituimos espacios por %20, por si acaso 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("Patron: " + patron + " url: " + item_local.url)
#logger.debug(data) #logger.debug(data)
#Pintamos el pseudo-título con toda la información disponible del vídeo
item_local.action = ""
item_local.server = "torrent"
rating = '' #Ponemos el rating
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
if item_local.contentType == "episode":
title = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2))
if item_local.infoLabels['temporada_num_episodios']:
title = '%s (de %s)' % (title, str(item_local.infoLabels['temporada_num_episodios']))
title = '%s %s' % (title, item_local.infoLabels['episodio_titulo'])
title_gen = '%s, %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR] [%s]' % (title, item_local.contentSerieName, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language), size)
else:
title = item_local.title
title_gen = title
title_gen = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title_gen).strip() #Quitamos etiquetas vacías
title_gen = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title_gen).strip() #Quitamos colores vacíos
title_gen = title_gen.replace(" []", "").strip() #Quitamos etiquetas vacías
if not unify_status: #Si Titulos Inteligentes NO seleccionados:
title_gen = '**- [COLOR gold]Enlaces Ver: [/COLOR]%s[COLOR gold] -**[/COLOR]' % (title_gen)
else:
title_gen = '[COLOR gold]Enlaces Ver: [/COLOR]%s' % (title_gen)
if config.get_setting("quit_channel_name", "videolibrary") == 1 and item_local.contentChannel == "videolibrary":
title_gen = '%s: %s' % (item_local.channel.capitalize(), title_gen)
itemlist.append(item_local.clone(title=title_gen)) #Título con todos los datos del vídeo
#Ahora pintamos el link del Torrent, si lo hay #Ahora pintamos el link del Torrent, si lo hay
if item_local.url: # Hay Torrent ? if item_local.url: # Hay Torrent ?
item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos etiquetas vacías
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title).strip() #Quitamos colores vacíos
item_local.alive = "??" #Calidad del link sin verificar item_local.alive = "??" #Calidad del link sin verificar
item_local.action = "play" #Visualizar vídeo item_local.action = "play" #Visualizar vídeo
item_local.server = "torrent" #Servidor
if size:
quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final del título
else:
quality = item_local.quality
itemlist.append(item_local.clone()) #Pintar pantalla itemlist.append(item_local.clone(quality=quality)) #Pintar pantalla
logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + title_gen + " / " + title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) logger.debug("TORRENT: " + item_local.url + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + size + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName)
#logger.debug(item_local) #logger.debug(item_local)
# VER vídeos, descargar vídeos un link, o múltiples links # VER vídeos, descargar vídeos un link, o múltiples links
@@ -1236,7 +1068,7 @@ def findvideos(item):
if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0: if len(enlaces_descargar) > 0 and ver_enlaces_descargas != 0:
#Pintamos un pseudo-título de Descargas #Pintamos un pseudo-título de Descargas
if not unify_status: #Si Titulos Inteligentes NO seleccionados: if not item.unify: #Si Titulos Inteligentes NO seleccionados:
itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold]**- Enlaces Descargar: -**[/COLOR]", action=""))
else: else:
itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action="")) itemlist.append(item_local.clone(title="[COLOR gold] Enlaces Descargar: [/COLOR]", action=""))
@@ -1261,7 +1093,7 @@ def findvideos(item):
#Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace #Recorremos cada una de las partes. Vemos si el primer link está activo. Si no lo está ignoramos todo el enlace
p = 1 p = 1
for enlace in partes: for enlace in partes:
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow][%s][/COLOR] %s (%s/%s) [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
else: else:
parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language)) parte_title = "[COLOR yellow]%s-[/COLOR] %s %s/%s [COLOR limegreen]-%s[/COLOR] [COLOR red]-%s[/COLOR]" % (servidor.capitalize(), title, p, len(partes), item_local.quality, str(item_local.language))
@@ -1303,12 +1135,12 @@ def findvideos(item):
break #Si se ha agotado el contador de verificación, se sale de "Enlace" break #Si se ha agotado el contador de verificación, se sale de "Enlace"
if item_local.alive == "??": #dudoso if item_local.alive == "??": #dudoso
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title) parte_title = '[COLOR yellow][?][/COLOR] %s' % (parte_title)
else: else:
parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR yellow]%s[/COLOR]-%s' % (item_local.alive, parte_title)
elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto
if not unify_status: #Si titles Inteligentes NO seleccionados: if not item.unify: #Si titles Inteligentes NO seleccionados:
parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title) parte_title = '[COLOR red][%s][/COLOR] %s' % (item_local.alive, parte_title)
else: else:
parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title) parte_title = '[COLOR red]%s[/COLOR]-%s' % (item_local.alive, parte_title)
@@ -1377,7 +1209,7 @@ def episodios(item):
list_pages = [item.url] list_pages = [item.url]
season = max_temp season = max_temp
if item.library_playcounts: #Comprobamos si realmente sabemos el num. máximo de temporadas if item.library_playcounts or item.tmdb_stat: #Comprobamos si realmente sabemos el num. máximo de temporadas
num_temporadas_flag = True num_temporadas_flag = True
else: else:
num_temporadas_flag = False num_temporadas_flag = False
@@ -1441,10 +1273,15 @@ def episodios(item):
if scrapertools.find_single_match(info, '\[\d{3}\]'): if scrapertools.find_single_match(info, '\[\d{3}\]'):
info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info) info = re.sub(r'\[(\d{3}\])', r'[Cap.\1', info)
elif scrapertools.find_single_match(info, 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'):
pattern = 'Temp.*?(?P<season>\d+).*?\[(?P<quality>.*?)\].*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<lang>\w+)\]?'
elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'): elif scrapertools.find_single_match(info, '\[Cap.\d{2}_\d{2}\]'):
info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info) info = re.sub(r'\[Cap.(\d{2})_(\d{2})\]', r'[Cap.1\1_1\2]', info)
elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'): elif scrapertools.find_single_match(info, '\[Cap.([A-Za-z]+)\]'):
info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info) info = re.sub(r'\[Cap.([A-Za-z]+)\]', '[Cap.100]', info)
elif "completa" in info.lower():
info = info.replace("COMPLETA", "Caps. 01_99")
pattern = 'Temp.*?(?P<season>\d+).*?Cap\w?\.\s\d?(?P<episode>\d{2})(?:.*?(?P<episode2>\d{2}))?.*?\[(?P<quality>.*?)\].*?\[(?P<lang>\w+)\]?'
if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'): if scrapertools.find_single_match(info, '\[Cap.\d{2,3}'):
pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \ pattern = "\[(?P<quality>.*?)\].*?\[Cap.(?P<season>\d).*?(?P<episode>\d{2})(?:_(?P<season2>\d+)" \
"(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?" "(?P<episode2>\d{2}))?.*?\].*?(?:\[(?P<lang>.*?)\])?"
@@ -1475,15 +1312,18 @@ def episodios(item):
except: except:
logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches))
#logger.error("TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / " + str(match['episode2']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1: if num_temporadas_flag and match['season'] != season and match['season'] > max_temp + 1:
#Si el num de temporada está fuera de control, se trata pone en num. de temporada actual #Si el num de temporada está fuera de control, se trata pone en num. de temporada actual
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) #logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern + " / MATCHES: " + str(matches))
#logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / PATRON: " + pattern)
match['season'] = season match['season'] = season
item_local.contentSeason = season item_local.contentSeason = season
else: else:
item_local.contentSeason = match['season'] item_local.contentSeason = match['season']
season = match['season'] season = match['season']
num_temporadas_flag = True if match['episode'] > 0:
num_temporadas_flag = True
if season > max_temp: if season > max_temp:
max_temp = season max_temp = season
@@ -1496,13 +1336,14 @@ def episodios(item):
item_local.infoLabels['episodio_titulo'] = match['lang'] item_local.infoLabels['episodio_titulo'] = match['lang']
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo'] item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.contentEpisodeNumber = match['episode']
if match['episode'] == 0: match['episode'] = 1 #Evitar errores en Videoteca
if match["episode2"]: #Hay episodio dos? es una entrada múltiple? if match["episode2"]: #Hay episodio dos? es una entrada múltiple?
item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios item_local.title = "%sx%s al %s -" % (str(match["season"]), str(match["episode"]).zfill(2), str(match["episode2"]).zfill(2)) #Creamos un título con el rango de episodios
else: #Si es un solo episodio, se formatea ya else: #Si es un solo episodio, se formatea ya
item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2)) item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2))
item_local.contentEpisodeNumber = match['episode']
if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca
if item_local.contentSeason < max_temp: if item_local.contentSeason < max_temp:
list_pages = [] #Sale del bucle de leer páginas list_pages = [] #Sale del bucle de leer páginas
@@ -1541,93 +1382,24 @@ def episodios(item):
# Pasada por TMDB y clasificación de lista por temporada y episodio # Pasada por TMDB y clasificación de lista por temporada y episodio
tmdb.set_infoLabels(itemlist, True) tmdb.set_infoLabels(itemlist, True)
# Pasada para maqullaje de los títulos obtenidos desde TMDB #Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
num_episodios = 1 item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
num_episodios_lista = []
for i in range(0, 50): num_episodios_lista += [0]
num_temporada = 1
num_temporada_max = 99
num_episodios_flag = True
for item_local in itemlist:
# Si no hay datos de TMDB, pongo los datos locales que conozco
if item_local.infoLabels['aired']:
item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})')
rating = ''
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
#Salvamos en número de episodios de la temporada
if item_local.infoLabels['number_of_seasons']:
#Si el num de temporada está fuera de control, se pone 0, y se reclasifica itemlist
if item_local.contentSeason > item_local.infoLabels['number_of_seasons'] + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(item_local.infoLabels['number_of_seasons']) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
else:
num_temporada_max = item_local.infoLabels['number_of_seasons']
else:
if item_local.contentSeason > num_temporada_max + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
if num_temporada != item_local.contentSeason:
num_temporada = item_local.contentSeason
num_episodios = 0
if item_local.infoLabels['temporada_num_episodios']:
num_episodios = item_local.infoLabels['temporada_num_episodios']
#Preparamos el título para que sea compatible con Añadir Serie a Videoteca
if item_local.infoLabels['episodio_titulo']:
if "al" in item_local.title: #Si son episodios múltiples, ponemos nombre de serie
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s - %s' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName)
else:
item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo'])
if item_local.infoLabels['year']:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.infoLabels['year'])
if rating:
item_local.infoLabels['episodio_titulo'] = '%s [%s]' % (item_local.infoLabels['episodio_titulo'], rating)
else:
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.contentSerieName, item_local.infoLabels['year'], rating)
item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
item_local.title = '%s [%s] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.title, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language))
#Quitamos campos vacíos
item_local.infoLabels['episodio_titulo'] = item_local.infoLabels['episodio_titulo'].replace(" []", "").strip()
item_local.title = item_local.title.replace(" []", "").strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]-\[\/COLOR\]', '', item_local.title).strip()
if num_episodios < item_local.contentEpisodeNumber:
num_episodios = item_local.contentEpisodeNumber
if num_episodios and not item_local.infoLabels['temporada_num_episodios']:
item_local.infoLabels['temporada_num_episodios'] = num_episodios
num_episodios_flag = False
num_episodios_lista[item_local.contentSeason] = [num_episodios]
#logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag))
#logger.debug(item_local)
try:
if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie
for item_local in itemlist:
item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason]
except:
logger.error("ERROR 07: EPISODIOS: Num de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
if config.get_videolibrary_support() and len(itemlist) > 0:
title = ''
if item_local.infoLabels['temporada_num_episodios']:
title = ' [Temp. de %s ep.]' % item_local.infoLabels['temporada_num_episodios']
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta serie a la videoteca[/COLOR]" + title, action="add_serie_to_library", extra="episodios"))
return itemlist return itemlist
def actualizar_titulos(item):
logger.info()
itemlist = []
from platformcode import launcher
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 launcher.run(item)
def search(item, texto): def search(item, texto):
logger.info("search:" + texto) logger.info("search:" + texto)
# texto = texto.replace(" ", "+") # texto = texto.replace(" ", "+")
+5 -12
View File
@@ -149,7 +149,6 @@ def generos(item):
itemlist = [] itemlist = []
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
data = re.sub(r'"|\n|\r|\t|&nbsp;|<br>|\s{2,}', "", data) data = re.sub(r'"|\n|\r|\t|&nbsp;|<br>|\s{2,}', "", data)
logger.debug(data)
patron = 'genres menu-item-.*?><a href=(.*?)>(.*?)<' patron = 'genres menu-item-.*?><a href=(.*?)>(.*?)<'
matches = re.compile(patron, re.DOTALL).findall(data) matches = re.compile(patron, re.DOTALL).findall(data)
@@ -201,13 +200,11 @@ def alpha(item):
url = 'https://www.ultrapeliculashd.com/wp-json/dooplay/glossary/?term=%s&nonce=4e850b7d59&type=all' % item.id url = 'https://www.ultrapeliculashd.com/wp-json/dooplay/glossary/?term=%s&nonce=4e850b7d59&type=all' % item.id
data = httptools.downloadpage(url).data data = httptools.downloadpage(url).data
dict_data = jsontools.load(data) dict_data = jsontools.load(data)
logger.debug(dict_data) if 'error' not in dict_data:
for elem in dict_data:
for elem in dict_data: elem = dict_data[elem]
logger.debug(dict_data[elem]) itemlist.append(Item(channel=item.channel, action='findvideos', title = elem['title'], url=elem['url'],
elem = dict_data[elem] thumbnail=elem['img']))
itemlist.append(Item(channel=item.channel, action='findvideos', title = elem['title'], url=elem['url'],
thumbnail=elem['img']))
return itemlist return itemlist
@@ -216,19 +213,15 @@ def findvideos(item):
itemlist = [] itemlist = []
data = httptools.downloadpage(item.url).data data = httptools.downloadpage(item.url).data
data = re.sub(r'"|\n|\r|\t|&nbsp;|<br>|\s{2,}', "", data) data = re.sub(r'"|\n|\r|\t|&nbsp;|<br>|\s{2,}', "", data)
#logger.debug(data)
patron = '<iframe.*?rptss src=(.*?) (?:width.*?|frameborder.*?) allowfullscreen><\/iframe>' patron = '<iframe.*?rptss src=(.*?) (?:width.*?|frameborder.*?) allowfullscreen><\/iframe>'
matches = re.compile(patron, re.DOTALL).findall(data) matches = re.compile(patron, re.DOTALL).findall(data)
for video_url in matches: for video_url in matches:
logger.debug('video_url: %s' % video_url)
if 'stream' in video_url and 'streamango' not in video_url: if 'stream' in video_url and 'streamango' not in video_url:
data = httptools.downloadpage('https:'+video_url).data data = httptools.downloadpage('https:'+video_url).data
logger.debug(data)
if not 'iframe' in video_url: if not 'iframe' in video_url:
new_url=scrapertools.find_single_match(data, 'iframe src="(.*?)"') new_url=scrapertools.find_single_match(data, 'iframe src="(.*?)"')
new_data = httptools.downloadpage(new_url).data new_data = httptools.downloadpage(new_url).data
logger.debug('new_data %s' % new_data)
url= '' url= ''
try: try:
url, quality = scrapertools.find_single_match(new_data, 'file:.*?(?:\"|\')(https.*?)(?:\"|\'),' url, quality = scrapertools.find_single_match(new_data, 'file:.*?(?:\"|\')(https.*?)(?:\"|\'),'
+1 -2
View File
@@ -524,8 +524,7 @@ def mark_content_as_watched(item):
# Actualizar toda la serie # Actualizar toda la serie
new_item = item.clone(contentSeason=-1) new_item = item.clone(contentSeason=-1)
mark_season_as_watched(new_item) mark_season_as_watched(new_item)
if config.is_xbmc(): #and item.contentType == 'episode':
if config.is_xbmc() and item.contentType == 'episode':
from platformcode import xbmc_videolibrary from platformcode import xbmc_videolibrary
xbmc_videolibrary.mark_content_as_watched_on_kodi(item, item.playcount) xbmc_videolibrary.mark_content_as_watched_on_kodi(item, item.playcount)
+2 -1
View File
@@ -69,7 +69,8 @@ def list_all(item):
action = 'seasons' action = 'seasons'
if 'episode' in item.url: if 'episode' in item.url:
scrapedtitle, season, episode = scrapertools.find_single_match(scrapedtitle, '(.*?) (\d+)x(\d+)') scrapedtitle, season, episode = scrapertools.find_single_match(scrapedtitle,
'(.*?) (\d+).*?(?:x|X).*?(\d+)')
contentSerieName = scrapedtitle contentSerieName = scrapedtitle
scrapedtitle = '%sx%s - %s' % (season, episode, scrapedtitle) scrapedtitle = '%sx%s - %s' % (season, episode, scrapedtitle)
action='findvideos' action='findvideos'
@@ -531,6 +531,18 @@ def add_movie(item):
""" """
logger.info() logger.info()
#Para desambiguar títulos, se provoca que TMDB pregunte por el título realmente deseado
#El usuario puede seleccionar el título entre los ofrecidos en la primera pantalla
#o puede cancelar e introducir un nuevo título en la segunda pantalla
#Si lo hace en "Introducir otro nombre", TMDB buscará automáticamente el nuevo título
#Si lo hace en "Completar Información", cambia parcialmente al nuevo título, pero no busca en TMDB. Hay que hacerlo
#Si se cancela la segunda pantalla, la variable "scraper_return" estará en False. El usuario no quiere seguir
from lib import generictools
generictools.update_title(item) #Llamamos al método que actualiza el título con tmdb.find_and_set_infoLabels
if item.tmdb_stat:
del item.tmdb_stat #Limpiamos el status para que no se grabe en la Videoteca
new_item = item.clone(action="findvideos") new_item = item.clone(action="findvideos")
insertados, sobreescritos, fallidos = save_movie(new_item) insertados, sobreescritos, fallidos = save_movie(new_item)
@@ -587,6 +599,18 @@ def add_tvshow(item, channel=None):
except ImportError: except ImportError:
exec "import channels." + item.channel + " as channel" exec "import channels." + item.channel + " as channel"
#Para desambiguar títulos, se provoca que TMDB pregunte por el título realmente deseado
#El usuario puede seleccionar el título entre los ofrecidos en la primera pantalla
#o puede cancelar e introducir un nuevo título en la segunda pantalla
#Si lo hace en "Introducir otro nombre", TMDB buscará automáticamente el nuevo título
#Si lo hace en "Completar Información", cambia parcialmente al nuevo título, pero no busca en TMDB. Hay que hacerlo
#Si se cancela la segunda pantalla, la variable "scraper_return" estará en False. El usuario no quiere seguir
from lib import generictools
generictools.update_title(item) #Llamamos al método que actualiza el título con tmdb.find_and_set_infoLabels
if item.tmdb_stat:
del item.tmdb_stat #Limpiamos el status para que no se grabe en la Videoteca
# Obtiene el listado de episodios # Obtiene el listado de episodios
itemlist = getattr(channel, item.action)(item) itemlist = getattr(channel, item.action)(item)
insertados, sobreescritos, fallidos, path = save_tvshow(item, itemlist) insertados, sobreescritos, fallidos, path = save_tvshow(item, itemlist)
+522
View File
@@ -0,0 +1,522 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# GenericTools
# ------------------------------------------------------------
# Código reusable de diferentes partes de los canales que pueden
# ser llamadados desde otros canales, y así carificar el formato
# y resultado de cada canal y reducir el costo su mantenimiento
# ----------------------------------------------------------
import re
import sys
import urllib
import urlparse
import datetime
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
def update_title(item):
logger.info()
from core import scraper
"""
Utilidad para desambiguar Títulos antes de añadirlos a la Videoteca. Puede ser llamado desde Videolibrarytools
o desde Episodios en un Canal. Si se llama desde un canal, la llamada sería así (incluida en post_tmdb_episodios(item, itemlist)):
#Permitimos la actualización de los títulos, bien para uso inmediato, o para añadir a la videoteca
item.from_action = item.action #Salvamos la acción...
item.from_title = item.title #... y el título
itemlist.append(item.clone(title="** [COLOR limegreen]Actualizar Títulos - vista previa videoteca[/COLOR] **", action="actualizar_titulos", extra="episodios", tmdb_stat=False))
El canal deberá añadir un método para poder recibir la llamada desde Kodi/Alfa, y poder llamar a este método:
def actualizar_titulos(item):
logger.info()
itemlist = []
from lib import generictools
from platformcode import launcher
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 launcher.run(item)
Para desambiguar títulos, se provoca que TMDB pregunte por el título realmente deseado, borrando los IDs existentes
El usuario puede seleccionar el título entre los ofrecidos en la primera pantalla
o puede cancelar e introducir un nuevo título en la segunda pantalla
Si lo hace en "Introducir otro nombre", TMDB buscará automáticamente el nuevo título
Si lo hace en "Completar Información", cambia al nuevo título, pero no busca en TMDB. Hay que hacerlo de nuevo
Si se cancela la segunda pantalla, la variable "scraper_return" estará en False. El usuario no quiere seguir
"""
#Restauramos y borramos las etiquetas intermedias (si se ha llamado desde el canal)
if item.from_action:
item.action = item.from_action
del item.from_action
if item.from_title:
item.title = item.from_title
del item.from_title
#Sólo ejecutamos este código si no se ha hecho antes en el Canal. Por ejemplo, si se ha llamado desde Episodios,
#ya no se ejecutará al Añadia a Videoteca, aunque desde el canal se podrá llamar tantas veces como se quiera,
#o hasta que encuentre un título no ambiguo
if not item.tmdb_stat:
new_item = item.clone() #Salvamos el Item inicial para restaurarlo si el usuario cancela
#Borramos los IDs y el año para forzar a TMDB que nos pregunte
if item.infoLabels['tmdb_id'] or item.infoLabels['tmdb_id'] == None: item.infoLabels['tmdb_id'] = ''
if item.infoLabels['tvdb_id'] or item.infoLabels['tvdb_id'] == None: item.infoLabels['tvdb_id'] = ''
if item.infoLabels['imdb_id'] or item.infoLabels['imdb_id'] == None: item.infoLabels['imdb_id'] = ''
if item.infoLabels['season']: del item.infoLabels['season'] #Funciona mal con num. de Temporada. Luego lo restauramos
item.infoLabels['year'] = '-'
if item.contentSerieName: #Copiamos el título para que sirva de referencia en menú "Completar Información"
item.infoLabels['originaltitle'] = item.contentSerieName
item.contentTitle = item.contentSerieName
else:
item.infoLabels['originaltitle'] = item.contentTitle
scraper_return = scraper.find_and_set_infoLabels(item)
if not scraper_return: #Si el usuario ha cancelado, restituimos los datos a la situación inicial y nos vamos
item = new_item.clone()
else:
#Si el usuario ha cambiado los datos en "Completar Información" hay que ver el título definitivo en TMDB
if not item.infoLabels['tmdb_id']:
if item.contentSerieName:
item.contentSerieName = item.contentTitle #Se pone título nuevo
item.infoLabels['noscrap_id'] = '' #Se resetea, por si acaso
item.infoLabels['year'] = '-' #Se resetea, por si acaso
scraper_return = scraper.find_and_set_infoLabels(item) #Se intenta de nuevo
#Parece que el usuario ha cancelado de nuevo. Restituimos los datos a la situación inicial
if not scraper_return or not item.infoLabels['tmdb_id']:
item = new_item.clone()
else:
item.tmdb_stat = True #Marcamos Item como procesado correctamente por TMDB (pasada 2)
else:
item.tmdb_stat = True #Marcamos Item como procesado correctamente por TMDB (pasada 1)
#Si el usuario ha seleccionado una opción distinta o cambiado algo, ajustamos los títulos
if new_item.contentSerieName: #Si es serie...
item.title = item.title.replace(new_item.contentSerieName, item.contentTitle)
item.contentSerieName = item.contentTitle
if new_item.contentSeason: item.contentSeason = new_item.contentSeason #Restauramos Temporada
if item.infoLabels['title']: del item.infoLabels['title'] #Borramos título de peli (es serie)
else: #Si es película...
item.title = item.title.replace(new_item.contentTitle, item.contentTitle)
if new_item.infoLabels['year']: #Actualizamos el Año en el título
item.title = item.title.replace(str(new_item.infoLabels['year']), str(item.infoLabels['year']))
if new_item.infoLabels['rating']: #Actualizamos en Rating en el título
rating_old = ''
if new_item.infoLabels['rating'] and new_item.infoLabels['rating'] != '0.0':
rating_old = float(new_item.infoLabels['rating'])
rating_old = round(rating_old, 1)
rating_new = ''
if item.infoLabels['rating'] and item.infoLabels['rating'] != '0.0':
rating_new = float(item.infoLabels['rating'])
rating_new = round(rating_new, 1)
item.title = item.title.replace("[" + str(rating_old) + "]", "[" + str(rating_new) + "]")
if item.wanted: #Actualizamos Wanted, si existe
item.wanted = item.contentTitle
#Para evitar el "efecto memoria" de TMDB, se le llama con un título ficticio para que resetee los buffers
if item.contentSerieName:
new_item.infoLabels['tmdb_id'] = '289' #una peli no ambigua
else:
new_item.infoLabels['tmdb_id'] = '111' #una serie no ambigua
new_item.infoLabels['year'] = '-'
scraper_return = scraper.find_and_set_infoLabels(new_item)
#logger.debug(item)
return item
def post_tmdb_listado(item, itemlist):
logger.info()
"""
Pasada para maquillaje de los títulos obtenidos desde TMDB en Listado y Listado_Búsqueda.
Toma de infoLabel todos los datos de interés y los va situando en diferentes variables, principalmente título
para que sea compatible con Unify, y si no se tienen Títulos Inteligentes, para que el formato sea lo más
parecido al de Unify.
También restaura varios datos salvados desde el título antes de pasarlo por TMDB, ya que mantenerlos no habría encontrado el título (title_subs)
La llamada al método desde Listado o Listado_Buscar, despues de pasar Itemlist pot TMDB, es:
from lib import generictools
item, itemlist = generictools.post_tmdb_listado(item, itemlist)
"""
for item_local in itemlist: #Recorremos el Itenlist generado por el canal
title = item_local.title
#Restauramos la info adicional guarda en la lista title_subs, y la borramos de Item
if item_local.title_subs and len(item_local.title_subs) > 0:
title += " "
if item_local.title_subs:
for title_subs in item_local.title_subs:
if "audio" in title_subs.lower(): #se restaura info de Audio
title = '%s [%s]' % (title, scrapertools.find_single_match(title_subs, r'[a|A]udio (.*?)'))
continue
if scrapertools.find_single_match(title_subs, r'(\d{4})'): #Se restaura el año, s no lo ha dado TMDB
if not item_local.infoLabels['year'] or item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = scrapertools.find_single_match(title_subs, r'(\d{4})')
continue
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s %s' % (title, title_subs) #se agregan el resto de etiquetas salvadas
else:
title = '%s -%s-' % (title, title_subs) #se agregan el resto de etiquetas salvadas
del item_local.title_subs
#Preparamos el Rating del vídeo
rating = ''
try:
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
except:
pass
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Para Episodios, tomo el año de exposición y no el de inicio de la serie
elif item_local.infoLabels['aired']:
item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})')
# Preparamos el título para series, con los núm. de temporadas, si las hay
if item_local.contentType == "season" or item_local.contentType == "tvshow":
if item.infoLabels['title']: del item.infoLabels['title']
if item_local.contentType == "season":
if scrapertools.find_single_match(item_local.url, '-(\d+)x'):
title = '%s -Temporada %s' % (title, scrapertools.find_single_match(item_local.url, '-(\d+)x'))
if scrapertools.find_single_match(item_local.url, '-temporadas?-(\d+)'):
title = '%s -Temporada %s' % (title, scrapertools.find_single_match(item_local.url, '-temporadas?-(\d+)'))
elif item.action == "search":
title += " -Serie-"
elif item_local.extra == "varios" and item.action == "search":
title += " -Varios-"
item_local.contentTitle += " -Varios-"
#Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
else: #Si Titulos Inteligentes SÍ seleccionados:
title = title.replace("[", "-").replace("]", "-")
#Limpiamos las etiquetas vacías
title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip()
title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title).strip()
title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title).strip()
if item.category == "newest": #Viene de Novedades. Marcamos el título con el nombre del canal
title += ' -%s-' % item_local.channel.capitalize()
if item_local.contentType == "movie":
item_local.contentTitle += ' -%s-' % item_local.channel.capitalize()
item_local.title = title
#logger.debug("url: " + item_local.url + " / title: " + item_local.title + " / content title: " + item_local.contentTitle + "/" + item_local.contentSerieName + " / calidad: " + item_local.quality + "[" + str(item_local.language) + "]" + " / year: " + str(item_local.infoLabels['year']))
#logger.debug(item_local)
return (item, itemlist)
def post_tmdb_episodios(item, itemlist):
logger.info()
"""
Pasada para maquillaje de los títulos obtenidos desde TMDB en Episodios.
Toma de infoLabel todos los datos de interés y los va situando en diferentes variables, principalmente título
para que sea compatible con Unify, y si no se tienen Títulos Inteligentes, para que el formato sea lo más
parecido al de Unify.
Lleva un control del num. de episodios por temporada, tratando de arreglar los errores de la Web y de TMDB
La llamada al método desde Episodios, despues de pasar Itemlist pot TMDB, es:
from lib import generictools
item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
"""
modo_serie_temp = ''
if config.get_setting('seleccionar_serie_temporada', item.channel) >= 0:
modo_serie_temp = config.get_setting('seleccionar_serie_temporada', item.channel)
modo_ultima_temp = ''
if config.get_setting('seleccionar_ult_temporadda_activa', item.channel) is True or config.get_setting('seleccionar_ult_temporadda_activa', item.channel) is False:
modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', item.channel)
#Inicia variables para el control del núm de episodios por temporada
num_episodios = 1
num_episodios_lista = []
for i in range(0, 50): num_episodios_lista += [0]
num_temporada = 1
num_temporada_max = 99
num_episodios_flag = True
for item_local in itemlist: #Recorremos el Itenlist generado por el canal
#Si el título de la serie está verificado en TMDB, se intenta descubrir los eisodios fuera de rango,
#que son probables errores de la Web
if item.tmdb_stat:
if item_local.infoLabels['number_of_seasons']:
#Si el num de temporada está fuera de control, se pone 0, y se reclasifica itemlist
if item_local.contentSeason > item_local.infoLabels['number_of_seasons'] + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(item_local.infoLabels['number_of_seasons']) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
else:
num_temporada_max = item_local.infoLabels['number_of_seasons']
else:
if item_local.contentSeason > num_temporada_max + 1:
logger.error("ERROR 07: EPISODIOS: Num. de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
item_local.contentSeason = 0
itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber)))
#Salvamos en número de episodios de la temporada
try:
if num_temporada != item_local.contentSeason:
num_temporada = item_local.contentSeason
num_episodios = 0
if item_local.infoLabels['temporada_num_episodios'] and int(item_local.infoLabels['temporada_num_episodios']) > int(num_episodios):
num_episodios = item_local.infoLabels['temporada_num_episodios']
except:
num_episodios = 0
#Preparamos el Rating del vídeo
rating = ''
try:
if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
rating = float(item_local.infoLabels['rating'])
rating = round(rating, 1)
except:
pass
# Si TMDB no ha encontrado el vídeo limpiamos el año
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
# Para Episodios, tomo el año de exposición y no el de inicio de la serie
elif item_local.infoLabels['aired']:
item_local.infoLabels['year'] = scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})')
#Preparamos el título para que sea compatible con Añadir Serie a Videoteca
if item.infoLabels['title']: del item.infoLabels['title']
if "Temporada" in item_local.title: #Compatibilizamos "Temporada" con Unify
item_local.title = '%sx%s al 99 -' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber))
if " al " in item_local.title: #Si son episodios múltiples, ponemos nombre de serie
if " al 99" in item_local.title.lower(): #Temporada completa. Buscamos num total de episodios de la temporada
item_local.title = item_local.title.replace("99", str(num_episodios))
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s - %s [%s] [%s]' % (scrapertools.find_single_match(item_local.title, r'(al \d+)'), item_local.contentSerieName, item_local.infoLabels['year'], rating)
elif item_local.infoLabels['episodio_titulo']:
item_local.title = '%s %s' % (item_local.title, item_local.infoLabels['episodio_titulo'])
item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.infoLabels['year'], rating)
else: #Si no hay título de episodio, ponermos el nombre de la serie
item_local.title = '%s %s' % (item_local.title, item_local.contentSerieName)
item_local.infoLabels['episodio_titulo'] = '%s [%s] [%s]' % (item_local.contentSerieName, item_local.infoLabels['year'], rating)
#item_local.infoLabels['title'] = item_local.infoLabels['episodio_titulo']
#Componemos el título final, aunque con Unify usará infoLabels['episodio_titulo']
item_local.title = '%s [%s] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.title, item_local.infoLabels['year'], rating, item_local.quality, str(item_local.language))
#Quitamos campos vacíos
item_local.infoLabels['episodio_titulo'] = item_local.infoLabels['episodio_titulo'].replace(" []", "").strip()
item_local.title = item_local.title.replace(" []", "").strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', item_local.title).strip()
item_local.title = re.sub(r'\s\[COLOR \w+\]-\[\/COLOR\]', '', item_local.title).strip()
#Si la información de num. total de episodios de TMDB no es correcta, tratamos de calcularla
if num_episodios < item_local.contentEpisodeNumber:
num_episodios = item_local.contentEpisodeNumber
if num_episodios and not item_local.infoLabels['temporada_num_episodios']:
item_local.infoLabels['temporada_num_episodios'] = num_episodios
num_episodios_flag = False
num_episodios_lista[item_local.contentSeason] = [num_episodios]
#logger.debug("title: " + item_local.title + " / url: " + item_local.url + " / calidad: " + item_local.quality + " / Season: " + str(item_local.contentSeason) + " / EpisodeNumber: " + str(item_local.contentEpisodeNumber) + " / num_episodios_lista: " + str(num_episodios_lista) + str(num_episodios_flag))
#logger.debug(item_local)
#Terminado el repaso de cada episodio, cerramos con el pié de página
#En primer lugar actualizamos todos los episodios con su núm máximo de episodios por temporada
try:
if not num_episodios_flag: #Si el num de episodios no está informado, acualizamos episodios de toda la serie
for item_local in itemlist:
item_local.infoLabels['temporada_num_episodios'] = num_episodios_lista[item_local.contentSeason]
except:
logger.error("ERROR 07: EPISODIOS: Num de Temporada fuera de rango " + " / TEMPORADA: " + str(item_local.contentSeason) + " / " + str(item_local.contentEpisodeNumber) + " / MAX_TEMPORADAS: " + str(num_temporada_max) + " / LISTA_TEMPORADAS: " + str(num_episodios_lista))
#Permitimos la actualización de los títulos, bien para uso inmediato, o para añadir a la videoteca
item.from_action = item.action #Salvamos la acción...
item.from_title = item.title #... y el título
#item.tmdb_stat=False #Fuerza la actualización de TMDB hasta desambiguar
itemlist.append(item.clone(title="** [COLOR yelow]Actualizar Títulos - vista previa videoteca[/COLOR] **", action="actualizar_titulos", extra="episodios", tmdb_stat=False))
contentSeason = item.contentSeason
if item.contentSeason_save:
contentSeason = item.contentSeason_save
del item.contentSeason_save
#Ponemos el título de Añadir a la Videoteca, con el núm. de episodios de la última temporada y el estado de la Serie
if config.get_videolibrary_support() and len(itemlist) > 0:
title = ''
if item_local.infoLabels['temporada_num_episodios']:
title += ' [Temp. de %s ep.]' % item_local.infoLabels['temporada_num_episodios']
if item_local.infoLabels['status'] and item_local.infoLabels['status'].lower() == "ended":
title += ' [TERMINADA]'
if item_local.quality: #La Videoteca no toma la calidad del episodio, sino de la serie. Pongo del episodio
item.quality = item_local.quality
if modo_serie_temp != '':
#Estamos en un canal que puede seleccionar entre gestionar Series completas o por Temporadas
#Tendrá una línea para Añadir la Serie completa y otra para Añadir sólo la Temporada actual
if item.action == 'get_seasons': #si es actualización desde videoteca, título estándar
#Si hay una nueva Temporada, se activa como la actual
if item.library_urls[item.channel] != item.url and (item.contentType == "season" or modo_ultima_temp):
item.library_urls[item.channel] = item.url #Se actualiza la url apuntando a la última Temporada
try:
from core import videolibrarytools #Se fuerza la actualización de la url en el .nfo
itemlist_fake = [] #Se crea un Itemlist vacio para actualizar solo el .nfo
videolibrarytools.save_tvshow(item, itemlist_fake) #Se actualiza el .nfo
except:
logger.error("ERROR 08: EPISODIOS: No se ha podido actualizar la URL a la nueva Temporada")
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a la Videoteca[/COLOR]" + title, action="add_serie_to_library"))
elif modo_serie_temp == 1: #si es Serie damos la opción de guardar la última temporada o la serie completa
itemlist.append(item.clone(title="[COLOR yellow]Añadir última Temp. a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="season", contentSeason=contentSeason, url=item_local.url))
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="tvshow"))
else: #si no, damos la opción de guardar la temporada actual o la serie completa
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Serie a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="tvshow"))
item.contentSeason = contentSeason
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta Temp. a Videoteca[/COLOR]" + title, action="add_serie_to_library", contentType="season", contentSeason=contentSeason))
else: #Es un canal estándar, sólo una linea de Añadir a Videoteca
itemlist.append(item.clone(title="[COLOR yellow]Añadir esta serie a la videoteca[/COLOR]" + title, action="add_serie_to_library", extra="episodios"))
return (item, itemlist)
def post_tmdb_findvideos(item, itemlist):
logger.info()
"""
Llamada para crear un pseudo título con todos los datos relevantes del vídeo.
Toma de infoLabel todos los datos de interés y los va situando en diferentes variables, principalmente título. Lleva un control del num. de episodios por temporada
La llamada al método desde Findvideos, al principio, es:
from lib import generictools
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
En Itemlist devuelve un Item con el pseudotítulo. Ahí el canal irá agregando el resto.
"""
#Creción de título general del vídeo a visualizar en Findvideos
itemlist = []
# Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal,
# con la función "play_from_library"
item.unify = False
try:
import xbmc
if xbmc.getCondVisibility('Window.IsMedia') == 1:
item.unify = config.get_setting("unify")
except:
item.unify = config.get_setting("unify")
#Salvamos la información de max num. de episodios por temporada para despues de TMDB
if item.infoLabels['temporada_num_episodios']:
num_episodios = item.infoLabels['temporada_num_episodios']
else:
num_episodios = 1
# Obtener la información actualizada del Episodio, si no la hay. Siempre cuando viene de Videoteca
if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'):
tmdb.set_infoLabels(item, True)
elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary":
tmdb.set_infoLabels(item, True)
#Restauramos la información de max num. de episodios por temporada despues de TMDB
try:
if item.infoLabels['temporada_num_episodios'] and int(num_episodios) > int(item.infoLabels['temporada_num_episodios']):
item.infoLabels['temporada_num_episodios'] = num_episodios
except:
pass
#Limpiamos de año y rating de episodios
if item.infoLabels['episodio_titulo']:
item.infoLabels['episodio_titulo'] = re.sub(r'\s?\[.*?\]', '', item.infoLabels['episodio_titulo'])
item.infoLabels['episodio_titulo'] = re.sub(r'\s?\(.*?\)', '', item.infoLabels['episodio_titulo'])
item.infoLabels['episodio_titulo'] = item.infoLabels['episodio_titulo'].replace(item.contentSerieName, '')
if item.infoLabels['aired'] and item.contentType == "episode":
item.infoLabels['year'] = scrapertools.find_single_match(str(item.infoLabels['aired']), r'\/(\d{4})')
rating = '' #Ponemos el rating
try:
if item.infoLabels['rating'] and item.infoLabels['rating'] != '0.0':
rating = float(item.infoLabels['rating'])
rating = round(rating, 1)
except:
pass
#Formateamos de forma especial el título para un episodio
if item.contentType == "episode": #Series
title = '%sx%s' % (str(item.contentSeason), str(item.contentEpisodeNumber).zfill(2)) #Temporada y Episodio
if item.infoLabels['temporada_num_episodios']:
title = '%s (de %s)' % (title, str(item.infoLabels['temporada_num_episodios'])) #Total Episodios
title = '%s %s' % (title, item.infoLabels['episodio_titulo']) #Título Episodio
title_gen = '%s, %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR] [%s]' % (title, item.contentSerieName, item.infoLabels['year'], rating, item.quality, str(item.language), scrapertools.find_single_match(item.title, '\s\[(\d+,?\d*?\s\w[b|B])\]')) #Rating, Calidad, Idioma, Tamaño
if item.infoLabels['status'] and item.infoLabels['status'].lower() == "ended":
title_gen = '[TERM.] %s' % title_gen #Marca cuando la Serie está terminada y no va a haber más producción
item.title = title_gen
else: #Películas
title = item.title
title_gen = item.title
#Limpiamos etiquetas vacías
title_gen = re.sub(r'\s\[COLOR \w+\]\[\[?\]?\]\[\/COLOR\]', '', title_gen).strip() #Quitamos etiquetas vacías
title_gen = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title_gen).strip() #Quitamos colores vacíos
title_gen = title_gen.replace(" []", "").strip() #Quitamos etiquetas vacías
if not item.unify: #Si Titulos Inteligentes NO seleccionados:
title_gen = '**- [COLOR gold]Enlaces Ver: [/COLOR]%s[COLOR gold] -**[/COLOR]' % (title_gen)
else: #Si Titulos Inteligentes SÍ seleccionados:
title_gen = '[COLOR gold]Enlaces Ver: [/COLOR]%s' % (title_gen)
if config.get_setting("quit_channel_name", "videolibrary") == 1 and item.contentChannel == "videolibrary":
title_gen = '%s: %s' % (item.channel.capitalize(), title_gen)
#Pintamos el pseudo-título con toda la información disponible del vídeo
item.action = ""
item.server = ""
itemlist.append(item.clone(title=title_gen)) #Título con todos los datos del vídeo
#logger.debug(item)
return (item, itemlist)
+1 -1
View File
@@ -4,7 +4,7 @@
"ignore_urls": [], "ignore_urls": [],
"patterns": [ "patterns": [
{ {
"pattern": "((?:kbagi.com|diskokosmiko.mx)/[^\\s'\"]+)", "pattern": "((?:k-bagi.com|diskokosmiko.mx)/[^\\s'\"]+)",
"url": "http://\\1" "url": "http://\\1"
} }
] ]
+3 -3
View File
@@ -10,7 +10,7 @@ from platformcode import logger
def test_video_exists(page_url): def test_video_exists(page_url):
logger.info("(page_url='%s')" % page_url) logger.info("(page_url='%s')" % page_url)
domain = "diskokosmiko.mx" domain = "diskokosmiko.mx"
if "kbagi.com" in page_url: if "k-bagi.com" in page_url:
domain = "kbagi.com" domain = "kbagi.com"
logueado, error_message = kbagi.login(domain) logueado, error_message = kbagi.login(domain)
if not logueado: if not logueado:
@@ -28,8 +28,8 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
video_urls = [] video_urls = []
data = httptools.downloadpage(page_url).data data = httptools.downloadpage(page_url).data
host = "http://kbagi.com" host = "http://k-bagi.com"
host_string = "kbagi" host_string = "k-bagi"
if "diskokosmiko.mx" in page_url: if "diskokosmiko.mx" in page_url:
host = "http://diskokosmiko.mx" host = "http://diskokosmiko.mx"
host_string = "diskokosmiko" host_string = "diskokosmiko"