From dab92fdda3f921c60229687f8c2842d7500b0ced Mon Sep 17 00:00:00 2001
From: Kingbox <37674310+lopezvg@users.noreply.github.com>
Date: Thu, 17 May 2018 18:27:00 +0200
Subject: [PATCH] Mejor Torrent
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Arreglo de problemas con Videoteca
- Normalización de títulos
---
plugin.video.alfa/channels/mejortorrent.py | 326 +++++++++++++--------
1 file changed, 200 insertions(+), 126 deletions(-)
diff --git a/plugin.video.alfa/channels/mejortorrent.py b/plugin.video.alfa/channels/mejortorrent.py
index 424c122c..0fd1236b 100755
--- a/plugin.video.alfa/channels/mejortorrent.py
+++ b/plugin.video.alfa/channels/mejortorrent.py
@@ -105,7 +105,7 @@ def listado(item):
item.action = "findvideos"
item.contentType = "movie"
pag = False #No hay paginación
- elif item.extra == "peliculas" and not item.tipo: #Desde Menún principal
+ elif item.extra == "peliculas" and not item.tipo: #Desde Menú principal
patron = '?'
patron += ''
patron_enlace = "/peli-descargar-torrent-\d+-(.*?)\.html"
@@ -278,24 +278,24 @@ def listado(item):
title = scrapedtitle
title_subs = ""
- item_local.language = ""
- if "[subs" in title or "[Subs" in title or "[VOS" in title or "[VOSE" in title or "(V.O.S.E" in title:
- item_local.language = "VOS"
- title = title.replace(" [Subs. integrados]", "").replace(" [subs. Integrados]", "").replace(" [VOSE", "").replace(" (V.O.S.E)", "")
- if "latino" in title or "Latino" in title or "rgentina" in title:
- item_local.language = "LAT"
+ item_local.language = []
+ if "[subs" in title.lower() or "[vos" in title.lower() or "v.o.s" in title.lower():
+ item_local.language += ["VOS"]
+ title = title.replace(" [Subs. integrados]", "").replace(" [subs. Integrados]", "").replace(" [VOSE", "").replace(" [VOS", "").replace(" (V.O.S.E)", "")
+ if "latino" in title.lower() or "argentina" in title.lower():
+ item_local.language += ["LAT"]
title = title.replace(" Latino", "").replace(" latino", "").replace(" Argentina", "").replace(" argentina", "")
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "")
- if "3d" in title or "3D" in title: #Reservamos info de subtítulos para después de TMDB
- title_subs = "[3D]"
+ if "3d" in title.lower(): #Reservamos info para después de TMDB
+ title_subs = " 3D"
title = title.replace(" [3d]", "").replace(" 3d", "").replace(" [3D]", "").replace(" 3D", "")
- if "Temp" in title or "temp" in title: #Reservamos info de Temporada para después de TMDB
+ if "temp" in title.lower(): #Reservamos info de Temporada para después de TMDB
title_subs = "[Temp.]"
- if "Audio" in title or "audio" in title: #Reservamos info de subtítulos para después de TMDB
+ if "audio" in title.lower(): #Reservamos info de audio para después de TMDB
title_subs = '[%s]' % scrapertools.find_single_match(title, r'(\[[a|A]udio.*?\])')
title = re.sub(r'\[[a|A]udio.*?\]', '', title)
- if "[Dual" in title or "[dual" in title:
+ if "[dual" in title.lower():
title_subs = "[Dual]"
title = title = re.sub(r'\[D|dual.*?\]', '', title)
@@ -312,9 +312,9 @@ def listado(item):
# Ahora preparamos el título y la calidad tanto para series como para documentales y películas
# scrapedinfo tiene la calidad, pero solo en llamadas desde peliculas sin alfabeto
if item_local.extra == "series" or item_local.extra == "documentales":
- item_local.quality = scrapertools.find_single_match(scrapedtitle, '.*?[\[|\(](.*?\d+.*?)[\)|\]]')
+ item_local.quality = scrapertools.find_single_match(scrapedtitle, '.*?[\[|\(](\d+.*?)[\)|\]]')
if item_local.quality:
- title = re.sub(r'[\[|\(].*?\d+.*?[\)|\]]', '', title) # Quitar la calidad del título
+ title = re.sub(r'[\[|\(]\d+.*?[\)|\]]', '', title) # Quitar la calidad del título
info = ""
item_local.contentSerieName = scrapertools.find_single_match(title, '(.*?) - \d.*?')
if not item_local.contentSerieName:
@@ -325,7 +325,7 @@ def listado(item):
if info != "" and not item_local.quality:
item_local.quality = info
- if "(HDRip" in title or "(BR" in title or "(HDRip" in title or "(VHSRip" in title or "(DVDRip" in title or "(FullB" in title or "(fullb" in title or "(Blu" in title or "(4K" in title or "(4k" in title or "(HEVC" in title or "(IMAX" in title or "Extendida" in title or "[720p]" in title or "[1080p]" in title:
+ if "(hdrip" in title.lower() or "(br" in title.lower() or "(vhsrip" in title.lower() or "(dvdrip" in title.lower() or "(fullb" in title.lower() or "(blu" in title.lower() or "(4k" in title.lower() or "(hevc" in title.lower() or "(imax" in title.lower() or "extendida" in title.lower() or "[720p]" in title.lower() or "[1080p]" in title.lower():
if not item_local.quality:
item_local.quality = scrapertools.find_single_match(title, r'\(.*?\)?\(.*?\)')
if not item_local.quality:
@@ -333,10 +333,10 @@ def listado(item):
title = re.sub(r'\(.*?\)?\(.*?\)', '', title)
title = re.sub(r'[\[|\(].*?[\)|\]]', '', title)
if not item_local.quality:
- if "FullBluRay" in title or "fullbluray" in title:
+ if "fullbluray" in title.lower():
item_local.quality = "FullBluRay"
title = title.replace("FullBluRay", "").replace("fullbluray", "")
- if "4K" in title or "4k" in title or "HDR" in title or "hdr" in title:
+ if "4k" in title.lower() or "hdr" in title.lower():
item_local.quality = "4K"
title = title.replace("4k-hdr", "").replace("4K-HDR", "").replace("hdr", "").replace("HDR", "").replace("4k", "").replace("4K", "")
title = title.replace("(", "").replace(")", "").replace("[", "").replace("]", "")
@@ -347,15 +347,19 @@ def listado(item):
if item_local.extra == "peliculas":
item_local.contentTitle = title
- if "Saga" in item_local.contentTitle or "Saga" in item_local.contentSerieName:
+ if "saga" in item_local.contentTitle.lower() or "saga" in item_local.contentSerieName.lower():
item_local.contentTitle = item_local.contentTitle.replace("Saga ", "").replace("Saga", "")
item_local.contentSerieName = item_local.contentSerieName.replace("Saga ", "").replace("Saga", "")
title_subs = "[Saga]"
- if "Colecc" in item_local.contentTitle or "Colecc" in item_local.contentSerieName:
+ if "colecc" in item_local.contentTitle.lower() or "colecc" in item_local.contentSerieName.lower():
item_local.contentTitle = item_local.contentTitle.replace("Coleccion ", "").replace("Coleccion", "")
item_local.contentSerieName = item_local.contentSerieName.replace("Coleccion ", "").replace("Coleccion", "")
title_subs = "[Coleccion]"
+ if "3D" in title_subs: #Si es 3D lo añadimos a calidad
+ item_local.quality = item_local.quality + title_subs
+ title_subs = ''
+
# Guardamos temporalmente info extra, si lo hay
item_local.extra = item_local.extra + title_subs
@@ -386,6 +390,15 @@ def listado(item):
if item_local.infoLabels['year'] == "-":
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
+
+ # Preparamos el título para series, con los núm. de temporadas, si las hay
+ if item_local.contentType == "season" or item_local.contentType == "tvshow":
+ item_local.contentTitle= ''
+
+ rating = ''
+ if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
+ rating = float(item_local.infoLabels['rating'])
+ rating = round(rating, 1)
#Cambiamos el título si son capítulos múltiples
if scrapertools.find_single_match(item_local.url, r'\d+x\d+.*?(\w+.*?\d+x\d+)'):
@@ -395,20 +408,20 @@ def listado(item):
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "episode":
if item_local.infoLabels['episodio_titulo']:
- title = '%sx%s %s, %s [%s][%s][%s]' % (str(item_local.contentSeason), item_local.contentEpisodeNumber, item_local.infoLabels['episodio_titulo'], item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), item_local.quality, item_local.language)
+ title = '%sx%s %s, %s [%s][%s][%s]' % (str(item_local.contentSeason), item_local.contentEpisodeNumber, item_local.infoLabels['episodio_titulo'], item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), item_local.quality, str(item_local.language))
else:
- title = '%sx%s %s [%s][%s][%s]' % (str(item_local.contentSeason), item_local.contentEpisodeNumber, item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), item_local.quality, item_local.language)
+ title = '%sx%s %s [%s][%s][%s]' % (str(item_local.contentSeason), item_local.contentEpisodeNumber, item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), item_local.quality, str(item_local.language))
item_local.infoLabels['title'] = item_local.contentSerieName
elif item_local.contentType == "season" or item_local.contentType == "tvshow":
if item_local.extra == "series" or temporada == "[Temp.]":
- title = '%s - Temporada %s [%s][%s][%s]' % (item_local.contentSerieName, str(item_local.contentSeason), scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), item_local.quality, item_local.language)
+ title = '%s - Temporada %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.contentSerieName, str(item_local.contentSeason), scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
else:
- title = '%s [%s][%s][%s]' % (item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), item_local.quality, item_local.language)
+ title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
- title = '%s [%s][%s][%s]' % (title, str(item_local.infoLabels['year']), item_local.quality, item_local.language)
-
+ title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
+
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
if item_local.contentType == "episode":
if item_local.infoLabels['episodio_titulo']:
@@ -424,7 +437,9 @@ def listado(item):
title = '%s -%s-' % (item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'))
title_subs = title_subs.replace("[", "-").replace("]", "-")
- title = title.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "")
+ title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "")
+ title = re.sub(r'\s\[COLOR \w+\]\[\]\[\/COLOR\]', '', title)
+ title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title)
item_local.title = title + title_subs
item_local.contentTitle += title_subs #añadimos info adicional para display
@@ -441,7 +456,7 @@ def listado(item):
itemlist.append(
Item(channel=item.channel, action="listado", title="[COLOR gold][B]Pagina siguiente >>[/B][/COLOR]", url=url_next_page, next_page=next_page, cnt_pag=cnt_pag, pag=pag, modo=modo, extra=item.extra, tipo=item.tipo))
- logger.debug(url_next_page + " / " + next_page + " / " + str(matches_cnt) + " / " + str(cnt_pag) + " / " + str(pag) + " / " + modo + " / " + item.extra + " / " + str(item.tipo))
+ #logger.debug(url_next_page + " / " + next_page + " / " + str(matches_cnt) + " / " + str(cnt_pag) + " / " + str(pag) + " / " + modo + " / " + item.extra + " / " + str(item.tipo))
return itemlist
@@ -478,6 +493,7 @@ def listado_busqueda(item):
patron_enlace = "\/doc-descargar-torrent-\d+-\d+-(.*?)\.html"
matches += re.compile(patron, re.DOTALL).findall(data)
+ #logger.debug("MATCHES: ")
#logger.debug(matches)
# Preparamos la paginación. Con un número variable de links, sin límite
@@ -531,14 +547,17 @@ def listado_busqueda(item):
# Limpiamos títulos, Sacamos datos de calidad, audio y lenguaje
scrapedtitle = re.sub('\r\n', '', scrapedtitle).decode('iso-8859-1').encode('utf8').strip()
title = scrapedtitle
+ title = title.replace("á", "a").replace("é", "e").replace("í", "i").replace("ó", "o").replace("ú", "u").replace("ü", "u").replace("�", "ñ").replace("ñ", "ñ")
title_subs = ""
- item_local.language = ""
- if "[subs" in title or "[Subs" in title or "[VOS" in title or "[VOSE" in title or "(V.O.S.E" in title:
- item_local.language = "VOS"
- title = title.replace(" [Subs. integrados]", "").replace(" [subs. Integrados]", "").replace(" [VOSE", "").replace(" (V.O.S.E)", "")
- if "latino" in title or "Latino" in title or "rgentina" in title:
- item_local.language = "LAT"
+
+ #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():
+ item_local.language += ["VOS"]
+ title = title.replace(" [Subs. integrados]", "").replace(" [subs. Integrados]", "").replace(" [VOSE", "").replace(" [VOS", "").replace(" (V.O.S.E)", "").replace(" VO", "")
+ if "latino" in title.lower() or "argentina" in title.lower():
+ item_local.language += ["LAT"]
title = title.replace(" Latino", "").replace(" latino", "").replace(" Argentina", "").replace(" argentina", "")
title = title.replace("Castellano", "").replace("castellano", "").replace("inglés", "").replace("ingles", "").replace("Inglés", "").replace("Ingles", "")
@@ -552,11 +571,11 @@ def listado_busqueda(item):
title = re.sub(r'\[[a|A]udio.*?\]', '', title)
if "[Dual" in title or "[dual" in title:
title_subs = "[Dual]"
- title = title = re.sub(r'\[D|dual.*?\]', '', title)
+ title = title = re.sub(r'\[[D|d]ual.*?\]', '', title)
if title.endswith('.'):
title = title[:-1]
- title = title.replace("á", "a", 1).replace("é", "e", 1).replace("í", "i", 1).replace("ó", "o", 1).replace("ú", "u", 1).replace("ü", "u", 1)
+
if not title:
title = "dummy"
title = scrapertools.remove_htmltags(title)
@@ -655,16 +674,25 @@ def listado_busqueda(item):
item_local.infoLabels['year'] = ''
item_local.infoLabels['aired'] = ''
+ # Preparamos el título para series, con los núm. de temporadas, si las hay
+ if item_local.contentType == "season" or item_local.contentType == "tvshow":
+ item_local.contentTitle= ''
+
+ rating = ''
+ if item_local.infoLabels['rating'] and item_local.infoLabels['rating'] != '0.0':
+ rating = float(item_local.infoLabels['rating'])
+ rating = round(rating, 1)
+
# Ahora maquillamos un poco los titulos dependiendo de si se han seleccionado títulos inteleigentes o no
if not config.get_setting("unify"): #Si Titulos Inteligentes NO seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
if item_local.extra == "series" or temporada == "[Temp.]":
- title = '%s - Temporada %s [%s][%s][%s]' % (item_local.contentSerieName, str(item_local.contentSeason), scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), item_local.quality, item_local.language)
+ title = '%s - Temporada %s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.contentSerieName, str(item_local.contentSeason), scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
else:
- title = '%s [%s][%s][%s]' % (item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), item_local.quality, item_local.language)
+ title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'), rating, item_local.quality, str(item_local.language))
elif item_local.contentType == "movie":
- title = '%s [%s][%s][%s]' % (title, str(item_local.infoLabels['year']), item_local.quality, item_local.language)
+ title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language))
if config.get_setting("unify"): #Si Titulos Inteligentes SÍ seleccionados:
if item_local.contentType == "season" or item_local.contentType == "tvshow":
@@ -674,7 +702,9 @@ def listado_busqueda(item):
title = '%s -%s-' % (item_local.contentSerieName, scrapertools.find_single_match(str(item_local.infoLabels['aired']), r'\/(\d{4})'))
title_subs = title_subs.replace("[", "-").replace("]", "-")
- title = title.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "")
+ title = title.replace("--", "").replace(" []", "").replace("()", "").replace("(/)", "").replace("[/]", "")
+ title = re.sub(r'\s\[COLOR \w+\]\[\]\[\/COLOR\]', '', title)
+ title = re.sub(r'\s\[COLOR \w+\]\[\/COLOR\]', '', title)
item_local.title = title + title_subs
item_local.contentTitle += title_subs #añadimos info adicional para display
@@ -685,25 +715,26 @@ def listado_busqueda(item):
itemlist.append(
Item(channel=item.channel, action="listado_busqueda", title="[COLOR gold][B]Pagina siguiente >>[/B][/COLOR]", url=url_next_page, next_page=next_page, cnt_pag=cnt_pag, pag=pag, modo=modo, extra=item.extra, tipo=item.tipo))
- logger.debug(url_next_page + " / " + next_page + " / " + str(matches_cnt) + " / " + str(cnt_pag) + " / " + str(pag) + " / " + modo + " / " + item.extra + " / " + str(item.tipo))
+ #logger.debug(url_next_page + " / " + next_page + " / " + str(matches_cnt) + " / " + str(cnt_pag) + " / " + str(pag) + " / " + modo + " / " + item.extra + " / " + str(item.tipo))
return itemlist
def findvideos(item):
- #import xbmc
+ import xbmc
logger.info()
itemlist = []
# Saber si estamos en una ventana emergente lanzada desde una viñeta del menú principal,
# con la función "play_from_library"
- #unify_status = False
- #if xbmc.getCondVisibility('Window.IsMedia') == 1:
- # unify_status = config.get_setting("unify")
- unify_status = config.get_setting("unify")
+ unify_status = False
+ if xbmc.getCondVisibility('Window.IsMedia') == 1:
+ unify_status = config.get_setting("unify")
# Obtener la información actualizada del Episodio, si no la hay
- if not item.infoLabels['tmdb_id']:
+ 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)
if item.post: #Puede traer datos para una llamada "post". De momento usado para documentales, pero podrían ser series
@@ -720,74 +751,84 @@ def findvideos(item):
#logger.debug(matches)
for scrapedurl in matches:
+ #Generamos una copia de Item para trabajar sobre ella
+ item_local = item.clone()
url = urlparse.urljoin(item.url, scrapedurl)
# Localiza el .torrent en el siguiente link
if not item.post: # Si no es llamada con Post, hay que bajar un nivel más
torrent_data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(url).data)
#logger.debug(torrent_data)
- link = scrapertools.get_match(torrent_data, ">Pincha.*?Pincha.*?.*?)")
# Prepara el patrón de búsqueda de: URL, título, fechas y dos valores mas sin uso
- if item.extra == 'series':
+ if '/serie' in item.url:
patron = ".*?