Merge pull request #370 from lopezvg/master

Videolibrary: error al seleccionar canal en ventana flotante
This commit is contained in:
Alfa
2018-07-25 12:02:04 -05:00
committed by GitHub
17 changed files with 789 additions and 479 deletions

View File

@@ -4,7 +4,8 @@
"active": true,
"adult": false,
"language": ["cast"],
"thumbnail": "http://imgur.com/sLaXHvp.png",
"thumbnail": "altorrent.png",
"fanart": "altorrent.jpg",
"categories": [
"torrent",
"movie"
@@ -22,7 +23,7 @@
"id": "include_in_global_search",
"type": "bool",
"label": "Incluir en busqueda global",
"default": true,
"default": false,
"enabled": true,
"visible": true
},

View File

@@ -1,93 +1,261 @@
# -*- coding: utf-8 -*-
import os
import re
import unicodedata
from threading import Thread
import sys
import urllib
import urlparse
from channelselector import get_thumb
from core import httptools
from core import scrapertools
from core import servertools
from core import tmdb
from core.item import Item
from platformcode import config, logger
__modo_grafico__ = config.get_setting('modo_grafico', "ver-pelis")
# Para la busqueda en bing evitando baneos
def browser(url):
import mechanize
# Utilizamos Browser mechanize para saltar problemas con la busqueda en bing
br = mechanize.Browser()
# Browser options
br.set_handle_equiv(False)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(False)
br.set_handle_robots(False)
# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
# Want debugging messages?
# br.set_debug_http(True)
# br.set_debug_redirects(True)
# br.set_debug_responses(True)
# User-Agent (this is cheating, ok?)
# br.addheaders = [('User-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/7.1.7 Safari/537.85.16')]
# br.addheaders =[('Cookie','SRCHD=AF=QBRE; domain=.bing.com; expires=25 de febrero de 2018 13:00:28 GMT+1; MUIDB=3B942052D204686335322894D3086911; domain=www.bing.com;expires=24 de febrero de 2018 13:00:28 GMT+1')]
# Open some site, let's pick a random one, the first that pops in mind
r = br.open(url)
response = r.read()
print response
if "img,divreturn" in response:
r = br.open("http://ssl-proxy.my-addr.org/myaddrproxy.php/" + url)
print "prooooxy"
response = r.read()
return response
api_key = "2e2160006592024ba87ccdf78c28f49f"
api_fankey = "dffe90fba4d02c199ae7a9e71330c987"
from core import tmdb
from lib import generictools
host = 'http://alltorrent.net/'
__modo_grafico__ = config.get_setting('modo_grafico', 'alltorrent')
def mainlist(item):
logger.info()
itemlist = []
i = 0
global i
itemlist.append(item.clone(title="[COLOR springgreen][B]Todas Las Películas[/B][/COLOR]", action="scraper",
url="http://alltorrent.net/", thumbnail="http://imgur.com/XLqPZoF.png",
fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie"))
itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 1080p[/COLOR]", action="scraper",
url="http://alltorrent.net/rezolucia/1080p/", thumbnail="http://imgur.com/XLqPZoF.png",
fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie"))
itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 720p[/COLOR]", action="scraper",
url="http://alltorrent.net/rezolucia/720p/", thumbnail="http://imgur.com/XLqPZoF.png",
fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie"))
itemlist.append(item.clone(title="[COLOR springgreen] Incluyen Hdrip[/COLOR]", action="scraper",
url="http://alltorrent.net/rezolucia/hdrip/", thumbnail="http://imgur.com/XLqPZoF.png",
fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie"))
itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 3D[/COLOR]", action="scraper",
url="http://alltorrent.net/rezolucia/3d/", thumbnail="http://imgur.com/XLqPZoF.png",
fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie"))
itemlist.append(itemlist[-1].clone(title="[COLOR floralwhite][B]Buscar[/B][/COLOR]", action="search",
thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg",
contentType="movie", extra="titulo"))
itemlist.append(itemlist[-1].clone(title="[COLOR oldlace] Por Título[/COLOR]", action="search",
thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg",
contentType="movie", extra="titulo"))
itemlist.append(itemlist[-1].clone(title="[COLOR oldlace] Por Año[/COLOR]", action="search",
thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg",
contentType="movie", extra="año"))
itemlist.append(itemlist[-1].clone(title="[COLOR oldlace] Por Rating Imdb[/COLOR]", action="search",
thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg",
contentType="movie", extra="rating"))
thumb_pelis = get_thumb("channels_movie.png")
thumb_pelis_hd = get_thumb("channels_movie_hd.png")
thumb_series = get_thumb("channels_tvshow.png")
thumb_series_hd = get_thumb("channels_tvshow_hd.png")
thumb_buscar = get_thumb("search.png")
itemlist.append(item.clone(title="[COLOR springgreen][B]Todas Las Películas[/B][/COLOR]", action="listado",
url=host, thumbnail=thumb_pelis, extra="pelicula"))
itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 1080p[/COLOR]", action="listado",
url=host + "rezolucia/1080p/", thumbnail=thumb_pelis_hd, extra="pelicula"))
itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 720p[/COLOR]", action="listado",
url=host + "rezolucia/720p/", thumbnail=thumb_pelis_hd, extra="pelicula"))
itemlist.append(item.clone(title="[COLOR springgreen] Incluyen Hdrip[/COLOR]", action="listado",
url=host + "rezolucia/hdrip/", thumbnail=thumb_pelis, extra="pelicula"))
itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 3D[/COLOR]", action="listado",
url=host + "rezolucia/3d/", thumbnail=thumb_pelis_hd, extra="pelicula"))
itemlist.append(item.clone(title="[COLOR floralwhite][B]Buscar[/B][/COLOR]", action="search", thumbnail=thumb_buscar,
extra="titulo"))
itemlist.append(item.clone(title="[COLOR oldlace] Por Título[/COLOR]", action="search", thumbnail=thumb_buscar,
extra="titulo"))
itemlist.append(item.clone(title="[COLOR oldlace] Por Año[/COLOR]", action="search", thumbnail=thumb_buscar,
extra="o"))
itemlist.append(item.clone(title="[COLOR oldlace] Por Rating Imdb[/COLOR]", action="search", thumbnail=thumb_buscar,
extra="rating"))
return itemlist
def listado(item):
logger.info()
itemlist = []
# Descarga la página
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
except:
pass
if not data: #Si la web está caída salimos sin dar error
logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
patron = '<div class="browse-movie-wrap col-xs-10 col-sm-4 col-md-5 col-lg-4"><a href="([^"]+)".*?src="([^"]+)".*?alt="([^"]+)".*?rel="tag">([^"]+)<\/a>\s?<\/div><div class="[^"]+">(.*?)<\/div><\/div><\/div>'
#data = scrapertools.find_single_match(data, patron)
matches = re.compile(patron, re.DOTALL).findall(data)
if not matches and not '<ul class="tsc_pagination tsc_pagination' in data: #error
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_episodios(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: LISTADO: Ha cambiado la estructura de la Web. Reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
#logger.debug("PATRON: " + patron)
#logger.debug(matches)
#logger.debug(data)
for scrapedurl, scrapedthumbnail, scrapedtitle, scrapedyear, scrapedqualities in matches:
item_local = item.clone() #Creamos copia de Item para trabajar
title_subs = []
title = re.sub('\r\n', '', scrapedtitle).decode('utf8').strip()
item_local.url = scrapedurl
item_local.thumbnail = scrapedthumbnail
scrapedtorrent = ''
if scrapedqualities:
patron_quality = '<a href="([^"]+)"\s?rel="[^"]+"\s?title="[^"]+">(.*?)<\/a>'
matches_quality = re.compile(patron_quality, re.DOTALL).findall(scrapedqualities)
quality = ''
for scrapedtorrent, scrapedquality in matches_quality:
quality_inter = scrapedquality
quality_inter = re.sub('HDr$', 'HDrip', quality_inter)
quality_inter = re.sub('720$', '720p', quality_inter)
quality_inter = re.sub('1080$', '1080p', quality_inter)
if quality:
quality += ', %s' % quality_inter
else:
quality = quality_inter
if quality:
item_local.quality = quality
item_local.language = [] #Verificamos el idioma por si encontramos algo
if "latino" in scrapedtorrent.lower() or "latino" in item.url or "latino" in title.lower():
item_local.language += ["LAT"]
if "ingles" in scrapedtorrent.lower() or "ingles" in item.url or "vose" in scrapedurl or "vose" in item.url:
if "VOSE" in scrapedtorrent.lower() or "sub" in title.lower() or "vose" in scrapedurl or "vose" in item.url:
item_local.language += ["VOS"]
else:
item_local.language += ["VO"]
if "dual" in scrapedtorrent.lower() or "dual" in title.lower():
item_local.language[0:0] = ["DUAL"]
#Limpiamos el título de la basura innecesaria
title = title.replace("Dual", "").replace("dual", "").replace("Subtitulada", "").replace("subtitulada", "").replace("Subt", "").replace("subt", "").replace("Sub", "").replace("sub", "").replace("(Proper)", "").replace("(proper)", "").replace("Proper", "").replace("proper", "").replace("#", "").replace("(Latino)", "").replace("Latino", "")
title = title.replace("- HDRip", "").replace("(HDRip)", "").replace("- Hdrip", "").replace("(microHD)", "").replace("(DVDRip)", "").replace("(HDRip)", "").replace("(BR-LINE)", "").replace("(HDTS-SCREENER)", "").replace("(BDRip)", "").replace("(BR-Screener)", "").replace("(DVDScreener)", "").replace("TS-Screener", "").replace(" TS", "").replace(" Ts", "")
title = re.sub(r'\??\s?\d*?\&.*', '', title).title().strip()
item_local.contentType = "movie"
item_local.contentTitle = title
item_local.extra = "peliculas"
item_local.action = "findvideos"
item_local.title = title.strip()
item_local.infoLabels['year'] = "-"
if scrapedyear >= "1900" and scrapedyear <= "2040":
title_subs += [scrapedyear]
itemlist.append(item_local.clone()) #Pintar pantalla
if not item.category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global
return itemlist #Retornamos sin pasar por la fase de maquillaje para ahorra tiempo
#Pasamos a TMDB la lista completa Itemlist
tmdb.set_infoLabels(itemlist, True)
#Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
item, itemlist = generictools.post_tmdb_listado(item, itemlist)
# Extrae el paginador
patron = '<li><a href="[^"]+">(\d+)<\/a><\/li>' #total de páginas
patron += '<li><a href="([^"]+\/page\/(\d+)\/)"\s?rel="[^"]+">Página siguiente[^<]+<\/a><\/li><\/ul><\/div><\/ul>' #url siguiente
url_next = ''
if scrapertools.find_single_match(data, patron):
last_page, url_next, next_num = scrapertools.find_single_match(data, patron)
if url_next:
if last_page:
title = '[COLOR gold]Página siguiente >>[/COLOR] %s de %s' % (int(next_num) - 1, last_page)
else:
title = '[COLOR gold]Página siguiente >>[/COLOR] %s' % (int(next_num) - 1)
itemlist.append(Item(channel=item.channel, action="listado", title=title, url=url_next, extra=item.extra))
return itemlist
def findvideos(item):
logger.info()
itemlist = []
#Bajamos los datos de la página
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
except:
pass
if not data:
logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
patron = 'id="modal-quality-\w+"><span>(.*?)</span>.*?class="quality-size">(.*?)</p>.*?href="([^"]+)"' #coge los .torrent
matches = re.compile(patron, re.DOTALL).findall(data)
if not matches: #error
logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
#Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist)
#logger.debug("PATRON: " + patron)
#logger.debug(matches)
for scrapedquality, scrapedsize, scrapedtorrent in matches: #leemos los torrents con la diferentes calidades
#Generamos una copia de Item para trabajar sobre ella
item_local = item.clone()
item_local.quality = scrapedquality
if item.infoLabels['duration']:
item_local.quality += scrapertools.find_single_match(item.quality, '(\s\[.*?\])') #Copiamos la duración
#Añadimos el tamaño para todos
item_local.quality = '%s [%s]' % (item_local.quality, scrapedsize) #Agregamos size al final de calidad
item_local.quality = item_local.quality.replace("G", "G ").replace("M", "M ") #Se evita la palabra reservada en Unify
#Ahora pintamos el link del Torrent
item_local.url = scrapedtorrent
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) #Quitamos etiquetas vacías
item_local.title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', item_local.title) #Quitamos colores vacíos
item_local.alive = "??" #Calidad del link sin verificar
item_local.action = "play" #Visualizar vídeo
item_local.server = "torrent" #Seridor Torrent
itemlist.append(item_local.clone()) #Pintar pantalla
#logger.debug("TORRENT: " + scrapedtorrent + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + scrapedsize + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName)
#logger.debug(item_local)
#Ahora tratamos el servidor directo
item_local = item.clone()
servidor = 'openload'
enlace = scrapertools.find_single_match(data, 'button-green-download-big".*?href="([^"]+)"><span class="icon-play">')
if enlace:
try:
devuelve = servertools.findvideosbyserver(enlace, servidor) #existe el link ?
if devuelve:
enlace = devuelve[0][1] #Se guarda el link
item_local.alive = "??" #Se asume poe defecto que es link es dudoso
#Llama a la subfunción de check_list_links(itemlist) para cada link de servidor
item_local.alive = servertools.check_video_link(enlace, servidor, timeout=5) #activo el link ?
#Si el link no está activo se ignora
if item_local.alive == "??": #dudoso
item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (servidor.capitalize(), item_local.quality, str(item_local.language))
elif item_local.alive.lower() == "no": #No está activo. Lo preparo, pero no lo pinto
item_local.title = '[COLOR red][%s][/COLOR] [COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.alive, servidor.capitalize(), item_local.quality, str(item_local.language))
logger.debug(item_local.alive + ": ALIVE / " + title + " / " + servidor + " / " + enlace)
raise
else: #Sí está activo
item_local.title = '[COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (servidor.capitalize(), item_local.quality, str(item_local.language))
#Preparamos el resto de variables de Item para ver los vídeos en directo
item_local.action = "play"
item_local.server = servidor
item_local.url = enlace
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()
itemlist.append(item_local.clone())
#logger.debug(item_local)
except:
pass
return itemlist
@@ -96,305 +264,17 @@ def search(item, texto):
logger.info()
texto = texto.replace(" ", "+")
if item.extra == "titulo":
item.url = "http://alltorrent.net/?s=" + texto
item.url = host + "?s=" + texto
elif item.extra == "año":
item.url = "http://alltorrent.net/weli/" + texto
item.url = host + "weli/" + texto + "/"
else:
item.url = "http://alltorrent.net/imdb/" + texto
item.extra == "imdb"
item.url = host + "imdb/" + texto + "/"
if texto != '':
return scraper(item)
def scraper(item):
logger.info()
itemlist = []
data = httptools.downloadpage(item.url).data
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data)
patron = scrapertools.find_multiple_matches(data,
'<div class="browse-movie-wrap col-xs-10 col-sm-4 col-md-5 col-lg-4"><a href="([^"]+)".*?src="([^"]+)".*?alt="([^"]+)".*?rel="tag">([^"]+)</a> ')
for url, thumb, title, year in patron:
title = re.sub(r"\(\d+\)", "", title)
title = ''.join((c for c in unicodedata.normalize('NFD', unicode(title.decode('utf-8'))) if
unicodedata.category(c) != 'Mn')).encode("ascii", "ignore")
titulo = "[COLOR lime]" + title + "[/COLOR]"
title = re.sub(r"!|\/.*", "", title).strip()
new_item = item.clone(action="findvideos", title=titulo, url=url, thumbnail=thumb, fulltitle=title,
contentTitle=title, contentType="movie", library=True)
new_item.infoLabels['year'] = year
itemlist.append(new_item)
## Paginación
next = scrapertools.find_single_match(data, '<li><a href="([^"]+)" rel="nofollow">Next Page')
if len(next) > 0:
url = next
itemlist.append(item.clone(title="[COLOR olivedrab][B]Siguiente >>[/B][/COLOR]", action="scraper", url=url,
thumbnail="http://imgur.com/TExhOJE.png"))
try:
from core import tmdb
tmdb.set_infoLabels_itemlist(itemlist, __modo_grafico__)
for item in itemlist:
if not "Siguiente >>" in item.title:
if "0." in str(item.infoLabels['rating']):
item.infoLabels['rating'] = "[COLOR olive]Sin puntuación[/COLOR]"
else:
item.infoLabels['rating'] = "[COLOR yellow]" + str(item.infoLabels['rating']) + "[/COLOR]"
item.title = item.title + " " + str(item.infoLabels['rating'])
except:
pass
for item_tmdb in itemlist:
logger.info(str(item_tmdb.infoLabels['tmdb_id']))
return itemlist
def findvideos(item):
logger.info()
itemlist = []
th = Thread(target=get_art(item))
th.setDaemon(True)
th.start()
data = httptools.downloadpage(item.url).data
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data)
enlaces = scrapertools.find_multiple_matches(data,
'id="modal-quality-\w+"><span>(.*?)</span>.*?class="quality-size">(.*?)</p>.*?href="([^"]+)"')
for calidad, size, url in enlaces:
title = "[COLOR palegreen][B]Torrent[/B][/COLOR]" + " " + "[COLOR chartreuse]" + calidad + "[/COLOR]" + "[COLOR teal] ( [/COLOR]" + "[COLOR forestgreen]" + size + "[/COLOR]" + "[COLOR teal] )[/COLOR]"
itemlist.append(
Item(channel=item.channel, title=title, url=url, action="play", server="torrent", fanart=item.fanart,
thumbnail=item.thumbnail, extra=item.extra, InfoLabels=item.infoLabels, folder=False))
dd = scrapertools.find_single_match(data, 'button-green-download-big".*?href="([^"]+)"><span class="icon-play">')
if dd:
if item.library:
itemlist.append(
Item(channel=item.channel, title="[COLOR floralwhite][B]Online[/B][/COLOR]", url=dd, action="dd_y_o",
thumbnail="http://imgur.com/mRmBIV4.png", fanart=item.extra.split("|")[0],
contentType=item.contentType, extra=item.extra, folder=True))
else:
videolist = servertools.find_video_items(data=str(dd))
for video in videolist:
icon_server = os.path.join(config.get_runtime_path(), "resources", "images", "servers",
"server_" + video.server + ".png")
if not os.path.exists(icon_server):
icon_server = ""
itemlist.append(Item(channel=item.channel, url=video.url, server=video.server,
title="[COLOR floralwhite][B]" + video.server + "[/B][/COLOR]",
thumbnail=icon_server, fanart=item.extra.split("|")[1], action="play",
folder=False))
if item.library and config.get_videolibrary_support() and itemlist:
infoLabels = {'tmdb_id': item.infoLabels['tmdb_id'],
'title': item.infoLabels['title']}
itemlist.append(Item(channel=item.channel, title="Añadir esta película a la videoteca",
action="add_pelicula_to_library", url=item.url, infoLabels=infoLabels,
text_color="0xFFe5ffcc",
thumbnail='http://imgur.com/DNCBjUB.png', extra="library"))
return itemlist
def dd_y_o(item):
itemlist = []
logger.info()
videolist = servertools.find_video_items(data=item.url)
for video in videolist:
icon_server = os.path.join(config.get_runtime_path(), "resources", "images", "servers",
"server_" + video.server + ".png")
if not os.path.exists(icon_server):
icon_server = ""
itemlist.append(Item(channel=item.channel, url=video.url, server=video.server,
title="[COLOR floralwhite][B]" + video.server + "[/B][/COLOR]", thumbnail=icon_server,
fanart=item.extra.split("|")[1], action="play", folder=False))
return itemlist
def fanartv(item, id_tvdb, id, images={}):
headers = [['Content-Type', 'application/json']]
from core import jsontools
if item.contentType == "movie":
url = "http://webservice.fanart.tv/v3/movies/%s?api_key=cab16e262d72fea6a6843d679aa10300" \
% id
else:
url = "http://webservice.fanart.tv/v3/tv/%s?api_key=cab16e262d72fea6a6843d679aa10300" % id_tvdb
try:
data = jsontools.load(scrapertools.downloadpage(url, headers=headers))
if data and not "error message" in data:
for key, value in data.items():
if key not in ["name", "tmdb_id", "imdb_id", "thetvdb_id"]:
images[key] = value
else:
images = []
except:
images = []
return images
def get_art(item):
logger.info()
id = item.infoLabels['tmdb_id']
check_fanart = item.infoLabels['fanart']
if item.contentType != "movie":
tipo_ps = "tv"
else:
tipo_ps = "movie"
if not id:
year = item.extra
otmdb = tmdb.Tmdb(texto_buscado=item.fulltitle, year=year, tipo=tipo_ps)
id = otmdb.result.get("id")
if id == None:
otmdb = tmdb.Tmdb(texto_buscado=item.fulltitle, tipo=tipo_ps)
id = otmdb.result.get("id")
if id == None:
if item.contentType == "movie":
urlbing_imdb = "http://www.bing.com/search?q=%s+%s+tv+series+site:imdb.com" % (
item.fulltitle.replace(' ', '+'), year)
data = browser(urlbing_imdb)
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;|http://ssl-proxy.my-addr.org/myaddrproxy.php/", "", data)
subdata_imdb = scrapertools.find_single_match(data,
'<li class="b_algo">(.*?)h="ID.*?<strong>.*?TV Series')
else:
urlbing_imdb = "http://www.bing.com/search?q=%s+%s+site:imdb.com" % (
item.fulltitle.replace(' ', '+'), year)
data = browser(urlbing_imdb)
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;|http://ssl-proxy.my-addr.org/myaddrproxy.php/", "", data)
subdata_imdb = scrapertools.find_single_match(data, '<li class="b_algo">(.*?)h="ID.*?<strong>')
try:
imdb_id = scrapertools.get_match(subdata_imdb, '<a href=.*?http.*?imdb.com/title/(.*?)/.*?"')
except:
try:
imdb_id = scrapertools.get_match(subdata_imdb,
'<a href=.*?http.*?imdb.com/.*?/title/(.*?)/.*?"')
except:
imdb_id = ""
otmdb = tmdb.Tmdb(external_id=imdb_id, external_source="imdb_id", tipo=tipo_ps, idioma_busqueda="es")
id = otmdb.result.get("id")
if id == None:
if "(" in item.fulltitle:
title = scrapertools.find_single_match(item.fulltitle, '\(.*?\)')
if item.contentType != "movie":
urlbing_imdb = "http://www.bing.com/search?q=%s+%s+tv+series+site:imdb.com" % (
title.replace(' ', '+'), year)
data = browser(urlbing_imdb)
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;|http://ssl-proxy.my-addr.org/myaddrproxy.php/", "",
data)
subdata_imdb = scrapertools.find_single_match(data,
'<li class="b_algo">(.*?)h="ID.*?<strong>.*?TV Series')
else:
urlbing_imdb = "http://www.bing.com/search?q=%s+%s+site:imdb.com" % (
title.replace(' ', '+'), year)
data = browser(urlbing_imdb)
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;|http://ssl-proxy.my-addr.org/myaddrproxy.php/", "",
data)
subdata_imdb = scrapertools.find_single_match(data,
'<li class="b_algo">(.*?)h="ID.*?<strong>')
try:
imdb_id = scrapertools.get_match(subdata_imdb,
'<a href=.*?http.*?imdb.com/title/(.*?)/.*?"')
except:
try:
imdb_id = scrapertools.get_match(subdata_imdb,
'<a href=.*?http.*?imdb.com/.*?/title/(.*?)/.*?"')
except:
imdb_id = ""
otmdb = tmdb.Tmdb(external_id=imdb_id, external_source="imdb_id", tipo=tipo_ps,
idioma_busqueda="es")
id = otmdb.result.get("id")
if not id:
fanart = item.fanart
id_tvdb = ""
imagenes = []
itmdb = tmdb.Tmdb(id_Tmdb=id, tipo=tipo_ps)
images = itmdb.result.get("images")
if images:
for key, value in images.iteritems():
for detail in value:
imagenes.append('http://image.tmdb.org/t/p/original' + detail["file_path"])
if len(imagenes) >= 4:
if imagenes[0] != check_fanart:
item.fanart = imagenes[0]
else:
item.fanart = imagenes[1]
if imagenes[1] != check_fanart and imagenes[1] != item.fanart and imagenes[2] != check_fanart:
item.extra = imagenes[1] + "|" + imagenes[2]
else:
if imagenes[1] != check_fanart and imagenes[1] != item.fanart:
item.extra = imagenes[1] + "|" + imagenes[3]
elif imagenes[2] != check_fanart:
item.extra = imagenes[2] + "|" + imagenes[3]
else:
item.extra = imagenes[3] + "|" + imagenes[3]
elif len(imagenes) == 3:
if imagenes[0] != check_fanart:
item.fanart = imagenes[0]
else:
item.fanart = imagenes[1]
if imagenes[1] != check_fanart and imagenes[1] != item.fanart and imagenes[2] != check_fanart:
item.extra = imagenes[1] + "|" + imagenes[2]
else:
if imagenes[1] != check_fanart and imagenes[1] != item.fanart:
item.extra = imagenes[0] + "|" + imagenes[1]
elif imagenes[2] != check_fanart:
item.extra = imagenes[1] + "|" + imagenes[2]
else:
item.extra = imagenes[1] + "|" + imagenes[1]
elif len(imagenes) == 2:
if imagenes[0] != check_fanart:
item.fanart = imagenes[0]
else:
item.fanart = imagenes[1]
if imagenes[1] != check_fanart and imagenes[1] != item.fanart:
item.extra = imagenes[0] + "|" + imagenes[1]
else:
item.extra = imagenes[1] + "|" + imagenes[0]
elif len(imagenes) == 1:
item.extra = imagenes + "|" + imagenes
else:
item.extra = item.fanart + "|" + item.fanart
images_fanarttv = fanartv(item, id_tvdb, id)
if images_fanarttv:
if item.contentType == "movie":
if images_fanarttv.get("moviedisc"):
item.thumbnail = images_fanarttv.get("moviedisc")[0].get("url")
elif images_fanarttv.get("hdmovielogo"):
item.thumbnail = images_fanarttv.get("hdmovielogo")[0].get("url")
elif images_fanarttv.get("moviethumb"):
item.thumbnail = images_fanarttv.get("moviethumb")[0].get("url")
elif images_fanarttv.get("moviebanner"):
item.thumbnail_ = images_fanarttv.get("moviebanner")[0].get("url")
else:
item.thumbnail = item.thumbnail
else:
if images_fanarttv.get("hdtvlogo"):
item.thumbnail = images_fanarttv.get("hdtvlogo")[0].get("url")
elif images_fanarttv.get("clearlogo"):
item.thumbnail = images_fanarttv.get("hdmovielogo")[0].get("url")
if images_fanarttv.get("tvbanner"):
item.extra = item.extra + "|" + images_fanarttv.get("tvbanner")[0].get("url")
elif images_fanarttv.get("tvthumb"):
item.extra = item.extra + "|" + images_fanarttv.get("tvthumb")[0].get("url")
else:
item.extra = item.extra + "|" + item.thumbnail
else:
item.extra = item.extra + "|" + item.thumbnail
return listado(item)
def newest(categoria):
logger.info()
itemlist = []
@@ -402,11 +282,11 @@ def newest(categoria):
try:
if categoria == 'torrent':
item.url = host
item.extra = "peliculas"
itemlist = scraper(item)
if itemlist[-1].action == "[COLOR olivedrab][B]Siguiente >>[/B][/COLOR]":
itemlist.pop()
itemlist = listado(item)
if itemlist[-1].title == "Página siguiente >>":
itemlist.pop()
# Se captura la excepción, para no interrumpir al canal novedades si un canal falla
except:

