Mejoras de código
This commit is contained in:
@@ -70,7 +70,7 @@
|
|||||||
"id": "timeout_downloadpage",
|
"id": "timeout_downloadpage",
|
||||||
"type": "list",
|
"type": "list",
|
||||||
"label": "Timeout (segs.) en descarga de páginas o verificación de servidores",
|
"label": "Timeout (segs.) en descarga de páginas o verificación de servidores",
|
||||||
"default": 5,
|
"default": 10,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"visible": true,
|
"visible": true,
|
||||||
"lvalues": [
|
"lvalues": [
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ channel = "grantorrent"
|
|||||||
dict_url_seasons = dict()
|
dict_url_seasons = dict()
|
||||||
__modo_grafico__ = config.get_setting('modo_grafico', channel)
|
__modo_grafico__ = config.get_setting('modo_grafico', channel)
|
||||||
timeout = config.get_setting('timeout_downloadpage', channel)
|
timeout = config.get_setting('timeout_downloadpage', channel)
|
||||||
|
if timeout <= 5: timeout = timeout*2
|
||||||
modo_serie_temp = config.get_setting('seleccionar_serie_temporada', channel)
|
modo_serie_temp = config.get_setting('seleccionar_serie_temporada', channel)
|
||||||
modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', channel)
|
modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', channel)
|
||||||
|
|
||||||
@@ -154,10 +155,10 @@ def listado(item):
|
|||||||
inicio = time.time() # Controlaremos que el proceso no exceda de un tiempo razonable
|
inicio = time.time() # Controlaremos que el proceso no exceda de un tiempo razonable
|
||||||
fin = inicio + 5 # Después de este tiempo pintamos (segundos)
|
fin = inicio + 5 # Después de este tiempo pintamos (segundos)
|
||||||
timeout_search = timeout # Timeout para descargas
|
timeout_search = timeout # Timeout para descargas
|
||||||
if item.extra == 'search':
|
if item.action == 'search':
|
||||||
timeout_search = timeout * 2 # Timeout un poco más largo para las búsquedas
|
timeout_search = int(timeout * 1.5) # Timeout un poco más largo para las búsquedas
|
||||||
if timeout_search < 5:
|
if timeout_search < 10:
|
||||||
timeout_search = 5 # Timeout un poco más largo para las búsquedas
|
timeout_search = 10 # Timeout un poco más largo para las búsquedas
|
||||||
|
|
||||||
#Máximo num. de líneas permitidas por TMDB (40). Máx de 5 páginas por Itemlist para no degradar el rendimiento.
|
#Máximo num. de líneas permitidas por TMDB (40). Máx de 5 páginas por Itemlist para no degradar el rendimiento.
|
||||||
#Si itemlist sigue vacío después de leer 5 páginas, se pueden llegar a leer hasta 10 páginas para encontrar algo
|
#Si itemlist sigue vacío después de leer 5 páginas, se pueden llegar a leer hasta 10 páginas para encontrar algo
|
||||||
@@ -170,12 +171,12 @@ def listado(item):
|
|||||||
item.post = item.url
|
item.post = item.url
|
||||||
video_section = ''
|
video_section = ''
|
||||||
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.post, timeout=timeout_search).data)
|
data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.post, timeout=timeout_search).data)
|
||||||
video_section = scrapertools.find_single_match(data, '<div class="contenedor-home">(.*?</div>)</div></div>')
|
video_section = scrapertools.find_single_match(data, '<div class="contenedor-home">(?:\s*<div class="titulo-inicial">\s*Últi.*?Añadi...\s*<\/div>)?\s*<div class="contenedor-imagen">\s*(<div class="imagen-post">.*?<\/div><\/div>)<\/div>')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
cnt_next += 1
|
cnt_next += 1
|
||||||
if not data: #Si la web está caída salimos sin dar error
|
if not data or 'Error 503 Backend fetch failed' in 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)
|
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'))
|
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'))
|
||||||
if len(itemlist) > 1:
|
if len(itemlist) > 1:
|
||||||
@@ -217,12 +218,12 @@ def listado(item):
|
|||||||
cnt_next = 99 #No hay más páginas. Salir del bucle después de procesar ésta
|
cnt_next = 99 #No hay más páginas. Salir del bucle después de procesar ésta
|
||||||
|
|
||||||
# Preparamos un patron que pretende recoger todos los datos significativos del video
|
# Preparamos un patron que pretende recoger todos los datos significativos del video
|
||||||
patron = '<a href="(?P<url>[^"]+)"><img.*?src="(?P<thumb>[^"]+)".*?'
|
patron = '<div class="imagen-post">\s*<a href="(?P<url>[^"]+)"><img.*?src="(?P<thumb>[^"]+)".*?'
|
||||||
if "categoria" in item.url or item.media == "search": #Patron distinto para páginas de Categorías o Búsquedas
|
if "categoria" in item.url or item.media == "search": #Patron distinto para páginas de Categorías o Búsquedas
|
||||||
patron += 'class="attachment-(?P<quality>.*?)-(?P<lang>[^\s]+)\s.*?'
|
patron += 'class="attachment-(?P<quality>.*?)-(?P<lang>[^\s]+)\s.*?'
|
||||||
else:
|
else:
|
||||||
patron += 'class="bloque-superior">\s*(?P<quality>.*?)\s*<div class="imagen-idioma">\s*<img src=".*?icono_(?P<lang>[^\.]+).*?'
|
patron += 'class="bloque-superior">\s*(?P<quality>.*?)\s*<div class="imagen-idioma">\s*<img src=".*?icono_(?P<lang>[^\.]+).*?'
|
||||||
patron += '<div class="bloque-inferior">\s*(?P<title>.*?)\s*<\/div>\s?<div class="bloque-date">\s*(?P<date>.*?)\s*<\/div>'
|
patron += '<div class="bloque-inferior">\s*(?P<title>.*?)\s*<\/div>\s*<div class="bloque-date">\s*(?P<date>.*?)\s*<\/div>\s*<\/div>'
|
||||||
|
|
||||||
matches_alt = re.compile(patron, re.DOTALL).findall(video_section)
|
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
|
if not matches_alt and not '<div class="titulo-load-core">0 resultados' in data: #error
|
||||||
@@ -231,6 +232,7 @@ def listado(item):
|
|||||||
item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error
|
item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error
|
||||||
return itemlist #Salimos
|
return itemlist #Salimos
|
||||||
|
|
||||||
|
if video_section: data = video_section
|
||||||
logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data)
|
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'))
|
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'))
|
||||||
if len(itemlist) > 1:
|
if len(itemlist) > 1:
|
||||||
|
|||||||
@@ -327,6 +327,8 @@ def post_tmdb_listado(item, itemlist):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
__modo_grafico__ = config.get_setting('modo_grafico', item.channel)
|
||||||
|
|
||||||
# Si TMDB no ha encontrado el vídeo limpiamos el año
|
# Si TMDB no ha encontrado el vídeo limpiamos el año
|
||||||
if item_local.infoLabels['year'] == "-":
|
if item_local.infoLabels['year'] == "-":
|
||||||
item_local.infoLabels['year'] = ''
|
item_local.infoLabels['year'] = ''
|
||||||
@@ -338,7 +340,7 @@ def post_tmdb_listado(item, itemlist):
|
|||||||
logger.error(item_local)
|
logger.error(item_local)
|
||||||
del item_local.infoLabels['tmdb_id'] #puede traer un TMDB-ID erroneo
|
del item_local.infoLabels['tmdb_id'] #puede traer un TMDB-ID erroneo
|
||||||
try:
|
try:
|
||||||
tmdb.set_infoLabels(item_local, True) #pasamos otra vez por TMDB
|
tmdb.set_infoLabels(item_local, __modo_grafico__) #pasamos otra vez por TMDB
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
logger.error(item_local)
|
logger.error(item_local)
|
||||||
@@ -349,7 +351,7 @@ def post_tmdb_listado(item, itemlist):
|
|||||||
year = item_local.infoLabels['year'] #salvamos el año por si no tiene éxito la nueva búsqueda
|
year = item_local.infoLabels['year'] #salvamos el año por si no tiene éxito la nueva búsqueda
|
||||||
item_local.infoLabels['year'] = "-" #reseteo el año
|
item_local.infoLabels['year'] = "-" #reseteo el año
|
||||||
try:
|
try:
|
||||||
tmdb.set_infoLabels(item_local, True) #pasamos otra vez por TMDB
|
tmdb.set_infoLabels(item_local, __modo_grafico__) #pasamos otra vez por TMDB
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if not item_local.infoLabels['tmdb_id']: #ha tenido éxito?
|
if not item_local.infoLabels['tmdb_id']: #ha tenido éxito?
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;)
|
|||||||
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
|
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
|
||||||
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
|
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
|
||||||
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; .NET4.0C; .NE
|
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; .NET4.0C; .NE
|
||||||
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; SLCC2; .NET CLR 2.0.50727; InfoPath.3; .NET4.0C; .NET4.0E; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8)
|
|
||||||
Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
|
Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.0.3705; Media Center PC 3.1; Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
|
||||||
Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)
|
Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)
|
||||||
Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
|
Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
|
||||||
@@ -36,7 +35,6 @@ Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)
|
|||||||
Mozilla/4.0 (compatible; MSIE 8.0; Linux i686; en) Opera 10.51
|
Mozilla/4.0 (compatible; MSIE 8.0; Linux i686; en) Opera 10.51
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; ko) Opera 10.53
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; ko) Opera 10.53
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; pl) Opera 11.00
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; pl) Opera 11.00
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; en) Opera 11.00
|
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; ja) Opera 11.00
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; ja) Opera 11.00
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; en) Opera 10.62
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; en) Opera 10.62
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; fr) Opera 11.00
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; fr) Opera 11.00
|
||||||
@@ -46,7 +44,6 @@ Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .N
|
|||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8;
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8;
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8;
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8;
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8;
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8;
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8)
|
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; msn Optimized
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; msn Optimized
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 3.0)
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 3.0)
|
||||||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)
|
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)
|
||||||
@@ -373,7 +370,6 @@ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b4pre) Gecko/20090401 Fi
|
|||||||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b4pre) Gecko/20090409 Firefox/3.5b4pre
|
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b4pre) Gecko/20090409 Firefox/3.5b4pre
|
||||||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b5pre) Gecko/20090517 Firefox/3.5b4pre (.NET CLR 3.5.30729)
|
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b5pre) Gecko/20090517 Firefox/3.5b4pre (.NET CLR 3.5.30729)
|
||||||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.0.16 (.NET CLR 3.5.30729)
|
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.0.16 (.NET CLR 3.5.30729)
|
||||||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.9.0.2) Gecko/2008092313 Ubuntu/9.25 (jaunty) Firefox
|
|
||||||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2b4) Gecko/20091124 Firefox/3.6b4
|
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2b4) Gecko/20091124 Firefox/3.6b4
|
||||||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b1) Gecko/2007110703 Firefox/3.0b1
|
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b1) Gecko/2007110703 Firefox/3.0b1
|
||||||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3
|
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3
|
||||||
|
|||||||
|
Reference in New Issue
Block a user