From 4c3393249ddbee02ed671630f90ca03502c6c095 Mon Sep 17 00:00:00 2001
From: Kingbox <37674310+lopezvg@users.noreply.github.com>
Date: Fri, 4 May 2018 20:42:12 +0200
Subject: [PATCH 1/2] TmDB: Evita retorno de infoLabel incorrecto
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Despues de crear infoLabels para Series, pueden devolver esta información con películas
---
plugin.video.alfa/core/tmdb.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/plugin.video.alfa/core/tmdb.py b/plugin.video.alfa/core/tmdb.py
index a318cc7d..1ba25685 100755
--- a/plugin.video.alfa/core/tmdb.py
+++ b/plugin.video.alfa/core/tmdb.py
@@ -404,7 +404,8 @@ def set_infoLabels_item(item, seekTmdb=True, idioma_busqueda='es', lock=None):
otmdb = Tmdb(external_id=item.infoLabels['tvrage_id'], external_source="tvrage_id",
tipo=tipo_busqueda, idioma_busqueda=idioma_busqueda)
- if otmdb is None:
+ #if otmdb is None:
+ if not item.infoLabels['tmdb_id'] and not item.infoLabels['imdb_id'] and not item.infoLabels['tvdb_id'] and not item.infoLabels['freebase_mid'] and not item.infoLabels['freebase_id'] and not item.infoLabels['tvrage_id']:
# No se ha podido buscar por ID...
# hacerlo por titulo
if tipo_busqueda == 'tv':
From b20607c8ac07d303a0750f72cdc1c68a52f88983 Mon Sep 17 00:00:00 2001
From: Kingbox <37674310+lopezvg@users.noreply.github.com>
Date: Mon, 7 May 2018 19:05:50 +0200
Subject: [PATCH 2/2] =?UTF-8?q?Mejor=20Torrent:=20reestructuraci=C3=B3n=20?=
=?UTF-8?q?del=20canal?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Basado en la idea del canal Mejor Torrent anterior, se reestructura para añadirle más funcionalidad. Es una web difícil, algo inconsistente, que aporta pocos datos, pero tiene muy buenos contenidos:
- Listados de películas, series y documentales, calidad normal y el HD, con y sin lista alfabética
- Búsquedas de esos tres contenidos
- Listado de series, que suele dar episodios, convertidos a temporadas
- Videoteca para películas, series y documentales
- Uso extensivo de www.themoviedb.org para mayor información de los contenidos
- Gestión detallada de títulos
- Paginación en todas la funciones
---
plugin.video.alfa/channels/mejortorrent.json | 8 +
plugin.video.alfa/channels/mejortorrent.py | 1212 +++++++++++++-----
2 files changed, 885 insertions(+), 335 deletions(-)
diff --git a/plugin.video.alfa/channels/mejortorrent.json b/plugin.video.alfa/channels/mejortorrent.json
index a64f06e1..49621d31 100755
--- a/plugin.video.alfa/channels/mejortorrent.json
+++ b/plugin.video.alfa/channels/mejortorrent.json
@@ -28,6 +28,14 @@
"default": true,
"enabled": true,
"visible": true
+ },
+ {
+ "id": "include_in_newest_documentales",
+ "type": "bool",
+ "label": "Incluir en Novedades - Documentales",
+ "default": true,
+ "enabled": true,
+ "visible": true
}
]
}
\ No newline at end of file
diff --git a/plugin.video.alfa/channels/mejortorrent.py b/plugin.video.alfa/channels/mejortorrent.py
index c31662f6..424c122c 100755
--- a/plugin.video.alfa/channels/mejortorrent.py
+++ b/plugin.video.alfa/channels/mejortorrent.py
@@ -8,13 +8,13 @@ import urlparse
from channelselector import get_thumb
from core import httptools
from core import scrapertools
+from core import servertools
from core.item import Item
-from core.tmdb import Tmdb
-from platformcode import logger
+from platformcode import config, logger
+from core import tmdb
host = "http://www.mejortorrent.com"
-
def mainlist(item):
logger.info()
@@ -28,48 +28,889 @@ def mainlist(item):
thumb_docus = get_thumb("channels_documentary.png")
thumb_buscar = get_thumb("search.png")
- itemlist.append(Item(channel=item.channel, title="Peliculas", action="getlist",
+ itemlist.append(Item(channel=item.channel, title="Novedades", action="listado_busqueda", extra="novedades", tipo=False,
+ url= host + "/secciones.php?sec=ultimos_torrents", thumbnail=thumb_buscar))
+ itemlist.append(Item(channel=item.channel, title="Peliculas", action="listado", extra="peliculas", tipo=False,
url= host + "/torrents-de-peliculas.html", thumbnail=thumb_pelis))
- itemlist.append(Item(channel=item.channel, title="Peliculas HD", action="getlist",
+ itemlist.append(Item(channel=item.channel, title="Peliculas HD", action="listado", extra="peliculas", tipo=False,
url= host + "/torrents-de-peliculas-hd-alta-definicion.html",
thumbnail=thumb_pelis_hd))
- itemlist.append(Item(channel=item.channel, title="Series", action="getlist",
+ itemlist.append(Item(channel=item.channel, title="Películas Listado Alfabetico", action="alfabeto",
+ url= host + "/peliculas-buscador.html" +
+ "?campo=letra&valor&valor2=Acci%%F3n&valor3=%s&valor4=3&submit=Buscar", extra="peliculas",
+ thumbnail=thumb_pelis))
+ itemlist.append(Item(channel=item.channel, title="Series", action="listado", extra="series", tipo=False,
url= host + "/torrents-de-series.html", thumbnail=thumb_series))
- itemlist.append(Item(channel=item.channel, title="Series HD", action="getlist",
+ itemlist.append(Item(channel=item.channel, title="Series Listado Alfabetico", action="alfabeto", extra="series",
+ url= host + "/torrents-de-series.html", thumbnail=thumb_series_az))
+ itemlist.append(Item(channel=item.channel, title="Series HD", action="listado", extra="series", tipo=False,
url= host + "/torrents-de-series-hd-alta-definicion.html",
thumbnail=thumb_series_hd))
- itemlist.append(Item(channel=item.channel, title="Series Listado Alfabetico", action="listalfabetico",
- url= host + "/torrents-de-series.html", thumbnail=thumb_series_az))
- #itemlist.append(Item(channel=item.channel, title="Documentales", action="getlist",
- # url= host + "/torrents-de-documentales.html", thumbnail=thumb_docus))
- itemlist.append(Item(channel=item.channel, title="Buscar...", action="search", thumbnail=thumb_buscar))
+ itemlist.append(Item(channel=item.channel, title="Series HD Listado Alfabetico", action="alfabeto", extra="series-hd",
+ url= host + "/torrents-de-series-hd-alta-definicion.html", thumbnail=thumb_series_az))
+ itemlist.append(Item(channel=item.channel, title="Documentales", action="listado", extra="documentales", tipo=False,
+ url= host + "/torrents-de-documentales.html", thumbnail=thumb_docus))
+ itemlist.append(Item(channel=item.channel, title="Documentales Listado Alfabetico", action="alfabeto", extra="documentales", url= host + "/torrents-de-documentales.html", thumbnail=thumb_docus))
+ itemlist.append(Item(channel=item.channel, title="Buscar...", action="search", thumbnail=thumb_buscar, tipo=False))
return itemlist
-def listalfabetico(item):
+def alfabeto(item):
logger.info()
-
itemlist = []
- for letra in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
- 'U', 'V', 'W', 'X', 'Y', 'Z']:
- itemlist.append(Item(channel=item.channel, action="getlist", title=letra,
- url= host + "/series-letra-" + letra.lower() + ".html"))
+ if item.extra == "series-hd":
+ itemlist.append(Item(channel=item.channel, action="listado", title="Todas", extra="series", tipo=True,
+ url= host + "/secciones.php?sec=descargas&ap=series_hd&func=mostrar&letra=."))
+ for letra in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']:
+ itemlist.append(Item(channel=item.channel, action="listado", title=letra, extra="series", tipo=True,
+ url= host + "/secciones.php?sec=descargas&ap=series_hd&func=mostrar&letra=" + letra.lower()))
- itemlist.append(Item(channel=item.channel, action="getlist", title="Todas",
- url= host + "/series-letra..html"))
+ elif item.extra == "series" or item.extra == "documentales":
+ itemlist.append(Item(channel=item.channel, action="listado", title="Todas", extra=item.extra, tipo=True, url= host + "/" + item.extra + "-letra-..html"))
+ for letra in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']:
+ itemlist.append(Item(channel=item.channel, action="listado", title=letra, extra=item.extra, tipo=True, url= host + "/" + item.extra + "-letra-" + letra.lower() + ".html"))
+
+ elif item.extra == "peliculas":
+ itemlist.append(Item(channel=item.channel, action="listado", title="Todas", extra=item.extra, tipo=True, url=item.url % "."))
+ for letra in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']:
+ itemlist.append(Item(channel=item.channel, action="listado", title=letra, extra=item.extra, tipo=True, url=item.url % letra.lower()))
return itemlist
+def listado(item):
+ logger.info()
+ itemlist = []
+ url_next_page ='' # Controlde paginación
+ cnt_tot = 30 # Poner el num. máximo de items por página
+
+ if item.category:
+ del item.category
+ if item.totalItems:
+ del item.totalItems
+
+ # La url de Películas por orden Alfabético tiene un formato distinto
+ if item.extra == "peliculas" and item.tipo:
+ url = item.url.split("?")
+ data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(url[0], post=url[1]).data)
+ else:
+ data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data)
+
+ # En este canal las url's y los títulos tienen diferente formato dependiendo del contenido
+ if item.extra == "peliculas" and item.tipo: #Desde Lista Alfabética
+ patron = "'
+ patron_enlace = "/peli-descargar-torrent-\d+-(.*?)\.html"
+ patron_title = '([^<]+)(\s*([^>]+))?'
+ item.action = "findvideos"
+ item.contentType = "movie"
+ pag = True #Sí hay paginación
+ elif item.extra == "series" and item.tipo:
+ patron = "()"
+ patron_enlace = "\/serie-descargar-torrent*.-\d+-?\d+-(.*?)\.html"
+ patron_title = "([^<]+)<\/a>(\s*([^>]+)<\/b>)?"
+ patron_title_ep = "\/serie-descargar-torrent*.-\d+-?\d+-(.*?)-\d+x\d+.*?\.html"
+ patron_title_se = "\/serie-descargar-torrent*.-\d+-?\d+-(.*?)-\d+-Temp.*?\.html"
+ item.action = "episodios"
+ item.contentType = "season"
+ pag = False
+ elif item.extra == "series" and not item.tipo:
+ patron = '?'
+ patron += ''
+ patron_enlace = "\/serie-[^a_z]{0,10}descargar-torrent*.-\d+-?\d+-(.*?)\.html"
+ patron_title = '([^<]+)(\s*([^>]+))?'
+ patron_title_ep = "\/serie-[^a_z]{0,10}descargar-torrent*.-\d+-?\d+-(.*?)-\d+x\d+.*?\.html"
+ patron_title_se = "\/serie-[^a_z]{0,10}descargar-torrent*.-\d+-?\d+-(.*?)-\d+-Temp.*?\.html"
+ item.action = "episodios"
+ item.contentType = "season"
+ pag = True
+ cnt_tot = 10 # Se reduce el numero de items por página porque es un proceso pesado
+ elif item.extra == "documentales" and item.tipo:
+ patron = "()"
+ patron_enlace = "\/doc-descargar-torrent*.-\d+-?\d+-(.*?)\.html"
+ patron_title = "([^<]+)<\/a>(\s*([^>]+)<\/b>)?"
+ patron_title_ep = "\/doc-descargar-torrent*.-\d+-?\d+-(.*?)-\d+x\d+.*?\.html"
+ patron_title_se = "\/doc-descargar-torrent*.-\d+-?\d+-(.*?)-\d+-Temp.*?\.html"
+ item.action = "episodios"
+ item.contentType = "tvshow"
+ pag = False
+ else:
+ patron = '?'
+ patron += '
'
+ patron_enlace = "/doc-descargar-torrent-\d+-\d+-(.*?)\.html"
+ patron_title = '([^<]+)(\s*([^>]+))?'
+ patron_title_ep = "\/doc-descargar-torrent*.-\d+-?\d+-(.*?)-\d+x\d+.*?\.html"
+ patron_title_se = "\/doc-descargar-torrent*.-\d+-?\d+-(.*?)-\d+-Temp.*?\.html"
+ item.action = "episodios"
+ item.contentType = "tvshow"
+ pag = True
+ item.next_page = 'b'
+
+ # Preparamos la paginación. Las páginas alfabéticas no tienen paginación.
+ # El resto sí, pero con un número variable de links
+ if not item.cnt_pag:
+ cnt_pag = 0
+ else:
+ cnt_pag = item.cnt_pag
+ del item.cnt_pag
+
+ matches = re.compile(patron, re.DOTALL).findall(data)
+
+ matches_cnt = len(matches)
+ if matches_cnt > cnt_tot and item.extra == "documentales" and pag:
+ item.next_page = ''
+ if item.next_page != 'b':
+ if matches_cnt > cnt_pag + cnt_tot:
+ url_next_page = item.url
+ matches = matches[cnt_pag:cnt_pag+cnt_tot]
+ next_page = ''
+ if matches_cnt <= cnt_pag + (cnt_tot * 2):
+ if pag:
+ next_page = 'b'
+ modo = 'continue'
+ else:
+ matches = matches[cnt_pag:cnt_pag+cnt_tot]
+ next_page = 'a'
+ patron_next_page = " Siguiente >> <\/a>"
+ matches_next_page = re.compile(patron_next_page, re.DOTALL).findall(data)
+ modo = 'continue'
+ if len(matches_next_page) > 0:
+ url_next_page = urlparse.urljoin(item.url, matches_next_page[0])
+ modo = 'next'
+ if item.next_page:
+ del item.next_page
+
+ #logger.debug(data)
+ #logger.debug("PATRON1: " + patron + " / ")
+ #logger.debug(matches)
+
+ # Primera pasada
+ # En la primera pasada se obtiene una información básica del título a partir de la url
+ # Para Series se obtienen la temporada y el episodio
+ # Se limpian algunas etiquetas del item inical.
+ for scrapedurl, scrapedthumbnail in matches:
+ item_local = item.clone()
+ if item_local.tipo:
+ del item_local.tipo
+ if item_local.totalItems:
+ del item_local.totalItems
+ item_local.title = ''
+ item_local.context = "['buscar_trailer']"
+
+ item_local.title = scrapertools.get_match(scrapedurl, patron_enlace)
+ item_local.title = item_local.title.replace("-", " ")
+ item_local.url = urlparse.urljoin(item_local.url, scrapedurl)
+ item_local.thumbnail = host + urllib.quote(scrapedthumbnail)
+ item_local.contentThumbnail = item_local.thumbnail
+ item_local.infoLabels['year'] = '-' # Al no saber el año, le ponemos "-" y TmDB lo calcula automáticamente
+
+ # Para que el menú contextual muestre conrrectamente las opciones de añadir a Videoteca
+ if item_local.extra == "series":
+ if "/serie-episodio" in item_local.url:
+ item_local.contentType = "episode"
+ else:
+ item_local.contentType = "season"
+
+ # Poner nombre real de serie. Busca nº de temporada y capítulo
+ if item_local.extra == "series" or item.extra == "documentales":
+ if item_local.contentType == "episode":
+ real_title = scrapertools.find_single_match(scrapedurl, patron_title_ep)
+ real_title = real_title.replace("-", " ")
+ item_local.contentSeason = scrapertools.find_single_match(scrapedurl, '.*?-(\d{1,2})x\d{1,2}.*?\.html')
+
+ #Hay que buscar la raiz de la temporada
+ data_epi = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item_local.url).data)
+ url = scrapertools.find_single_match(data_epi, r"([^']+)<\/span>"
+ patron_enlace = "\/serie-descargar-torrents-\d+-\d+-(.*?)\.html"
+ matches = scrapertools.find_multiple_matches(data, patron)
+
+ # busca pelis y Novedades
+ patron = "]+>(.*?)<\/a>"
+ patron += ".*?([^']+)<\/a>"
+ matches += re.compile(patron, re.DOTALL).findall(data) #Busquedas
+ patron = "]+>(.*?)<\/a>"
+ patron += ".*?([^']+)<\/span>"
+ patron_enlace = "\/peli-descargar-torrent-\d+(.*?)\.html"
+ matches += re.compile(patron, re.DOTALL).findall(data) #Novedades
+
+ # busca docu
+ patron = "(.*?)<\/a>.*?"
+ patron += "