View File

@@ -40,9 +40,13 @@ def submenu(item):
logger.info()
itemlist = []
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
except:
pass
if not data:
logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log'))
return itemlist #Algo no funciona, pintamos lo que tenemos
@@ -55,6 +59,13 @@ def submenu(item):
patron = '<a href="(.*?)".*?title="(.*?)"' #Encontrar todos los apartados
matches = re.compile(patron, re.DOTALL).findall(data1)
if not matches:
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
for clone_inter, autoridad in item.intervencion:
thumb_intervenido = get_thumb(autoridad)
itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido))
return itemlist #Salimos
logger.error("ERROR 02: SUBMENU: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data1)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: SUBMENU: Ha cambiado la estructura de la Web. Reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
@@ -86,16 +97,16 @@ def listado(item):
itemlist = []
# Descarga la página
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
except:
logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
pass
if not data: #Si la web está caída salimos sin dar error
logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
patron = '<div id="principal">.*?<\/nav><\/div><\/div>'
data = scrapertools.find_single_match(data, patron)
@@ -110,9 +121,14 @@ def listado(item):
matches = re.compile(patron, re.DOTALL).findall(data)
if not matches and not '<title>503 Backend fetch failed</title>' in data: #error
logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: LISTADO: Ha cambiado la estructura de la Web. Reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: LISTADO: Ha cambiado la estructura de la Web. Reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
#logger.debug("PATRON: " + patron)
#logger.debug(matches)
@@ -153,7 +169,7 @@ def listado(item):
if "dual" in scrapedcategory.lower() or "dual" in title.lower():
item_local.language[0:0] = ["DUAL"]
#Limpiamos el título de la basuna innecesaria
#Limpiamos el título de la basura innecesaria
title = title.replace("Dual", "").replace("dual", "").replace("Subtitulada", "").replace("subtitulada", "").replace("Subt", "").replace("subt", "").replace("Sub", "").replace("sub", "").replace("(Proper)", "").replace("(proper)", "").replace("Proper", "").replace("proper", "").replace("#", "").replace("(Latino)", "").replace("Latino", "")
title = title.replace("- HDRip", "").replace("(HDRip)", "").replace("- Hdrip", "").replace("(microHD)", "").replace("(DVDRip)", "").replace("(HDRip)", "").replace("(BR-LINE)", "").replace("(HDTS-SCREENER)", "").replace("(BDRip)", "").replace("(BR-Screener)", "").replace("(DVDScreener)", "").replace("TS-Screener", "").replace(" TS", "").replace(" Ts", "")
title = re.sub(r'\??\s?\d*?\&.*', '', title).title().strip()
@@ -199,11 +215,11 @@ def listado(item):
itemlist.append(item_local.clone()) #Pintar pantalla
#if not item.category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global
# return itemlist #Retornamos sin pasar por la fase de maquillaje para ahorra tiempo
if not item.category: #Si este campo no existe es que viene de la primera pasada de una búsqueda global
return itemlist #Retornamos sin pasar por la fase de maquillaje para ahorra tiempo
#Pasamos a TMDB la lista completa Itemlist
#tmdb.set_infoLabels(itemlist, True)
tmdb.set_infoLabels(itemlist, True)
#Llamamos al método para el maquillaje de los títulos obtenidos desde TMDB
item, itemlist = generictools.post_tmdb_listado(item, itemlist)
@@ -239,9 +255,13 @@ def findvideos(item):
itemlist = []
#Bajamos los datos de la página
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
except:
pass
if not data:
logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
@@ -268,6 +288,11 @@ def findvideos(item):
#logger.info("link Magnet: " + link_magnet)
if not link_torrent and not link_magnet: #error
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron_t + " / " + patron_m + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos

View File

@@ -63,9 +63,13 @@ def submenu(item):
thumb_buscar = get_thumb("search.png")
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
except:
pass
if not data:
logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log'))
return itemlist #Algo no funciona, pintamos lo que tenemos
@@ -73,6 +77,13 @@ def submenu(item):
if item.extra == "peliculas":
patron = '<li class="navigation-top">.*?<a href="(.*?)".*?class="nav"> (.*?)\s?<\/a><\/li>'
matches = re.compile(patron, re.DOTALL).findall(data)
if not matches:
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
for clone_inter, autoridad in item.intervencion:
thumb_intervenido = get_thumb(autoridad)
itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido))
return itemlist #Salimos
itemlist.append(item.clone(action="listado", title="Novedades", url=host)) #Menú principal películas
@@ -87,6 +98,13 @@ def submenu(item):
else: #Tratamos Series
patron = '<li class="navigation-top-dcha">.*?<a href="(.*?)".*?class="series"> (.*?)\s?<\/a><\/li>'
matches = re.compile(patron, re.DOTALL).findall(data)
if not matches:
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
for clone_inter, autoridad in item.intervencion:
thumb_intervenido = get_thumb(autoridad)
itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido))
return itemlist #Salimos
for scrapedurl, scrapedtitle in matches:
scrapedtitle = re.sub('\r\n', '', scrapedtitle).decode('utf8').encode('utf8').strip()
@@ -121,6 +139,7 @@ def listado(item):
while cnt_title <= cnt_tot and cnt_next < cnt_top:
# Descarga la página
data = ''
try:
if not item.post:
item.post = item.url
@@ -128,9 +147,8 @@ def listado(item):
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.post).data)
video_section = scrapertools.find_single_match(data, '<div class="contenedor-home">(.*?</div>)</div></div>')
except:
logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + video_section)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
pass
cnt_next += 1
if not data: #Si la web está caída salimos sin dar error
logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + video_section)
@@ -178,6 +196,11 @@ def listado(item):
matches_alt = re.compile(patron, re.DOTALL).findall(video_section)
if not matches_alt and not '<div class="titulo-load-core">0 resultados' in data: #error
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: LISTADO: Ha cambiado la estructura de la Web. Reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
@@ -349,9 +372,13 @@ def findvideos(item):
itemlist = []
#Bajamos los datos de la página
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data)
except:
pass
if not data:
logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
@@ -361,6 +388,11 @@ 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>.*?)?"'
matches = re.compile(patron, re.DOTALL).findall(data)
if not matches: #error
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
@@ -421,7 +453,10 @@ def findvideos(item):
#Tratamos la calidad y tamaño de cada link
if quality:
item_local.quality = quality
tiempo = ''
if item_local.quality:
tiempo = scrapertools.find_single_match(item_local.quality, r'(\s\[.*?\])')
item_local.quality = quality + tiempo
if "temporada" in temp_epi.lower():
item_local.quality = '%s [Temporada]' % item_local.quality
#if size and item_local.contentType != "episode":
@@ -460,6 +495,7 @@ def episodios(item):
if not item.infoLabels['tmdb_id']:
tmdb.set_infoLabels(item, True)
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) #Cargamos los datos de la página
@@ -648,6 +684,11 @@ def episodios(item):
patron = '\/icono_.*?png" title="(?P<lang>.*?)?" [^>]+><\/td><td>(?P<temp_epi>.*?)?<?\/td>.*?<td>(?P<quality>.*?)?<\/td><td><a class="link" href="(?P<url>.*?)?"'
matches = re.compile(patron, re.DOTALL).findall(data)
if not matches: #error
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_episodios(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web. Reportar el error con el log'))
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos

View File

@@ -1,18 +1,17 @@
{
"active": true,
"adult": false,
"banner": "mejortorrent.png",
"id": "mejortorrent",
"name": "Mejor Torrent",
"active": true,
"adult": false,
"language": ["*"],
"thumbnail": "thumb_intervenido_pn.jpeg",
"banner": "mejortorrent.png",
"categories": [
"torrent",
"movie",
"tvshow",
"torrent",
"movie",
"tvshow",
"documentary"
],
"id": "mejortorrent",
"language": [
"*"
],
"name": "Mejor Torrent",
],
"settings": [
{
"default": "http://www.mejortorrent.com/",
@@ -62,6 +61,5 @@
"type": "bool",
"visible": true
}
],
"thumbnail": ", thumb_intervenido_pn.jpeg"
]
}

