NewPct1: mejoras en Alta Disponibilidad

This commit is contained in:
Kingbox
2019-03-06 16:01:14 +01:00
parent 2d34dafa4c
commit 60ad90829d
2 changed files with 29 additions and 15 deletions

View File

@@ -1315,7 +1315,7 @@ def findvideos(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 = host.capitalize()
item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
verify_fo = True #Verificamos si el clone a usar está activo
item, data = generictools.fail_over_newpct1(item, verify_fo)
@@ -1446,8 +1446,9 @@ def findvideos(item):
if scrapertools.find_single_match(data, patron):
patron = patron_alt
url_torr = scrapertools.find_single_match(data, patron)
if not url_torr.startswith("http"): #Si le falta el http.: lo ponemos
url_torr = scrapertools.find_single_match(host, '(\w+:)//') + url_torr
if not url_torr.startswith("http"): #Si le falta el http.: lo ponemos
url_torr = scrapertools.find_single_match(item.channel_host, '(\w+:)//') + url_torr
#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) or not videolibrarytools.verify_url_torrent(url_torr): # Si no hay datos o url, error
item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada
@@ -1509,6 +1510,9 @@ def findvideos(item):
patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent
if not scrapertools.find_single_match(data, patron):
patron = '<a href="([^"]+)"\s?title="[^"]+"\s?class="btn-torrent"' #Patron para .torrent (planetatorrent)
url_torr = scrapertools.find_single_match(data, patron)
if not url_torr.startswith("http"): #Si le falta el http.: lo ponemos
url_torr = scrapertools.find_single_match(item.channel_host, '(\w+:)//') + url_torr
#buscamos el tamaño del .torrent
size = scrapertools.find_single_match(data, '<div class="entry-left".*?><a href=".*?span class=.*?>Size:<\/strong>?\s(\d+?\.?\d*?\s\w[b|B])<\/span>')
@@ -1884,11 +1888,11 @@ def episodios(item):
season_display = item.from_num_season_colapse
# Obtener la información actualizada de la Serie. TMDB es imprescindible para Videoteca
if not item.infoLabels['tmdb_id']:
try:
tmdb.set_infoLabels(item, True) #TMDB de cada Temp
except:
pass
#if not item.infoLabels['tmdb_id']:
try:
tmdb.set_infoLabels(item, True) #TMDB de cada Temp
except:
pass
modo_ultima_temp_alt = modo_ultima_temp
if item.ow_force == "1": #Si hay un traspaso de canal o url, se actualiza todo
@@ -1972,6 +1976,7 @@ def episodios(item):
num_temporadas_flag = True
else:
num_temporadas_flag = False
for page in list_pages: #Recorre la lista de páginas
if not list_pages:
break
@@ -2075,7 +2080,7 @@ def episodios(item):
itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: EPISODIOS: Ha cambiado la estructura de la Web. Reportar el error con el log'))
break #si no hay más datos, algo no funciona, pintamos lo que tenemos
#Si no se encuentran valores, pero poner lo básico
#Si no se encuentran valores, se pone lo básico
if match['season'] is None or match['season'] == "0" or not match['season']: match['season'] = season
if match['episode'] is None: match['episode'] = "0"
try:
@@ -2085,6 +2090,7 @@ def episodios(item):
if match['season'] > max_temp:
logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches))
match['season'] = scrapertools.find_single_match(item_local.url, '\/[t|T]emp\w+-*(\d+)\/')
num_temporadas_flag = False
if not match['season']:
match['season'] = season_alt
else:

View File

@@ -1494,8 +1494,9 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
fail_over = settings['default'] #Carga lista de clones
break
fail_over_list = ast.literal_eval(fail_over)
#logger.debug(str(fail_over_list))
if item.from_channel and item.from_channel != 'videolibrary': #Desde search puede venir con el nombre de canal equivocado
if item.from_channel and item.from_channel != 'videolibrary': #Desde search puede venir con el nombre de canal equivocado
item.channel = item.from_channel
#Recorremos el Array identificando el canal que falla
for active, channel, channel_host, contentType, action_excluded in fail_over_list:
@@ -1508,10 +1509,11 @@ 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
#logger.debug(channel_failed + ' / ' + channel_host_failed)
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?
if (item.action == 'episodios' or item.action == "update_tvshow" or item.action == "get_seasons" or item.action == 'findvideos') and item.contentType not in contentType: #soporta el fail_over de este contenido?
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
@@ -1526,7 +1528,7 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
data_alt = ''
if channel == channel_failed or active == '0' or item.action in action_excluded or item.extra2 in action_excluded: #es válido el nuevo canal?
continue
if (item.action == 'episodios' or item.action == 'findvideos') and item.contentType not in contentType: #soporta el contenido?
if (item.action == 'episodios' or item.action == "update_tvshow" or item.action == "get_seasons" or item.action == 'findvideos') and item.contentType not in contentType: #soporta el contenido?
continue
#Hacemos el cambio de nombre de canal y url, conservando las anteriores como ALT
@@ -1536,12 +1538,16 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
item.category = channel.capitalize()
item.url_alt = channel_url_failed
item.url = channel_url_failed
item.url = item.url.replace(channel_host_failed, channel_host)
channel_host_bis = re.sub(r'(?i)http.*://', '', channel_host)
channel_host_failed_bis = re.sub(r'(?i)http.*://', '', channel_host_failed)
item.url = item.url.replace(channel_host_failed_bis, channel_host_bis)
url_alt += [item.url] #salvamos la url para el bucle
item.channel_host = channel_host
#logger.debug(str(url_alt))
#quitamos el código de series, porque puede variar entre webs
if item.action == "episodios" or item.action == "get_seasons":
if item.action == "episodios" or item.action == "get_seasons" or item.action == "update_tvshow":
item.url = re.sub(r'\/\d+\/?$', '', item.url) #parece que con el título solo ecuentra la serie, normalmente...
url_alt = [item.url] #salvamos la url para el bucle, pero de momento ignoramos la inicial con código de serie
@@ -1602,9 +1608,11 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None):
#Función especial para encontrar en otro clone un .torrent válido
if verify_torrent == 'torrent:check:status':
from core import videolibrarytools
if not data_alt.startswith("http"): #Si le falta el http.: lo ponemos
data_alt = scrapertools.find_single_match(item.channel_host, '(\w+:)//') + data_alt
if videolibrarytools.verify_url_torrent(data_alt): #verificamos si el .torrent existe
item.url = url #guardamos la url que funciona
break #nos vamos, con la nueva url del .torrent verificada
break #nos vamos, con la nueva url del .torrent verificada
data = ''
continue #no vale el .torrent, continuamos
item.url = url #guardamos la url que funciona, sin verificar