Redireccionamiento automáticos de series y peliculas
En caso de cambio de dominio o clausura judicial, se puede parametrizar la migración a un nuevo dominio y/o canal
This commit is contained in:
@@ -57,6 +57,14 @@
|
||||
"enabled": true,
|
||||
"visible": false
|
||||
},
|
||||
{
|
||||
"id": "intervenidos_channels_list",
|
||||
"type": "text",
|
||||
"label": "Lista de canales y clones de NewPct1 intervenidos y orden de sustitución de URLs",
|
||||
"default": "('0', 'canal_org', 'canal_des', 'url_org', 'url_des', 'patron1', 'patron2', 'patron3', 'patron4', 'patron5', 'content_inc', 'content_exc', 'ow_force'), ('1', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', '(http.?:\/\/.*?\/)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)([^0-9]+-)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-\\d+-(Temporada-).html', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-(?:[^-]+-)[^0-9]+-(\\d+)-', '', 'tvshow, season', '', 'force'), ('1', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', '(http.?:\/\/.*?\/)', 'http.?:\/\/.*?\/.*?-torrent.?-[^-]+-([^.]+).html', '', '', '', 'movie', '', 'force')",
|
||||
"enabled": true,
|
||||
"visible": false
|
||||
},
|
||||
{
|
||||
"id": "seleccionar_ult_temporadda_activa",
|
||||
"type": "bool",
|
||||
|
||||
@@ -34,8 +34,16 @@ for active_clone, channel_clone, host_clone, contentType_clone, info_clone in cl
|
||||
if i == host_index:
|
||||
channel_clone_name = channel_clone #Nombre del Canal elegido
|
||||
host = host_clone #URL del Canal elegido
|
||||
break
|
||||
if active_clone == "1": #Comprueba que el clone esté activo
|
||||
break
|
||||
channel_clone_name = "*** DOWN ***" #es un fallo masivo ???
|
||||
for active_clone, channel_clone, host_clone, contentType_clone, info_clone in clone_list:
|
||||
if active_clone == "1": #Comprueba que el clone esté activo
|
||||
channel_clone_name = channel_clone #Nombre del Canal elegido
|
||||
host = host_clone #URL del Canal elegido
|
||||
break
|
||||
i += 1
|
||||
|
||||
item = Item()
|
||||
if item.channel != channel_py:
|
||||
item.channel = channel_py
|
||||
@@ -72,6 +80,10 @@ def mainlist(item):
|
||||
thumb_docus = get_thumb("channels_documentary.png")
|
||||
thumb_buscar = get_thumb("search.png")
|
||||
thumb_settings = get_thumb("setting_0.png")
|
||||
|
||||
if channel_clone_name == "*** DOWN ***": #Ningún clones activo !!!
|
||||
itemlist.append(item.clone(action='', title="[COLOR yellow]Ningún canal NewPct1 activo[/COLOR]"))
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos y salimos
|
||||
|
||||
itemlist.append(Item(channel=item.channel, action="submenu_novedades", title="Novedades", url=item.channel_host + "ultimas-descargas/", extra="novedades", thumbnail=thumb_pelis, category=item.category, channel_host=item.channel_host))
|
||||
|
||||
@@ -103,7 +115,6 @@ def settingCanal(item):
|
||||
return
|
||||
|
||||
|
||||
|
||||
def submenu(item):
|
||||
logger.info()
|
||||
|
||||
@@ -183,6 +194,10 @@ def submenu_novedades(item):
|
||||
item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
|
||||
item.extra = "novedades"
|
||||
|
||||
if channel_clone_name == "*** DOWN ***": #Ningún clones activo !!!
|
||||
itemlist.append(item.clone(action='', title="[COLOR yellow]Ningún canal NewPct1 activo[/COLOR]"))
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos y salimos
|
||||
|
||||
try:
|
||||
data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, timeout=timeout_search).data)
|
||||
except:
|
||||
@@ -307,7 +322,7 @@ def listado(item):
|
||||
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url, timeout=timeout).data)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
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):
|
||||
logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data)
|
||||
@@ -412,7 +427,7 @@ def listado(item):
|
||||
cnt_pag += cnt_tot
|
||||
|
||||
#Tratamos todos los contenidos, creardo una variable local de Item
|
||||
for scrapedurl, scrapedtitle, scrapedthumbnail, title_alt, calidad in matches:
|
||||
for scrapedurl, scrapedtitle, scrapedthumbnail, scrapedtitle_alt, calidad in matches:
|
||||
item_local = item.clone()
|
||||
if item_local.tipo:
|
||||
del item_local.tipo
|
||||
@@ -422,13 +437,15 @@ def listado(item):
|
||||
del item_local.post_num
|
||||
if item_local.category:
|
||||
del item_local.category
|
||||
if item_local.intervencion:
|
||||
del item_local.intervencion
|
||||
|
||||
item_local.title = ''
|
||||
item_local.context = "['buscar_trailer']"
|
||||
|
||||
# Limpiamos títulos, Sacamos datos de calidad, audio y lenguaje
|
||||
title = re.sub('\r\n', '', scrapedtitle).decode('iso-8859-1').encode('utf8').strip()
|
||||
title_alt = re.sub('\r\n', '', title_alt).decode('iso-8859-1').encode('utf8').strip()
|
||||
title_alt = re.sub('\r\n', '', scrapedtitle_alt).decode('iso-8859-1').encode('utf8').strip()
|
||||
title = title.replace("á", "a").replace("é", "e").replace("í", "i").replace("ó", "o").replace("ú", "u").replace("ü", "u").replace("�", "ñ").replace("ñ", "ñ").replace(".", " ")
|
||||
title_alt = title_alt.replace("á", "a").replace("é", "e").replace("í", "i").replace("ó", "o").replace("ú", "u").replace("ü", "u").replace("�", "ñ").replace("ñ", "ñ")
|
||||
|
||||
@@ -590,6 +607,10 @@ def listado_busqueda(item):
|
||||
item.category_new = item.category
|
||||
item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
|
||||
|
||||
if channel_clone_name == "*** DOWN ***": #Ningún clones activo !!!
|
||||
itemlist.append(item.clone(action='', title="[COLOR yellow]Ningún canal NewPct1 activo[/COLOR]"))
|
||||
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos y salimos
|
||||
|
||||
itemlist = []
|
||||
cnt_tot = 40 # Poner el num. máximo de items por página. Dejamos que la web lo controle
|
||||
cnt_title = 0 # Contador de líneas insertadas en Itemlist
|
||||
@@ -741,7 +762,7 @@ def listado_busqueda(item):
|
||||
#logger.debug(data)
|
||||
|
||||
cnt_title = 0
|
||||
for scrapedurl, scrapedtitle, scrapedthumbnail, calidad, year, size in matches:
|
||||
for scrapedurl, scrapedtitle, scrapedthumbnail, calidad, scrapedyear, scrapedsize in matches:
|
||||
cnt_pag += 1
|
||||
|
||||
#Realiza un control de las series que se añaden, ya que el buscador devuelve episodios y no las series completas
|
||||
@@ -786,15 +807,18 @@ def listado_busqueda(item):
|
||||
del item_local.adult
|
||||
item_local.folder = True
|
||||
del item_local.folder
|
||||
if item_local.intervencion:
|
||||
del item_local.intervencion
|
||||
item_local.title = ''
|
||||
item_local.context = "['buscar_trailer']"
|
||||
item_local.contentType = ""
|
||||
url = scrapedurl
|
||||
|
||||
title_subs = []
|
||||
|
||||
#Si son episodios sueltos de Series que vienen de Novedades, se busca la url de la Serie
|
||||
if item.extra == "novedades" and "/serie" in scrapedurl and episodio_serie == 1:
|
||||
item_local.url = scrapedurl
|
||||
if item.extra == "novedades" and "/serie" in url and episodio_serie == 1:
|
||||
item_local.url = url
|
||||
item_local.extra2 = 'serie_episodios' #Creamos acción temporal excluyente para otros clones
|
||||
if item_local.category == 'Mispelisyseries': #Esta web no gestiona bien el cambio de episodio a Serie
|
||||
pattern = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent
|
||||
@@ -816,39 +840,39 @@ def listado_busqueda(item):
|
||||
title_subs += ["ERR"]
|
||||
|
||||
elif item_local.channel_alt: #Si ha habido fail-over, lo comento
|
||||
scrapedurl = scrapedurl.replace(item_local.channel_alt, item_local.category.lower())
|
||||
url = url.replace(item_local.channel_alt, item_local.category.lower())
|
||||
title_subs += ["ALT"]
|
||||
|
||||
try:
|
||||
pattern = '<div class="content">.*?<h1>.*?<a href="([^"]+)"' #Patron para Serie completa
|
||||
item_local.url = scrapertools.find_single_match(data_serie, pattern)
|
||||
if (item.post and '775' in item.post and 'vo/' not in item_local.url) or 'vo/' in scrapedurl: #Son series VO mal formadas?
|
||||
if (item.post and '775' in item.post and 'vo/' not in item_local.url) or 'vo/' in url: #Son series VO mal formadas?
|
||||
item_local.url = item_local.url.replace('/series/', '/series-vo/')
|
||||
#item_local.url = re.sub(r'\/\d+$', '/', item_local.url) #Quitamos el ID de la serie por compatib.
|
||||
if item_local.url:
|
||||
title_subs += ["Episodio %sx%s" % (scrapertools.find_single_match(scrapedurl, '\/temp.*?-(\d+)\/cap.*?-(\d+)\/'))]
|
||||
scrapedurl = item_local.url
|
||||
title_subs += ["Episodio %sx%s" % (scrapertools.find_single_match(url, '\/temp.*?-(\d+)\/cap.*?-(\d+)\/'))]
|
||||
url = item_local.url
|
||||
except:
|
||||
pass
|
||||
|
||||
if item.extra == "novedades" and "/serie" in scrapedurl:
|
||||
if item.extra == "novedades" and "/serie" in url:
|
||||
if not item_local.url or episodio_serie == 0:
|
||||
item_local.url = scrapedurl
|
||||
if scrapertools.find_single_match(scrapedurl, '\/temp.*?-(\d+)\/cap.*?-(\d+)\/'):
|
||||
title_subs += ["Episodio %sx%s" % (scrapertools.find_single_match(scrapedurl, '\/temp.*?-(\d+)\/cap.*?-(\d+)\/'))]
|
||||
item_local.url = url
|
||||
if scrapertools.find_single_match(url, '\/temp.*?-(\d+)\/cap.*?-(\d+)\/'):
|
||||
title_subs += ["Episodio %sx%s" % (scrapertools.find_single_match(url, '\/temp.*?-(\d+)\/cap.*?-(\d+)\/'))]
|
||||
else:
|
||||
title_subs += ["Episodio 1x01"]
|
||||
|
||||
#Establecemos los valores básicos en función del tipo de contenido
|
||||
if (".com/serie" in scrapedurl or "/serie" in scrapedurl or "-serie" in scrapedurl) and not "/miniseries" in scrapedurl and (not "/capitulo" in scrapedurl or "pelisyseries.com" in item_local.channel_host): #Series
|
||||
if (".com/serie" in url or "/serie" in url or "-serie" in url) and not "/miniseries" in url and (not "/capitulo" in url or "pelisyseries.com" in item_local.channel_host): #Series
|
||||
item_local.action = "episodios"
|
||||
item_local.contentType = "tvshow"
|
||||
item_local.extra = "series"
|
||||
elif "varios/" in scrapedurl or "/miniseries" in scrapedurl: #Documentales y varios
|
||||
elif "varios/" in url or "/miniseries" in url: #Documentales y varios
|
||||
item_local.action = "findvideos"
|
||||
item_local.contentType = "movie"
|
||||
item_local.extra = "varios"
|
||||
elif "/capitulo" in scrapedurl: #Documentales y varios
|
||||
elif "/capitulo" in url: #Documentales y varios
|
||||
item_local.action = "findvideos"
|
||||
item_local.contentType = "episode"
|
||||
item_local.extra = "series"
|
||||
@@ -865,10 +889,10 @@ def listado_busqueda(item):
|
||||
|
||||
#Determinamos y marcamos idiomas distintos del castellano
|
||||
item_local.language = []
|
||||
if "[vos" in title.lower() or "v.o.s" in title.lower() or "vo" in title.lower() or ".com/pelicula/" in scrapedurl or ".com/series-vo" in scrapedurl or "-vo/" in scrapedurl or "vos" in calidad.lower() or "vose" in calidad.lower() or "v.o.s" in calidad.lower() or "sub" in calidad.lower() or ".com/peliculas-vo" in item.url:
|
||||
if "[vos" in title.lower() or "v.o.s" in title.lower() or "vo" in title.lower() or ".com/pelicula/" in url or ".com/series-vo" in url or "-vo/" in url or "vos" in calidad.lower() or "vose" in calidad.lower() or "v.o.s" in calidad.lower() or "sub" in calidad.lower() or ".com/peliculas-vo" in item.url:
|
||||
item_local.language += ["VOS"]
|
||||
title = title.replace(" [Subs. integrados]", "").replace(" [subs. Integrados]", "").replace(" [VOSE", "").replace(" [VOS", "").replace(" (V.O.S.E)", "").replace(" VO", "").replace("Subtitulos", "")
|
||||
if "latino" in title.lower() or "argentina" in title.lower() or "-latino/" in scrapedurl or "latino" in calidad.lower() or "argentina" in calidad.lower():
|
||||
if "latino" in title.lower() or "argentina" in title.lower() or "-latino/" in url or "latino" in calidad.lower() or "argentina" in calidad.lower():
|
||||
item_local.language += ["LAT"]
|
||||
|
||||
#Guardamos info de 3D en calidad y limpiamos
|
||||
@@ -986,19 +1010,19 @@ def listado_busqueda(item):
|
||||
item_local.title = title
|
||||
if item_local.contentType == "movie":
|
||||
item_local.contentTitle = title
|
||||
size = size.replace(".", ",")
|
||||
size = scrapedsize.replace(".", ",")
|
||||
item_local.quality = '%s [%s]' % (item_local.quality, size)
|
||||
else:
|
||||
item_local.contentSerieName = title
|
||||
|
||||
#Guardamos el resto de variables del vídeo
|
||||
item_local.url = scrapedurl
|
||||
item_local.url = url
|
||||
item_local.thumbnail = scrapedthumbnail
|
||||
item_local.contentThumbnail = scrapedthumbnail
|
||||
|
||||
#Guardamos el año que puede venir en la url, por si luego no hay resultados desde TMDB
|
||||
try:
|
||||
year = int(year)
|
||||
year = int(scrapedyear)
|
||||
except:
|
||||
year = ""
|
||||
year = str(year)
|
||||
@@ -1083,14 +1107,16 @@ def listado_busqueda(item):
|
||||
|
||||
def findvideos(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
|
||||
#Renombramos el canal al nombre de clone elegido. Actualizados URL
|
||||
host = scrapertools.find_single_match(item.url, '(http.?\:\/\/(?:www.)?\w+\.\w+\/)')
|
||||
item.channel_host = host
|
||||
item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
|
||||
|
||||
itemlist = []
|
||||
|
||||
verify_fo = True #Verificamos si el clone a usar está activo
|
||||
item, data = generictools.fail_over_newpct1(item, verify_fo)
|
||||
|
||||
# Cualquiera de las tres opciones son válidas
|
||||
# item.url = item.url.replace(".com/",".com/ver-online/")
|
||||
# item.url = item.url.replace(".com/",".com/descarga-directa/")
|
||||
@@ -1194,7 +1220,7 @@ def findvideos(item):
|
||||
verificar_enlaces_descargas = -1 #Verificar todos los enlaces Descargar
|
||||
verificar_enlaces_descargas_validos = True #"¿Contar sólo enlaces 'verificados' en Descargar?"
|
||||
excluir_enlaces_descargas = [] #Lista vacía de servidores excluidos en Descargar
|
||||
|
||||
|
||||
# Descarga la página
|
||||
data = ''
|
||||
try:
|
||||
@@ -1443,14 +1469,18 @@ def findvideos(item):
|
||||
|
||||
def episodios(item):
|
||||
logger.info()
|
||||
itemlist = []
|
||||
|
||||
#logger.debug(item)
|
||||
|
||||
#Renombramos el canal al nombre de clone elegido. Actualizados URL
|
||||
host = scrapertools.find_single_match(item.url, '(http.?\:\/\/(?:www.)?\w+\.\w+\/)')
|
||||
item.channel_host = host
|
||||
item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
|
||||
|
||||
itemlist = []
|
||||
|
||||
verify_fo = True #Verificamos si el clone a usar está activo
|
||||
item, data = generictools.fail_over_newpct1(item, verify_fo)
|
||||
|
||||
#Limpiamos num. Temporada y Episodio que ha podido quedar por Novedades
|
||||
if item.contentSeason:
|
||||
del item.infoLabels['season']
|
||||
@@ -1461,11 +1491,15 @@ def episodios(item):
|
||||
if not item.infoLabels['tmdb_id']:
|
||||
tmdb.set_infoLabels(item, True)
|
||||
|
||||
modo_ultima_temp_alt = modo_ultima_temp
|
||||
if item.ow_force == "1": #Si hay un traspaso de canal o url, se actualiza todo
|
||||
modo_ultima_temp_alt = False
|
||||
|
||||
max_temp = 1
|
||||
if item.infoLabels['number_of_seasons']:
|
||||
max_temp = item.infoLabels['number_of_seasons']
|
||||
y = []
|
||||
if modo_ultima_temp and item.library_playcounts: #Averiguar cuantas temporadas hay en Videoteca
|
||||
if modo_ultima_temp_alt and item.library_playcounts: #Averiguar cuantas temporadas hay en Videoteca
|
||||
patron = 'season (\d+)'
|
||||
matches = re.compile(patron, re.DOTALL).findall(str(item.library_playcounts))
|
||||
for x in matches:
|
||||
@@ -1562,7 +1596,9 @@ def episodios(item):
|
||||
#logger.debug(matches)
|
||||
|
||||
#Empezamos a generar cada episodio
|
||||
for url, thumb, info in matches:
|
||||
for scrapedurl, scrapedthumb, info in matches:
|
||||
url = scrapedurl
|
||||
thumb = scrapedthumb
|
||||
if "pelisyseries.com" in item.url: #En esta web están en diferente orden
|
||||
interm = url
|
||||
url = thumb
|
||||
@@ -1671,34 +1707,22 @@ def episodios(item):
|
||||
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
|
||||
item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2))
|
||||
|
||||
if modo_ultima_temp and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca
|
||||
|
||||
if modo_ultima_temp_alt and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca
|
||||
if item_local.contentSeason < max_temp:
|
||||
list_pages = [] #Sale del bucle de leer páginas
|
||||
break #Sale del bucle actual del FOR de episodios por página
|
||||
#if ('%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2))) in item.library_playcounts:
|
||||
# continue
|
||||
|
||||
|
||||
if item_local.active:
|
||||
del item_local.active
|
||||
if item_local.infoLabels['title']:
|
||||
if item_local.contentTitle:
|
||||
del item_local.infoLabels['title']
|
||||
item_local.context = "['buscar_trailer']"
|
||||
item_local.action = "findvideos"
|
||||
item_local.contentType = "episode"
|
||||
item_local.extra = "episodios"
|
||||
if item_local.library_playcounts:
|
||||
del item_local.library_playcounts
|
||||
if item_local.library_urls:
|
||||
del item_local.library_urls
|
||||
if item_local.path:
|
||||
del item_local.path
|
||||
if item_local.update_last:
|
||||
del item_local.update_last
|
||||
if item_local.update_next:
|
||||
del item_local.update_next
|
||||
if item_local.channel_host:
|
||||
del item_local.channel_host
|
||||
|
||||
itemlist.append(item_local.clone())
|
||||
|
||||
|
||||
@@ -326,7 +326,11 @@ def findvideos(item):
|
||||
if 'downloads' in list_canales:
|
||||
json_path = list_canales['downloads']
|
||||
item_json = Item().fromjson(filetools.read(json_path))
|
||||
item_json = generictools.redirect_clone_newpct1(item_json) ###### Redirección al canal NewPct1.py si es un clone
|
||||
###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial
|
||||
try:
|
||||
item_json, it, overwrite = generictools.redirect_clone_newpct1(item_json)
|
||||
except:
|
||||
pass
|
||||
item_json.contentChannel = "local"
|
||||
# Soporte para rutas relativas en descargas
|
||||
if filetools.is_relative(item_json.url):
|
||||
@@ -367,7 +371,11 @@ def findvideos(item):
|
||||
|
||||
item_canal = Item()
|
||||
item_canal.channel = nom_canal
|
||||
item_canal = generictools.redirect_clone_newpct1(item_canal) ###### Redirección al canal NewPct1.py si es un clone
|
||||
###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial
|
||||
try:
|
||||
item_canal, it, overwrite = generictools.redirect_clone_newpct1(item_canal)
|
||||
except:
|
||||
pass
|
||||
nom_canal = item_canal.channel
|
||||
|
||||
# Importamos el canal de la parte seleccionada
|
||||
@@ -377,7 +385,11 @@ def findvideos(item):
|
||||
exec "import channels." + nom_canal + " as channel"
|
||||
|
||||
item_json = Item().fromjson(filetools.read(json_path))
|
||||
item_json = generictools.redirect_clone_newpct1(item_json) ###### Redirección al canal NewPct1.py si es un clone
|
||||
###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial
|
||||
try:
|
||||
item_json, it, overwrite = generictools.redirect_clone_newpct1(item_json)
|
||||
except:
|
||||
pass
|
||||
list_servers = []
|
||||
|
||||
try:
|
||||
@@ -389,7 +401,7 @@ def findvideos(item):
|
||||
item_json.show = item.library_filter_show.get(nom_canal, "")
|
||||
|
||||
# Ejecutamos find_videos, del canal o común
|
||||
item_json.contentChannel='videolibrary'
|
||||
item_json.contentChannel = 'videolibrary'
|
||||
if hasattr(channel, 'findvideos'):
|
||||
from core import servertools
|
||||
list_servers = getattr(channel, 'findvideos')(item_json)
|
||||
|
||||
@@ -18,11 +18,15 @@ from core import httptools
|
||||
from core import scrapertools
|
||||
from core import servertools
|
||||
from core import channeltools
|
||||
from core import filetools
|
||||
from core.item import Item
|
||||
from platformcode import config, logger
|
||||
from core import tmdb
|
||||
|
||||
channel_py = "newpct1"
|
||||
intervenido_judicial = 'Dominio intervenido por la Autoridad Judicial'
|
||||
intervenido_policia = '<!--CATEGORY:Judicial_Policia_Nacional'
|
||||
intervenido_guardia = '<!--CATEGORY:Judicial_Guardia_Civil'
|
||||
|
||||
|
||||
def update_title(item):
|
||||
@@ -164,6 +168,7 @@ def update_title(item):
|
||||
|
||||
def post_tmdb_listado(item, itemlist):
|
||||
logger.info()
|
||||
itemlist_fo = []
|
||||
|
||||
"""
|
||||
|
||||
@@ -190,6 +195,8 @@ def post_tmdb_listado(item, itemlist):
|
||||
del item.channel_alt
|
||||
if item.url_alt:
|
||||
del item.url_alt
|
||||
if item.extra2:
|
||||
del item.extra2
|
||||
#Ajustamos el nombre de la categoría
|
||||
if not item.category_new:
|
||||
item.category_new = ''
|
||||
@@ -210,6 +217,8 @@ def post_tmdb_listado(item, itemlist):
|
||||
del item_local.channel_alt
|
||||
if item_local.url_alt:
|
||||
del item_local.url_alt
|
||||
if item_local.extra2:
|
||||
del item_local.extra2
|
||||
|
||||
#Ajustamos el nombre de la categoría
|
||||
item_local.category = scrapertools.find_single_match(item_local.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
|
||||
@@ -250,8 +259,6 @@ def post_tmdb_listado(item, itemlist):
|
||||
|
||||
# Preparamos el título para series, con los núm. de temporadas, si las hay
|
||||
if item_local.contentType in ['season', 'tvshow', 'episode']:
|
||||
if item_local.infoLabels['title']: del item_local.infoLabels['title']
|
||||
|
||||
if item_local.contentType == "episode":
|
||||
if "Temporada" in title: #Compatibilizamos "Temporada" con Unify
|
||||
title = '%sx%s al 99 -' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber))
|
||||
@@ -263,7 +270,7 @@ def post_tmdb_listado(item, itemlist):
|
||||
|
||||
elif item_local.infoLabels['episodio_titulo']:
|
||||
title = '%s %s, %s' % (title, item_local.infoLabels['episodio_titulo'], item_local.contentSerieName)
|
||||
item_local.infoLabels['episodio_titulo'] = '%s, %s [%s] [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.contentSerieName, item_local.infoLabels['year'], rating)
|
||||
item_local.infoLabels['episodio_titulo'] = '%s- %s [%s] [%s]' % (item_local.infoLabels['episodio_titulo'], item_local.contentSerieName, item_local.infoLabels['year'], rating)
|
||||
|
||||
else: #Si no hay título de episodio, ponermos el nombre de la serie
|
||||
if item_local.contentSerieName not in title:
|
||||
@@ -291,7 +298,7 @@ def post_tmdb_listado(item, itemlist):
|
||||
elif item.action == "search":
|
||||
title += " -Serie-"
|
||||
|
||||
elif item_local.extra == "varios" and (item.action == "search" or item.action == "listado_busqueda"):
|
||||
if (item_local.extra == "varios" or item_local.extra == "documentales") and (item.action == "search" or item.action == "listado_busqueda"):
|
||||
title += " -Varios-"
|
||||
item_local.contentTitle += " -Varios-"
|
||||
|
||||
@@ -325,10 +332,20 @@ def post_tmdb_listado(item, itemlist):
|
||||
|
||||
#logger.debug(item_local)
|
||||
|
||||
#Si intervención judicial, alerto!!!
|
||||
if item.intervencion:
|
||||
for clone_inter, autoridad in item.intervencion:
|
||||
thumb_intervenido = get_thumb(autoridad)
|
||||
itemlist_fo.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido))
|
||||
del item.intervencion
|
||||
|
||||
#Si ha habido fail-over, lo comento
|
||||
if channel_alt and item.category_new != "newest":
|
||||
itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR] [ALT ] en uso'))
|
||||
itemlist.append(item.clone(action='', title="[COLOR yellow]" + channel_alt.capitalize() + '[/COLOR] inaccesible'))
|
||||
itemlist_fo.append(item.clone(action='', title="[COLOR yellow]" + item.category + '[/COLOR] [ALT ] en uso'))
|
||||
itemlist_fo.append(item.clone(action='', title="[COLOR yellow]" + channel_alt.capitalize() + '[/COLOR] inaccesible'))
|
||||
|
||||
if len(itemlist_fo) > 0:
|
||||
itemlist = itemlist_fo + itemlist
|
||||
|
||||
del item.category_new
|
||||
|
||||
@@ -337,6 +354,7 @@ def post_tmdb_listado(item, itemlist):
|
||||
|
||||
def post_tmdb_episodios(item, itemlist):
|
||||
logger.info()
|
||||
itemlist_fo = []
|
||||
|
||||
"""
|
||||
|
||||
@@ -400,7 +418,7 @@ def post_tmdb_episodios(item, itemlist):
|
||||
if item.title_from_channel:
|
||||
del item.title_from_channel
|
||||
|
||||
for item_local in itemlist: #Recorremos el Itenlist generado por el canal
|
||||
for item_local in itemlist: #Recorremos el Itemlist generado por el canal
|
||||
if item_local.add_videolibrary:
|
||||
del item_local.add_videolibrary
|
||||
if item_local.add_menu:
|
||||
@@ -409,6 +427,23 @@ def post_tmdb_episodios(item, itemlist):
|
||||
del item_local.contentSeason_save
|
||||
if item_local.title_from_channel:
|
||||
del item_local.title_from_channel
|
||||
if item_local.library_playcounts:
|
||||
del item_local.library_playcounts
|
||||
if item_local.library_urls:
|
||||
del item_local.library_urls
|
||||
if item_local.path:
|
||||
del item_local.path
|
||||
if item_local.nfo:
|
||||
del item_local.nfo
|
||||
if item_local.update_last:
|
||||
del item_local.update_last
|
||||
if item_local.update_next:
|
||||
del item_local.update_next
|
||||
if item_local.channel_host:
|
||||
del item_local.channel_host
|
||||
if item_local.intervencion:
|
||||
del item_local.intervencion
|
||||
#logger.debug(item_local)
|
||||
|
||||
#Ajustamos el nombre de la categoría si es un clone de NewPct1
|
||||
item_local.category = scrapertools.find_single_match(item_local.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
|
||||
@@ -532,7 +567,7 @@ def post_tmdb_episodios(item, itemlist):
|
||||
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
|
||||
itemlist.append(item.clone(title="** [COLOR yelow]Actualizar Títulos - vista previa videoteca[/COLOR] **", action="actualizar_titulos", extra="episodios", tmdb_stat=False, from_action=item.action, from_title=item.title))
|
||||
itemlist.append(item.clone(title="** [COLOR yelow]Actualizar Títulos - vista previa videoteca[/COLOR] **", action="actualizar_titulos", tmdb_stat=False, from_action=item.action, from_title=item.title))
|
||||
|
||||
#Borro num. Temporada si no viene de menú de Añadir a Videoteca y no está actualizando la Videoteca
|
||||
if not item.library_playcounts: #si no está actualizando la Videoteca
|
||||
@@ -583,15 +618,25 @@ def post_tmdb_episodios(item, itemlist):
|
||||
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 videoteca-[/COLOR]" + title, action="add_serie_to_library", extra="episodios", add_menu=True))
|
||||
|
||||
#Si ha habido fail-over, lo comento
|
||||
if channel_alt:
|
||||
itemlist.append(item.clone(action='', title="[COLOR yellow]" + channel_alt.capitalize() + '[/COLOR] [ALT ] en uso'))
|
||||
itemlist.append(item.clone(action='', title="[COLOR yellow]" + item.category.capitalize() + '[/COLOR] inaccesible'))
|
||||
#Si intervención judicial, alerto!!!
|
||||
if item.intervencion:
|
||||
for clone_inter, autoridad in item.intervencion:
|
||||
thumb_intervenido = get_thumb(autoridad)
|
||||
itemlist_fo.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido))
|
||||
del item.intervencion
|
||||
|
||||
if item.add_videolibrary: #Estamos Añadiendo a la Videoteca.
|
||||
del item.add_videolibrary #Borramos ya el indicador
|
||||
if item.add_menu: #Opción que avisa si se ha añadido a la Videoteca
|
||||
del item.add_menu #desde la página de Episodios o desde Menú Contextual
|
||||
#Si ha habido fail-over, lo comento
|
||||
if channel_alt:
|
||||
itemlist_fo.append(item.clone(action='', title="[COLOR yellow]" + channel_alt.capitalize() + '[/COLOR] [ALT ] en uso'))
|
||||
itemlist_fo.append(item.clone(action='', title="[COLOR yellow]" + item.category.capitalize() + '[/COLOR] inaccesible'))
|
||||
|
||||
if len(itemlist_fo) > 0:
|
||||
itemlist = itemlist_fo + itemlist
|
||||
|
||||
if item.add_videolibrary: #Estamos Añadiendo a la Videoteca.
|
||||
del item.add_videolibrary #Borramos ya el indicador
|
||||
if item.add_menu: #Opción que avisa si se ha añadido a la Videoteca
|
||||
del item.add_menu #desde la página de Episodios o desde Menú Contextual
|
||||
|
||||
#logger.debug(item)
|
||||
|
||||
@@ -631,7 +676,7 @@ def post_tmdb_findvideos(item, itemlist):
|
||||
|
||||
#Salvamos la información de max num. de episodios por temporada para despues de TMDB
|
||||
num_episodios = item.contentEpisodeNumber
|
||||
if item.infoLabels['temporada_num_episodios']:
|
||||
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
|
||||
@@ -712,6 +757,13 @@ def post_tmdb_findvideos(item, itemlist):
|
||||
elif (config.get_setting("quit_channel_name", "videolibrary") == 1 or item.channel == channel_py) and item.contentChannel == "videolibrary":
|
||||
title_gen = '%s: %s' % (item.category.capitalize(), title_gen)
|
||||
|
||||
#Si intervención judicial, alerto!!!
|
||||
if item.intervencion:
|
||||
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))
|
||||
del item.intervencion
|
||||
|
||||
#Pintamos el pseudo-título con toda la información disponible del vídeo
|
||||
itemlist.append(item.clone(action="", server = "", title=title_gen)) #Título con todos los datos del vídeo
|
||||
|
||||
@@ -747,12 +799,13 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
La llamada al método desde el principio de Submenu, Listado_Búsqueda, Episodios y Findvideos, es:
|
||||
|
||||
from lib import generictools
|
||||
item, data = generictools.fail_over_newpct1(item, patron)
|
||||
item, data = generictools.fail_over_newpct1(item, patron[, patron2=][, timeout=])
|
||||
|
||||
- Entrada: patron: con este patron permite verificar si los datos de la nueva web son buenos
|
||||
- Entrada (opcional): patron2: segundo patron opcional
|
||||
- Entrada (opcional): timeout: valor de espera máximo en download de página. Por defecto 3
|
||||
- Saida: data: devuelve los datos del la nueva web. Si vuelve vacía es que no se ha encontrado alternativa
|
||||
- Entrada (opcional): patron=True: pide que sólo verifique si el canal en uso está activo, si no, ofrece otro
|
||||
- Salida: data: devuelve los datos del la nueva web. Si vuelve vacía es que no se ha encontrado alternativa
|
||||
|
||||
"""
|
||||
#logger.debug(item)
|
||||
@@ -771,13 +824,12 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
|
||||
#Array con los datos de los canales alternativos
|
||||
#Cargamos en .json del canal para ver las listas de valores en settings
|
||||
fail_over_list = channeltools.get_channel_json(channel_py)
|
||||
for settings in fail_over_list['settings']: #Se recorren todos los settings
|
||||
fail_over = channeltools.get_channel_json(channel_py)
|
||||
for settings in fail_over['settings']: #Se recorren todos los settings
|
||||
if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting
|
||||
fail_over_list = settings['default'] #Carga lista de clones
|
||||
fail_over = settings['default'] #Carga lista de clones
|
||||
break
|
||||
#fail_over_list = config.get_setting('clonenewpct1_channels_list', channel_py)
|
||||
fail_over_list = ast.literal_eval(fail_over_list)
|
||||
fail_over_list = ast.literal_eval(fail_over)
|
||||
|
||||
#Recorremos el Array identificando el canal que falla
|
||||
for active, channel, channel_host, contentType, action_excluded in fail_over_list:
|
||||
@@ -790,8 +842,9 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
channel_failed = channel #salvamos el nombre del canal o categoría
|
||||
channel_host_failed = channel_host #salvamos el nombre del host
|
||||
channel_url_failed = item.url #salvamos la url
|
||||
if patron == True and active == '1': #solo nos han pedido verificar el clone
|
||||
return (item, data) #nos vamos, con el mismo clone, si está activo
|
||||
if (item.action == 'episodios' or item.action == 'findvideos') and item.contentType not in contentType: #soporta el fail_over de este contenido?
|
||||
data = ''
|
||||
logger.error("ERROR 99: " + item.action.upper() + ": Acción no soportada para Fail-Over en canal: " + item.url)
|
||||
return (item, data) #no soporta el fail_over de este contenido, no podemos hacer nada
|
||||
break
|
||||
@@ -799,7 +852,7 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
if not channel_failed:
|
||||
logger.error(item)
|
||||
return (item, data) #Algo no ha funcionado, no podemos hacer nada
|
||||
|
||||
|
||||
#Recorremos el Array identificando canales activos que funcionen, distintos del caído, que soporten el contenido
|
||||
for active, channel, channel_host, contentType, action_excluded in fail_over_list:
|
||||
data_alt = ''
|
||||
@@ -819,8 +872,11 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
item.channel_host = channel_host
|
||||
#quitamos el código de series, porque puede variar entre webs
|
||||
if item.action == "episodios" or item.action == "get_seasons":
|
||||
item.url = re.sub(r'\/\d+$', '', item.url) #parece que con el título solo ecuentra la serie, normalmente...
|
||||
item.url = re.sub(r'\/\d+\/?$', '', item.url) #parece que con el título solo ecuentra la serie, normalmente...
|
||||
|
||||
if patron == True: #solo nos han pedido verificar el clone
|
||||
return (item, data) #nos vamos, con un nuevo clone
|
||||
|
||||
#Leemos la nueva url
|
||||
try:
|
||||
if item.post:
|
||||
@@ -842,12 +898,14 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
data_alt = scrapertools.find_single_match(data_alt, patron2)
|
||||
if not data_alt: #no ha habido suerte, probamos con el siguiente canal
|
||||
logger.error("ERROR 02: " + item.action + ": Ha cambiado la estructura de la Web: " + item.url + " / Patron: " + patron)
|
||||
web_intervenida(item, data)
|
||||
data = ''
|
||||
continue
|
||||
else:
|
||||
break #por fin !!! Este canal parece que funciona
|
||||
else:
|
||||
logger.error("ERROR 02: " + item.action + ": Ha cambiado la estructura de la Web: " + item.url + " / Patron: " + patron)
|
||||
web_intervenida(item, data)
|
||||
data = ''
|
||||
continue
|
||||
|
||||
@@ -869,14 +927,88 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
|
||||
#logger.debug(item)
|
||||
|
||||
return (item, data)
|
||||
|
||||
|
||||
|
||||
def redirect_clone_newpct1(item):
|
||||
def web_intervenida(item, data, desactivar=True):
|
||||
logger.info()
|
||||
|
||||
"""
|
||||
|
||||
Llamada para redirigir cualquier llamada a un clone de NewPct1 a NewPct1.py
|
||||
Llamada para verificar si la caída de un clone de Newpct1 es debido a una intervención judicial
|
||||
|
||||
La llamada al método desde es:
|
||||
|
||||
from lib import generictools
|
||||
item = generictools.web_intervenida(item, data[, desactivar=True])
|
||||
|
||||
- Entrada: data: resultado de la descarga. Nos permite analizar si se trata de una intervención
|
||||
- Entrada: desactivar=True: indica que desactiva el canal o clone en caso de intervención judicial
|
||||
- Salida: item.intervencion: devuele un array con el nombre del clone intervenido y el thumb de la autoridad que interviene. El canal puede anunciarlo.
|
||||
- Salida: Si es un clone de Newpct1, se desactiva el clone en el .json del Canal. Si es otro canal, se desactiva el canal en su .json.
|
||||
|
||||
"""
|
||||
|
||||
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
|
||||
if intervenido_policia in data:
|
||||
judicial = 'intervenido_pn.jpeg' #thumb de la Policia Nacional
|
||||
category = item.category
|
||||
if not item.category:
|
||||
category = item.channel
|
||||
intervencion = (category, judicial) #Guardamos el nombre canal/categoría y el thumb judicial
|
||||
if not item.intervencion:
|
||||
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)
|
||||
|
||||
if desactivar == False: #Si no queremos desactivar el canal, nos vamos
|
||||
return item
|
||||
|
||||
#Cargamos en .json del canal para ver las listas de valores en settings. Carga las claves desordenadas !!!
|
||||
from core import filetools
|
||||
import json
|
||||
json_data = channeltools.get_channel_json(item.channel)
|
||||
|
||||
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
|
||||
if action_excluded:
|
||||
if "intervenido" not in action_excluded:
|
||||
action_excluded += ', %s' % judicial #Agregamos el thumb de la autoridad judicial
|
||||
else:
|
||||
action_excluded = '%s' % judicial
|
||||
|
||||
#Reemplazamos el estado a desactivado y agregamos el thumb de la autoridad judicial
|
||||
settings['default'] = re.sub(r"\('\d', '%s', ('[^']+', '[^']*'), '[^']*'\)" % item.category.lower(), r"('0', '%s', \1, '%s')" % (item.category.lower(), action_excluded), settings['default'])
|
||||
|
||||
break
|
||||
else:
|
||||
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:
|
||||
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)
|
||||
except:
|
||||
logger.error("ERROR 98 al salvar el archivo: %s" % channel_path)
|
||||
|
||||
#logger.debug(item)
|
||||
|
||||
return item
|
||||
|
||||
|
||||
def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=False):
|
||||
logger.info()
|
||||
|
||||
"""
|
||||
|
||||
Llamada para redirigir cualquier llamada a un clone de NewPct1 a NewPct1.py, o de una url de un canal caido a una alternativa
|
||||
Incluye las llamadas estándar del canal y la llamadas externas:
|
||||
- Play fron Library
|
||||
- Videolibrary Update
|
||||
@@ -884,23 +1016,123 @@ def redirect_clone_newpct1(item):
|
||||
La lógica es reemplazar item.channel por "newpct1" y dejar el nombre del clone en item.category.
|
||||
De esta forma utiliza siempre el código de NewPct1.py, aunque con las urls y apariencia del clone seleccionado por el usuario.
|
||||
|
||||
Este método interroga la configruación de NewPct1 para extraer la lista de canales clones. Si item.channel es un clone de NewPct1 y está en esa lista, actualiza item.channel='newpct1'
|
||||
En el caso de un canal/clone caído o intervenido judicialmente, puede reemplazar el canal en item.channel, o el clone en item.category, y la parte de item.url que se introduzca en una tabla. Esta conversión sólo se realiza si el canal original está inactivo, pero lo realiza siempre para los clones, o si el canal de origen y destino son los mismos.
|
||||
|
||||
La llamada recibe el parámetro Item y lo devuleve actualizado
|
||||
Este método interroga el .json de NewPct1 para extraer la lista de canales clones. Si item.channel es un clone de NewPct1 y está en esa lista, actualiza item.channel='newpct1'
|
||||
|
||||
También en este .json está la tabla para la conversión de canales y urls:
|
||||
- activo: está o no activa esta entrada
|
||||
- canal_org: canal o clone de origen
|
||||
- canal_des: canal o clone de destino (puede ser el mismo)
|
||||
- url_org: parte de la url a sustituir de canal o clone de origen
|
||||
- url_des: parte de la url a sustituir de canal o clone de destino
|
||||
- patron1: expresión Regex aplicable a la url (opcional)
|
||||
- patron2: expresión Regex aplicable a la url (opcional)
|
||||
- patron3: expresión Regex aplicable a la url (opcional)
|
||||
- patron4: expresión Regex aplicable a la url (opcional)
|
||||
- patron5: expresión Regex aplicable a la url (opcional)
|
||||
- content_inc: contenido al que aplica esta entrada, o * (item.contentType o item.extra)
|
||||
- content_exc: contenido que se excluye de esta entrada (item.contentType) (opcional)
|
||||
- ow_force: indicador para la acción de "videolibrary_service.py". Puede crear la variable item.ow_force:
|
||||
- force: indica al canal que analize toda la serie y que videolibrary_service la reescriba
|
||||
- auto: indica a videolibrary_service que la reescriba
|
||||
- no: no acción especial para videolibrary_service
|
||||
ejemplo: ('1', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', 'auto')
|
||||
|
||||
La llamada recibe el parámetro Item, el .nfoy los devuleve actualizados, así como opcionalmente el parámetro "overwrite· que puede forzar la reescritura de todos los archivos de la serie
|
||||
|
||||
"""
|
||||
if not it:
|
||||
it = Item()
|
||||
#logger.debug(item)
|
||||
ow_force_param = True
|
||||
channel_enabled = False
|
||||
update_stat = 0
|
||||
|
||||
#Array con los datos de los canales alternativos
|
||||
#Cargamos en .json del canal para ver las listas de valores en settings
|
||||
#Cargamos en .json de Newpct1 para ver las listas de valores en settings
|
||||
fail_over_list = channeltools.get_channel_json(channel_py)
|
||||
for settings in fail_over_list['settings']: #Se recorren todos los settings
|
||||
if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting
|
||||
fail_over_list = settings['default'] #Carga lista de clones
|
||||
break
|
||||
#fail_over_list = config.get_setting('clonenewpct1_channels_list', channel_py)
|
||||
|
||||
if settings['id'] == "intervenidos_channels_list": #Encontramos en setting
|
||||
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
|
||||
channel = "'%s'" % item.channel
|
||||
if channel in fail_over_list:
|
||||
if channel in fail_over_list: #Si es un clone de Newpct1, se actualiza el canal
|
||||
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...
|
||||
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
|
||||
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 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
|
||||
if item.contentType not in content_inc:
|
||||
continue
|
||||
if item.contentType in content_exc: #Es esta nuestra entrada?
|
||||
continue
|
||||
if channel_enabled and canal_org != canal_des: #Si el canal está activo, puede ser solo...
|
||||
continue #... una intervención que afecte solo a una región
|
||||
item.url = item.url.replace(url_org, url_des) #reemplzamos una parte de url
|
||||
if patron1: #Hay expresión regex?
|
||||
url = scrapertools.find_single_match(item.url, 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
|
||||
if patron3: #Hay más expresión regex?
|
||||
url += scrapertools.find_single_match(item.url, 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
|
||||
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
|
||||
update_stat += 1 #Ya hemos actualizado algo
|
||||
|
||||
if update_stat > 0: #Ha habido alguna actualización? Entonces salvamos
|
||||
if item.channel == channel_py: #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
|
||||
if item.library_urls:
|
||||
item.library_urls.pop(canal_org, None)
|
||||
item.library_urls = {canal_des: item.url}
|
||||
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 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 item.contentType in ['tvshow', 'season'] and it.library_urls:
|
||||
if path == False:
|
||||
TVSHOWS_PATH = item.path
|
||||
else:
|
||||
TVSHOWS_PATH = path
|
||||
|
||||
return item
|
||||
# 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
|
||||
for archivo in ficheros:
|
||||
if canal_erase in archivo: #Borramos los .json que sean del canal intervenido
|
||||
filetools.remove(archivo)
|
||||
if "tvshow.nfo" in archivo:
|
||||
filetools.write(archivo, head_nfo + it.tojson()) #escribo el .nfo por si aborta update
|
||||
|
||||
#logger.debug(item)
|
||||
|
||||
return (item, it, overwrite)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 515 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
@@ -23,7 +23,11 @@ def update(path, p_dialog, i, t, serie, overwrite):
|
||||
serie.channel = channel
|
||||
serie.url = url
|
||||
|
||||
serie = generictools.redirect_clone_newpct1(serie) ###### Redirección al canal NewPct1.py si es un clone
|
||||
###### 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)
|
||||
except:
|
||||
pass
|
||||
|
||||
channel_enabled = channeltools.is_enabled(serie.channel)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user