View File

@@ -515,6 +515,7 @@ def listado_busqueda(item):
while cnt_title <= cnt_tot and cnt_next < 5:
status = False # Calidad de los datos leídos
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(url_next_page, post=item.post).data)
data = re.sub('\r\n', '', data).decode('utf8').encode('utf8')
@@ -851,10 +852,14 @@ def episodios(item):
tmdb.set_infoLabels(item, True)
# Carga la página
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data)
data = data.replace('"', "'")
except: #Algún error de proceso, salimos
pass
if not data:
logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea" + item.url)
itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: EPISODIOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log'))
return itemlist

View File

@@ -61,6 +61,11 @@ elif fecha_rango == 3: fecha_rango = 'Mes'
elif fecha_rango == 4: fecha_rango = 'Siempre'
episodio_serie = config.get_setting('clonenewpct1_serie_episodio_novedades', channel_py) #Episodio o serie para Novedades
#Temporal, sólo para actualizar newpct1_data.json con otro valor por defecto
channel_banned = config.get_setting('clonenewpct1_excluir1_enlaces_veronline', channel_py) #1er Canal baneado
if channel_banned == 9:
config.set_setting('clonenewpct1_excluir1_enlaces_veronline', 22, channel_py) #se pone el nuevo valor por defecto
def mainlist(item):
logger.info()
@@ -129,6 +134,13 @@ def submenu(item):
patron = '<li><a\s?class="[^"]+"\s?href="http:[^"]+"><i\s?class=.*><\/i>.*Inicio<\/a><\/li>(.+)<\/ul>\s?<\/nav>'
#Verificamos si se ha cargado una página, y si además tiene la estructura correcta
if not data or not scrapertools.find_single_match(data, patron):
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
for clone_inter, autoridad in item.intervencion:
thumb_intervenido = get_thumb(autoridad)
itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido))
return itemlist #Salimos
logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url + data)
#Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú
item, data = generictools.fail_over_newpct1(item, patron)
@@ -206,6 +218,13 @@ def submenu_novedades(item):
patron = '<div class="content">.*?<ul class="noticias'
#Verificamos si se ha cargado una página, y si además tiene la estructura correcta
if not data or not scrapertools.find_single_match(data, patron):
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
for clone_inter, autoridad in item.intervencion:
thumb_intervenido = get_thumb(autoridad)
itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido))
return itemlist #Salimos
logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url + data)
#Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú
item, data = generictools.fail_over_newpct1(item, patron)
@@ -274,6 +293,13 @@ def alfabeto(item):
patron = '<ul class="alfabeto">(.*?)</ul>'
if not data or not scrapertools.find_single_match(data, patron):
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
for clone_inter, autoridad in item.intervencion:
thumb_intervenido = get_thumb(autoridad)
itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido))
return itemlist #Salimos
logger.error("ERROR 01: ALFABETO: La Web no responde o ha cambiado de URL: " + item.url + data)
#Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú
item, data = generictools.fail_over_newpct1(item, patron)
@@ -325,6 +351,11 @@ def listado(item):
patron = '<ul class="' + clase + '">(.*?)</ul>' #seleccionamos el bloque que nos interesa
if not data or (not scrapertools.find_single_match(data, patron) and not '<h3><strong>( 0 ) Resultados encontrados </strong>' in data):
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data)
#Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú
item, data = generictools.fail_over_newpct1(item, patron)
@@ -645,6 +676,7 @@ def listado_busqueda(item):
#Máximo num. de líneas permitidas por TMDB. Máx de 5 páginas por Itemlist para no degradar el rendimiento
while cnt_title <= cnt_tot and cnt_next < 5:
data = ''
try:
data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, post=item.post, timeout=timeout_search).data)
except:
@@ -656,6 +688,11 @@ def listado_busqueda(item):
else:
pattern = '<ul class="%s">(.*?)</ul>' % item.pattern #seleccionamos el bloque que nos interesa
if not data or (not scrapertools.find_single_match(data, pattern) and not '<h3><strong>( 0 ) Resultados encontrados </strong>' in data):
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 01: LISTADO_BUSQUEDA: La Web no responde o ha cambiado de URL: " + item.url + item.post + " / DATA: " + data)
#Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú
item, data = generictools.fail_over_newpct1(item, pattern)
@@ -1231,6 +1268,11 @@ def findvideos(item):
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent
#Verificamos si se ha cargado una página, y si además tiene la estructura correcta
if not data or not scrapertools.find_single_match(data, patron):
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data)
#Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el vídeo
@@ -1526,6 +1568,11 @@ def episodios(item):
#Verificamos si se ha cargado una página, y si además tiene la estructura correcta
if not data_alt or not scrapertools.find_single_match(data_alt, pattern):
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
if item.intervencion: #Sí ha sido clausurada judicialmente
item, itemlist = generictools.post_tmdb_episodios(item, itemlist) #Llamamos al método para el pintado del error
return itemlist #Salimos
logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea: " + item.url)
logger.error(pattern + data)

View File

@@ -9,6 +9,7 @@ from core import videolibrarytools
from core.item import Item
from platformcode import config, logger
from platformcode import platformtools
from lib import generictools
def mainlist(item):
@@ -31,7 +32,7 @@ def channel_config(item):
caption=config.get_localized_string(60598))
def list_movies(item):
def list_movies(item, silent=False):
logger.info()
itemlist = []
@@ -39,6 +40,15 @@ def list_movies(item):
for f in ficheros:
if f.endswith(".nfo"):
nfo_path = filetools.join(raiz, f)
#Sincronizamos las películas vistas desde la videoteca de Kodi con la de Alfa
try:
if config.is_xbmc(): #Si es Kodi, lo hacemos
from platformcode import xbmc_videolibrary
xbmc_videolibrary.mark_content_as_watched_on_alfa(nfo_path)
except:
pass
head_nfo, new_item = videolibrarytools.read_nfo(nfo_path)
new_item.nfo = nfo_path
@@ -50,6 +60,12 @@ def list_movies(item):
# Si se ha eliminado el strm desde la bilbioteca de kodi, no mostrarlo
continue
###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial
try:
new_item, new_item, overwrite = generictools.redirect_clone_newpct1(new_item, head_nfo, new_item, raiz)
except:
pass
# Menu contextual: Marcar como visto/no visto
visto = new_item.library_playcounts.get(os.path.splitext(f)[0], 0)
new_item.infoLabels["playcount"] = visto
@@ -85,7 +101,10 @@ def list_movies(item):
# logger.debug("new_item: " + new_item.tostring('\n'))
itemlist.append(new_item)
return sorted(itemlist, key=lambda it: it.title.lower())
if silent == False:
return sorted(itemlist, key=lambda it: it.title.lower())
else:
return
def list_tvshows(item):
@@ -98,6 +117,15 @@ def list_tvshows(item):
if f == "tvshow.nfo":
tvshow_path = filetools.join(raiz, f)
# logger.debug(tvshow_path)
#Sincronizamos los episodios vistos desde la videoteca de Kodi con la de Alfa
try:
if config.is_xbmc(): #Si es Kodi, lo hacemos
from platformcode import xbmc_videolibrary
xbmc_videolibrary.mark_content_as_watched_on_alfa(tvshow_path)
except:
pass
head_nfo, item_tvshow = videolibrarytools.read_nfo(tvshow_path)
item_tvshow.title = item_tvshow.contentTitle
item_tvshow.path = raiz
@@ -292,7 +320,6 @@ def get_episodes(item):
def findvideos(item):
logger.info()
from lib import generictools
# logger.debug("item:\n" + item.tostring('\n'))
itemlist = []
@@ -362,7 +389,7 @@ def findvideos(item):
platformtools.play_video(item_local)
elif index > 0:
filtro_canal = opciones[index].replace(config.get_localized_string(70078), "")
filtro_canal = opciones[index].replace(config.get_localized_string(70078), "").strip()
itemlist = []
for nom_canal, json_path in list_canales.items():
@@ -552,7 +579,7 @@ def mark_content_as_watched2(item):
# Guardamos los cambios en item.nfo
if filetools.write(item.nfo, head_nfo + it.tojson()):
item.infoLabels['playcount'] = item.playcount
logger.debug(item.playcount)
#logger.debug(item.playcount)
# if item.contentType == 'episodesss':
# Actualizar toda la serie
@@ -569,7 +596,7 @@ def mark_content_as_watched2(item):
def mark_content_as_watched(item):
logger.info()
logger.debug("item:\n" + item.tostring('\n'))
#logger.debug("item:\n" + item.tostring('\n'))
if filetools.exists(item.nfo):
head_nfo, it = videolibrarytools.read_nfo(item.nfo)

View File

@@ -27,6 +27,7 @@ channel_py = "newpct1"
intervenido_judicial = 'Dominio intervenido por la Autoridad Judicial'
intervenido_policia = '<!--CATEGORY:Judicial_Policia_Nacional'
intervenido_guardia = '<!--CATEGORY:Judicial_Guardia_Civil'
intervenido_sucuri = 'Access Denied - Sucuri Website Firewall'
def update_title(item):
@@ -664,6 +665,7 @@ def post_tmdb_findvideos(item, itemlist):
En Itemlist devuelve un Item con el pseudotítulo. Ahí el canal irá agregando el resto.
"""
#logger.debug(item)
#Creción de título general del vídeo a visualizar en Findvideos
itemlist = []
@@ -683,11 +685,12 @@ def post_tmdb_findvideos(item, itemlist):
if item.infoLabels['temporada_num_episodios'] and item.contentEpisodeNumber <= item.infoLabels['temporada_num_episodios']:
num_episodios = item.infoLabels['temporada_num_episodios']
# 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)
# Obtener la información actualizada del vídeo. En una segunda lectura de TMDB da más información que en la primera
#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)
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']:
@@ -697,7 +700,7 @@ def post_tmdb_findvideos(item, itemlist):
item.infoLabels['temporada_num_episodios'] = num_episodios
except:
pass
#Quitamos el la categoría o nombre del título, si lo tiene
if item.contentTitle:
item.contentTitle = re.sub(r' -%s-' % item.category, '', item.contentTitle)
@@ -721,6 +724,34 @@ def post_tmdb_findvideos(item, itemlist):
if item.quality.lower() in ['gb', 'mb']:
item.quality = item.quality.replace('GB', 'G B').replace('Gb', 'G b').replace('MB', 'M B').replace('Mb', 'M b')
#busco "duration" en infoLabels
tiempo = 0
if item.infoLabels['duration']:
tiempo = item.infoLabels['duration']
elif item.contentChannel == 'videolibrary': #No hay, viene de la Videoteca? buscamos en la DB
#Leo de la BD de Kodi la duración de la película o episodio. En "from_fields" se pueden poner las columnas que se quiera
nun_records = 0
if item.contentType == 'movie':
nun_records, records = get_field_from_kodi_DB(item, from_fields='c11') #Leo de la BD de Kodi la duración de la película
else:
nun_records, records = get_field_from_kodi_DB(item, from_fields='c09') #Leo de la BD de Kodi la duración del episodio
if nun_records > 0: #Hay registros?
#Es un array, busco el campo del registro: añadir en el FOR un fieldX por nueva columna
for strFileName, field1 in records:
tiempo = field1
try: #calculamos el timepo en hh:mm
tiempo_final = int(tiempo) #lo convierto a int, pero puede se null
if tiempo_final > 0: #Si el tiempo está a 0, pasamos
if tiempo_final > 700: #Si está en segundos
tiempo_final = tiempo_final / 60 #Lo transformo a minutos
horas = tiempo_final / 60 #Lo transformo a horas
resto = tiempo_final - (horas * 60) #guardo el resto de minutos de la hora
item.quality += ' [%s:%s]' % (str(horas).zfill(2), str(resto).zfill(2)) #Lo agrego a Calidad del Servidor
except:
pass
#Ajustamos el nombre de la categoría
if item.channel != channel_py:
@@ -783,6 +814,78 @@ def post_tmdb_findvideos(item, itemlist):
return (item, itemlist)
def get_field_from_kodi_DB(item, from_fields='*', files='file'):
logger.info()
"""
Llamada para leer de la DB de Kodi los campos que se reciben de entrada (from_fields, por defecto "*") del vídeo señalado en Item
Obviamente esto solo funciona con Kodi y si la película o serie está catalogada en las Videotecas de Alfa y Kodi
Se puede pedir que la búdqueda se haga por archivos (defecto), o por carpeta (series)
La llamada es:
nun_records, records = generictools.get_field_from_kodi_DB(item, from_fields='cXX[, cYY,...]'[, files = 'file|folder'])
Devuelve el num de registros encontrados y los registros. Es importante que el llamador verifique que "nun_records > 0" antes de tratar "records"
"""
FOLDER_MOVIES = config.get_setting("folder_movies")
FOLDER_TVSHOWS = config.get_setting("folder_tvshows")
VIDEOLIBRARY_PATH = config.get_videolibrary_config_path()
if item.contentType == 'movie': #Agrego la carpeta correspondiente al path de la Videoteca
path = filetools.join(VIDEOLIBRARY_PATH, FOLDER_MOVIES)
else:
path = filetools.join(VIDEOLIBRARY_PATH, FOLDER_TVSHOWS)
raiz, carpetas, ficheros = filetools.walk(path).next() #listo las series o películas en la Videoteca
carpetas = [filetools.join(path, f) for f in carpetas] #agrego la carpeta del contenido al path
for carpeta in carpetas: #busco el contenido seleccionado en la lista de carpetas
if item.contentType == 'movie' and (item.contentTitle.lower() in carpeta or item.contentTitle in carpeta): #Películas?
path = carpeta #Almacenamos la carpeta en el path
break
elif item.contentType in ['tvshow', 'season', 'episode'] and (item.contentSerieName.lower() in carpeta or item.contentSerieName in carpeta): #Series?
path = carpeta #Almacenamos la carpeta en el path
break
file_search = '%' #Por defecto busca todos los archivos de la carpeta
if files == 'file': #Si se ha pedido son un archivo (defecto), se busca
if item.contentType == 'episode': #Si es episodio, se pone el nombre, si no de deja %
file_search = '%sx%s.strm' % (item.contentSeason, str(item.contentEpisodeNumber).zfill(2)) #Nombre para episodios
if "\\" in path: #Ajustamos los / en función de la plataforma
path = path.replace("/", "\\")
path += "\\" #Terminamos el path con un /
else:
path += "/"
if FOLDER_TVSHOWS in path: #Compruebo si es CINE o SERIE
contentType = "episode_view" #Marco la tabla de BBDD de Kodi Video
else:
contentType = "movie_view" #Marco la tabla de BBDD de Kodi Video
path1 = path.replace("\\\\", "\\") #para la SQL solo necesito la carpeta
path2 = path.replace("\\", "/") #Formato no Windows
#Ejecutmos la sentencia SQL
if not from_fields:
from_fields = '*'
else:
from_fields = 'strFileName, %s' % from_fields #al menos dos campos, porque uno solo genera cosas raras
sql = 'select %s from %s where (strPath like "%s" or strPath like "%s") and strFileName like "%s"' % (from_fields, contentType, path1, path2, file_search)
nun_records = 0
records = None
try:
if config.is_xbmc():
from platformcode import xbmc_videolibrary
nun_records, records = xbmc_videolibrary.execute_sql_kodi(sql) #ejecución de la SQL
if nun_records == 0: #hay error?
logger.error("Error en la SQL: " + sql + ": 0 registros") #No estará catalogada o hay un error en el SQL
except:
pass
return (nun_records, records)
def fail_over_newpct1(item, patron, patron2=None, timeout=None):
logger.info()
@@ -953,11 +1056,16 @@ def web_intervenida(item, data, desactivar=True):
"""
intervencion = ()
if intervenido_policia in data or intervenido_guardia in data: #Verificamos que sea una intervención judicial
judicial = 'intervenido_gc.png' #Por defecto thumb de la Benemérita
judicial = ''
#Verificamos que sea una intervención judicial
if intervenido_policia in data or intervenido_guardia in data or intervenido_sucuri in data:
if intervenido_guardia in data:
judicial = 'intervenido_gc.png' #thumb de la Benemérita
if intervenido_policia in data:
judicial = 'intervenido_pn.jpeg' #thumb de la Policia Nacional
if intervenido_sucuri in data:
judicial = 'intervenido_sucuri.png' #thumb de Sucuri
category = item.category
if not item.category:
category = item.channel
@@ -966,7 +1074,7 @@ def web_intervenida(item, data, desactivar=True):
item.intervencion = [] #Si no existe el array, lo creamos
item.intervencion += [intervencion] #Añadimos esta intervención al array
logger.error("ERROR 99: " + category + ": " + intervenido_judicial + ": " + item.url + ": DESACTIVADO=" + str(desactivar) + " / DATA: " + data)
logger.error("ERROR 99: " + category + ": " + judicial + ": " + item.url + ": DESACTIVADO=" + str(desactivar) + " / DATA: " + data)
if desactivar == False: #Si no queremos desactivar el canal, nos vamos
return item
@@ -979,7 +1087,7 @@ def web_intervenida(item, data, desactivar=True):
if item.channel == channel_py: #Si es un clone de Newpct1, lo desactivamos
for settings in json_data['settings']: #Se recorren todos los settings
if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting
action_excluded = scrapertools.find_single_match(settings['default'], "\('\d', '%s', '[^']+', '[^']*', '([^']*)'\)" % item.category.lower()) #extraemos el valor de action_excluded
action_excluded = scrapertools.find_single_match(settings['default'], "\('\d', '%s', '[^']+', '[^']*', '([^']*)'\)" % item.category.lower()) #extraemos el valor de action_excluded
if action_excluded:
if "intervenido" not in action_excluded:
action_excluded += ', %s' % judicial #Agregamos el thumb de la autoridad judicial
@@ -991,11 +1099,13 @@ def web_intervenida(item, data, desactivar=True):
break
else:
json_data['active'] = False #Se desactiva el canal
#json_data['active'] = False #Se desactiva el canal
json_data['thumbnail'] = ', thumb_%s' % judicial #Guardamos el thumb de la autoridad judicial
#Guardamos los cambios hechos en el .json
try:
if item.channel != channel_py:
disabled = config.set_setting('enabled', False, item.channel)
channel_path = filetools.join(config.get_runtime_path(), "channels", item.channel + ".json")
with open(channel_path, 'w') as outfile: #Grabamos el .json actualizado
json.dump(json_data, outfile, sort_keys = True, indent = 2, ensure_ascii = False)
@@ -1007,7 +1117,7 @@ def web_intervenida(item, data, desactivar=True):
return item
def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=False):
def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=False, lookup=False):
logger.info()
"""
@@ -1043,7 +1153,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=F
- no: no acción para videolibrary_service, solo redirige en visionado de videolibrary
ejemplo: ('1', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', 'auto')
La llamada recibe el parámetro Item, el .nfo y los devuleve actualizados, así como opcionalmente el parámetro "overwrite· que puede forzar la reescritura de todos los archivos de la serie, y el parámetro "path" si viene de videolibrary_service
La llamada recibe el parámetro Item, el .nfo y los devuleve actualizados, así como opcionalmente el parámetro "overwrite· que puede forzar la reescritura de todos los archivos de la serie, y el parámetro "path" si viene de videolibrary_service. Por último, recibe opcionalmente el parámetro "lookup" si se quiere solo averigurar si habrá migración para ese título, pero sin realizarla.
"""
if not it:
@@ -1060,7 +1170,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=F
if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting
fail_over_list = settings['default'] #Carga lista de clones
if settings['id'] == "intervenidos_channels_list": #Encontramos en setting
intervencion = settings['default'] #Carga lista de clones y canales intervenidos
intervencion = settings['default'] #Carga lista de clones y canales intervenidos
#primero tratamos los clones de Newpct1
channel_alt = item.channel #Salvamos en nombre del canal o clone
@@ -1069,16 +1179,28 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=F
item.channel = channel_py
#Ahora tratamos las webs intervenidas, tranformamos la url, el nfo y borramos los archivos obsoletos de la serie
if channel not in intervencion: #Hacemos una lookup para ver si...
if channel not in intervencion and channel_alt != 'videolibrary': #Hacemos una lookup para ver si...
return (item, it, overwrite) #... el canal/clone está listado
import ast
intervencion_list = ast.literal_eval(intervencion) #Convertir a Array el string
#logger.debug(intervencion_list)
if item.channel != channel_py:
channel_enabled = channeltools.is_enabled(item.channel) #Verificamos que el canal esté inactivo
if lookup == True:
overwrite = False #Solo avisamos si hay cambios
for activo, canal_org, canal_des, url_org, url_des, patron1, patron2, patron3, patron4, patron5, content_inc, content_exc, ow_force in intervencion_list:
if activo == '1' and canal_org == channel_alt: #Es esta nuestra entrada?
if activo == '1' and (canal_org == channel_alt or channel_alt == 'videolibrary'): #Es esta nuestra entrada?
if channel_alt == 'videolibrary': #Viene de videolibrary.list_movies
for canal_vid, url_vid in item.library_urls.items():
if canal_org != canal_vid: #Miramos si canal_org de la regla está en item.library_urls
continue
else:
channel_alt = canal_org #Sí, ponermos el nombre del canal de origen
channel_b = "'%s'" % canal_org
if channel_b in fail_over_list: #Si es un clone de Newpct1, se actualiza a newpct1
channel_alt = channel_py
if channel_alt == 'videolibrary':
continue
if item.contentType == "list": #Si viene de Videolibrary, le cambiamos ya el canal
if item.channel != channel_py:
item.channel = canal_des #Cambiamos el canal. Si es clone, lo hace el canal
@@ -1087,60 +1209,110 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=F
continue
if item.contentType in content_exc: #Está el contenido excluido?
continue
if channel_enabled and canal_org != canal_des: #Si el canal está activo, puede ser solo...
if item.channel != channel_py:
channel_enabled = channeltools.is_enabled(channel_alt) #Verificamos que el canal esté inactivo
channel_enabled_alt = config.get_setting('enabled', channel_alt)
channel_enabled = channel_enabled * channel_enabled_alt #Si está inactivo en algún sitio, tomamos eso
if channel_enabled == 1 and canal_org != canal_des: #Si el canal está activo, puede ser solo...
continue #... una intervención que afecte solo a una región
if ow_force == 'no' and path != False: #Queremos que el canal solo visualice sin migración?
continue #Salimos sin tocas archivos
item.url = item.url.replace(url_org, url_des) #reemplzamos una parte de url
if ow_force == 'no' and it.library_urls: #Esta regla solo vale para findvideos...
continue #... salidmos si estamos actualizando
if lookup == True: #Queremos que el canal solo visualice sin migración?
if ow_force != 'no':
overwrite = True #Avisamos que hay cambios
continue #Salimos sin tocar archivos
url_total = ''
if item.url:
url_total = item.url
elif not item.url and item.library_urls:
url_total = item.library_urls[canal_org]
url_total = url_total.replace(url_org, url_des) #reemplazamos una parte de url
url = ''
if patron1: #Hay expresión regex?
url = scrapertools.find_single_match(item.url, patron1) #La aplicamos a url
url += scrapertools.find_single_match(url_total, patron1) #La aplicamos a url
if patron2: #Hay más expresión regex?
url += scrapertools.find_single_match(item.url, patron2) #La aplicamos a url
url += scrapertools.find_single_match(url_total, patron2) #La aplicamos a url
if patron3: #Hay más expresión regex?
url += scrapertools.find_single_match(item.url, patron3) #La aplicamos a url
url += scrapertools.find_single_match(url_total, patron3) #La aplicamos a url
if patron4: #Hay más expresión regex?
url += scrapertools.find_single_match(item.url, patron4) #La aplicamos a url
url += scrapertools.find_single_match(url_total, patron4) #La aplicamos a url
if patron5: #Hay más expresión regex?
url += scrapertools.find_single_match(item.url, patron5) #La aplicamos a url
item.url = url #Guardamos la suma de los resultados intermedios
url += scrapertools.find_single_match(url_total, patron5) #La aplicamos a url
if url:
url_total = url #Guardamos la suma de los resultados intermedios
update_stat += 1 #Ya hemos actualizado algo
canal_org_def = canal_org
canal_des_def = canal_des
ow_force_def = ow_force
if update_stat > 0: #Ha habido alguna actualización? Entonces salvamos
if item.channel == channel_py: #Si es Newpct1...
if item.channel == channel_py or channel in fail_over_list: #Si es Newpct1...
if item.contentType == "tvshow":
item.url = re.sub(r'\/\d+\/?$', '', item.url) #parece que con el título ecuentra la serie, normalmente...
if it.url:
it.url = item.url #reemplazamos una parte de url en .nfo, aunque no suele haberla
url_total = re.sub(r'\/\d+\/?$', '', url_total) #parece que con el título ecuentra la serie, normalmente...
if item.url:
item.url = url_total #Salvamos la url convertida
if item.library_urls:
item.library_urls.pop(canal_org, None)
item.library_urls = {canal_des: item.url}
item.library_urls.pop(canal_org_def, None)
item.library_urls = {canal_des_def: url_total}
it.library_urls = item.library_urls
if item.channel != channel_py:
item.channel = canal_des #Cambiamos el canal. Si es clone, lo hace el canal
if item.channel != channel_py and item.channel != 'videolibrary':
item.channel = canal_des_def #Cambiamos el canal. Si es clone, lo hace el canal
if channel_alt == item.category.lower(): #Actualizamos la Categoría y si la tenía
item.category = item.channel.capitalize()
if ow_force == 'force': #Queremos que el canal revise la serie entera?
item.ow_force = "1" #Se lo decimos
if ow_force in ['force', 'auto']: #Sobreescribir la series?
overwrite = ow_force_param #Sí, lo marcamos
if ow_force_def == 'force' and item.contentType != "movie": #Queremos que el canal revise la serie entera?
item.ow_force = '1' #Se lo decimos
if ow_force_def in ['force', 'auto']: #Sobreescribir la series?
overwrite = True #Sí, lo marcamos
if item.contentType in ['tvshow', 'season'] and it.library_urls:
if path == False:
TVSHOWS_PATH = item.path
else:
TVSHOWS_PATH = path
#logger.debug(canal_org_def + canal_des_def + ow_force_def)
if it.library_urls and path != False and ow_force_def != 'no': #Continuamos si hay .nfo, path, y queremos actualizarlo
if item.update_next:
del item.update_next #Borramos estos campos para forzar la actualización ya
if it.update_next:
del it.update_next
# Listamos todos los ficheros de la serie, asi evitamos tener que comprobar si existe uno por uno
raiz, carpetas_series, ficheros = filetools.walk(TVSHOWS_PATH).next()
ficheros = [filetools.join(TVSHOWS_PATH, f) for f in ficheros] #Almacenamos la lista de archivos de la carpeta
canal_erase = '[%s]' % canal_org
raiz, carpetas_series, ficheros = filetools.walk(path).next()
ficheros = [filetools.join(path, f) for f in ficheros] #Almacenamos la lista de archivos de la carpeta
canal_erase = '[%s]' % canal_org_def
for archivo in ficheros:
if canal_erase in archivo: #Borramos los .json que sean del canal intervenido
if canal_erase in archivo: #Borramos los .json que sean del canal intervenido
json_path = archivo.replace(canal_org_def, canal_des_def) #Salvamos el path del .json para luego crearlo
filetools.remove(archivo)
if "tvshow.nfo" in archivo:
filetools.write(archivo, head_nfo + it.tojson()) #escribo el .nfo por si aborta update
if item.contentType == "movie" and ".nfo" in archivo:
filetools.write(archivo, head_nfo + it.tojson()) #escribo el .nfo de la peli por si aborta update
if item.contentType != "movie" and "tvshow.nfo" in archivo:
filetools.write(archivo, head_nfo + it.tojson()) #escribo el tvshow.nfo por si aborta update
#Aquí convertimos las películas. Después de borrado el .json, dejamos que videolibrarytools lo regenere
if item.contentType == "movie": #Dejamos que regenere el archivo .json
item_movie = item.clone()
item_movie.channel = canal_des_def #mombre del canal migrado
del item_movie.library_playcounts #Borramos lo que no es necesario en el .json
del item_movie.library_urls
item_movie.url = url_total #url migrada
del item_movie.nfo
del item_movie.path
del item_movie.strm_path
del item_movie.text_color
filetools.write(json_path, item_movie.tojson()) #Salvamos el nuevo .json de la película
#logger.debug(item)
if update_stat > 0 and path != False and ow_force_def != 'no':
logger.debug(item)
return (item, it, overwrite)
return (item, it, overwrite)
def dejuice(data):
logger.info()
# Metodo para desobfuscar datos de JuicyCodes
import base64
from lib import jsunpack
juiced = scrapertools.find_single_match(data, 'JuicyCodes.Run\((.*?)\);')
b64_data = juiced.replace('+', '').replace('"', '')
b64_decode = base64.b64decode(b64_data)
dejuiced = jsunpack.unpack(b64_decode)
return dejuiced

View File

@@ -319,12 +319,95 @@ def mark_season_as_watched_on_kodi(item, value=1):
item_path2 = item_path1.replace("\\", "/")
sql = 'update files set playCount= %s where idFile in ' \
'(select idfile from episode_view where strPath like "%s" or strPath like "%s"%s)' % \
'(select idfile from episode_view where (strPath like "%s" or strPath like "%s")%s)' % \
(value, item_path1, item_path2, request_season)
execute_sql_kodi(sql)
def mark_content_as_watched_on_alfa(path):
from channels import videolibrary
from core import videolibrarytools
from core import scrapertools
import re
"""
marca toda la serie o película como vista o no vista en la Videoteca de Alfa basado en su estado en la Videoteca de Kodi
@type str: path
@param path: carpeta de contenido a marcar
"""
logger.info()
#logger.debug("path: " + path)
FOLDER_MOVIES = config.get_setting("folder_movies")
FOLDER_TVSHOWS = config.get_setting("folder_tvshows")
VIDEOLIBRARY_PATH = config.get_videolibrary_config_path()
# Solo podemos marcar el contenido como vista en la BBDD de Kodi si la BBDD es local,
# en caso de compartir BBDD esta funcionalidad no funcionara
#if config.get_setting("db_mode", "videolibrary"):
# return
path2 = ''
if "special://" in VIDEOLIBRARY_PATH:
if FOLDER_TVSHOWS in path:
path2 = re. sub(r'.*?%s' % FOLDER_TVSHOWS, VIDEOLIBRARY_PATH + "/" + FOLDER_TVSHOWS, path).replace("\\", "/")
if FOLDER_MOVIES in path:
path2 = re. sub(r'.*?%s' % FOLDER_MOVIES, VIDEOLIBRARY_PATH + "/" + FOLDER_MOVIES, path).replace("\\", "/")
if "\\" in path:
path = path.replace("/", "\\")
head_nfo, item = videolibrarytools.read_nfo(path) #Leo el .nfo del contenido
if FOLDER_TVSHOWS in path: #Compruebo si es CINE o SERIE
contentType = "episode_view" #Marco la tabla de BBDD de Kodi Video
nfo_name = "tvshow.nfo" #Construyo el nombre del .nfo
path1 = path.replace("\\\\", "\\").replace(nfo_name, '') #para la SQL solo necesito la carpeta
if not path2:
path2 = path1.replace("\\", "/") #Formato no Windows
else:
path2 = path2.replace(nfo_name, '')
else:
contentType = "movie_view" #Marco la tabla de BBDD de Kodi Video
path1 = path.replace("\\\\", "\\") #Formato Windows
if not path2:
path2 = path1.replace("\\", "/") #Formato no Windows
nfo_name = scrapertools.find_single_match(path2, '\]\/(.*?)$') #Construyo el nombre del .nfo
path1 = path1.replace(nfo_name, '') #para la SQL solo necesito la carpeta
path2 = path2.replace(nfo_name, '') #para la SQL solo necesito la carpeta
#Ejecutmos la sentencia SQL
sql = 'select strFileName, playCount from %s where (strPath like "%s" or strPath like "%s")' % (contentType, path1, path2)
nun_records = 0
records = None
nun_records, records = execute_sql_kodi(sql) #ejecución de la SQL
if nun_records == 0: #hay error?
logger.error("Error en la SQL: " + sql + ": 0 registros")
return #salimos: o no está catalogado en Kodi, o hay un error en la SQL
for title, playCount in records: #Ahora recorremos todos los registros obtenidos
if contentType == "episode_view":
title_plain = title.replace('.strm', '') #Si es Serie, quitamos el sufijo .strm
else:
title_plain = scrapertools.find_single_match(item.strm_path, '.(.*?\s\[.*?\])') #si es peli, quitamos el título
if playCount is None or playCount == 0: #todavía no se ha visto, lo ponemos a 0
playCount_final = 0
elif playCount >= 1:
playCount_final = 1
title_plain = title_plain.decode("utf-8").encode("utf-8") #Hacemos esto porque si no genera esto: u'title_plain'
item.library_playcounts.update({title_plain: playCount_final}) #actualizamos el playCount del .nfo
if item.infoLabels['mediatype'] == "tvshow": #Actualizamos los playCounts de temporadas y Serie
for season in item.library_playcounts:
if "season" in season: #buscamos las etiquetas "season" dentro de playCounts
season_num = int(scrapertools.find_single_match(season, 'season (\d+)')) #salvamos el núm, de Temporada
item = videolibrary.check_season_playcount(item, season_num) #llamamos al método que actualiza Temps. y Series
filetools.write(path, head_nfo + item.tojson())
#logger.debug(item)
def get_data(payload):
"""
obtiene la información de la llamada JSON-RPC con la información pasada en payload

View File

@@ -3071,7 +3071,7 @@ msgstr "¿Realmente desea eliminar '%s' de su videoteca?"
msgctxt "#70089"
msgid "Show only links of %s"
msgstr "Mostrar solo los enlaces de %s "
msgstr "Mostrar solo los enlaces de %s"
msgctxt "#70090"
msgid " Exclude all streams with specific words"

View File

@@ -3071,7 +3071,7 @@ msgstr "¿Realmente desea eliminar '%s' de su videoteca?"
msgctxt "#70089"
msgid "Show only links of %s"
msgstr "Mostrar solo los enlaces de %s "
msgstr "Mostrar solo los enlaces de %s"
msgctxt "#70090"
msgid " Exclude all streams with specific words"

View File

@@ -3071,7 +3071,7 @@ msgstr "¿Realmente desea eliminar '%s' de su videoteca?"
msgctxt "#70089"
msgid "Show only links of %s"
msgstr "Mostrar solo los enlaces de %s "
msgstr "Mostrar solo los enlaces de %s"
msgctxt "#70090"
msgid " Exclude all streams with specific words"

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -9,13 +9,13 @@ from core import channeltools, filetools, videolibrarytools
from platformcode import config, logger
from platformcode import platformtools
from channels import videolibrary
from lib import generictools
def update(path, p_dialog, i, t, serie, overwrite):
logger.info("Actualizando " + path)
from lib import generictools
insertados_total = 0
head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo')
# logger.debug("%s: %s" %(serie.contentSerieName,str(list_canales) ))
@@ -25,7 +25,7 @@ def update(path, p_dialog, i, t, serie, overwrite):
###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial
try:
serie, it, overwrite = generictools.redirect_clone_newpct1(serie, head_nfo, it, overwrite, path)
serie, it, overwrite = generictools.redirect_clone_newpct1(serie, head_nfo, it, path, overwrite)
except:
pass
@@ -46,8 +46,6 @@ def update(path, p_dialog, i, t, serie, overwrite):
obj = imp.load_source(serie.channel, pathchannels)
itemlist = obj.episodios(serie)
serie.channel = channel #Restauramos el valor incial del clone de NewPct1
try:
if int(overwrite) == 3:
@@ -80,11 +78,20 @@ def update(path, p_dialog, i, t, serie, overwrite):
else:
logger.debug("Canal %s no activo no se actualiza" % serie.channel)
#Sincronizamos los episodios vistos desde la videoteca de Kodi con la de Alfa
try:
if config.is_xbmc(): #Si es Kodi, lo hacemos
from platformcode import xbmc_videolibrary
xbmc_videolibrary.mark_content_as_watched_on_alfa(path + '/tvshow.nfo')
except:
pass
return insertados_total > 0
def check_for_update(overwrite=True):
logger.info("Actualizando series...")
p_dialog = None
serie_actualizada = False
update_when_finished = False
@@ -108,7 +115,17 @@ def check_for_update(overwrite=True):
for i, tvshow_file in enumerate(show_list):
head_nfo, serie = videolibrarytools.read_nfo(tvshow_file)
path = filetools.dirname(tvshow_file)
###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial
overwrite_forced = False
try:
serie, serie, overwrite_forced = generictools.redirect_clone_newpct1(serie, head_nfo, serie, path, overwrite, lookup=True)
except:
pass
if overwrite_forced == True:
overwrite = True
serie.update_next = ''
logger.info("serie=" + serie.contentSerieName)
p_dialog.update(int(math.ceil((i + 1) * t)), heading, serie.contentSerieName)
@@ -116,7 +133,16 @@ def check_for_update(overwrite=True):
if not serie.active:
# si la serie no esta activa descartar
continue
if overwrite_forced == False:
#Sincronizamos los episodios vistos desde la videoteca de Kodi con la de Alfa, aunque la serie esté desactivada
try:
if config.is_xbmc(): #Si es Kodi, lo hacemos
from platformcode import xbmc_videolibrary
xbmc_videolibrary.mark_content_as_watched_on_alfa(path + '/tvshow.nfo')
except:
pass
continue
# obtenemos las fecha de actualizacion y de la proxima programada para esta serie
update_next = serie.update_next
@@ -162,6 +188,7 @@ def check_for_update(overwrite=True):
if not serie_actualizada:
update_next += datetime.timedelta(days=interval)
head_nfo, serie = videolibrarytools.read_nfo(tvshow_file) #Vuelve a leer el.nfo, que ha sido modificado
if interval != int(serie.active) or update_next.strftime('%Y-%m-%d') != serie.update_next:
serie.active = interval
serie.update_next = update_next.strftime('%Y-%m-%d')
@@ -197,6 +224,10 @@ def check_for_update(overwrite=True):
if p_dialog:
p_dialog.close()
from core.item import Item
item_dummy = Item()
videolibrary.list_movies(item_dummy, silent=True)
def start(thread=True):