From 4bc29f1a50d87f1c152ea60c23dc58753145f258 Mon Sep 17 00:00:00 2001 From: Alfa Addon Date: Tue, 29 Aug 2017 18:06:04 -0400 Subject: [PATCH] fixed --- plugin.video.alfa/channels/pelismagnet.py | 129 ++++++++++++++-------- 1 file changed, 81 insertions(+), 48 deletions(-) mode change 100755 => 100644 plugin.video.alfa/channels/pelismagnet.py diff --git a/plugin.video.alfa/channels/pelismagnet.py b/plugin.video.alfa/channels/pelismagnet.py old mode 100755 new mode 100644 index ecb61647..891fd535 --- a/plugin.video.alfa/channels/pelismagnet.py +++ b/plugin.video.alfa/channels/pelismagnet.py @@ -84,7 +84,7 @@ def menu_genero(item): itemlist = [] - response = httptools.downloadpage("https://kproxy.com/") + httptools.downloadpage("https://kproxy.com/") url = "https://kproxy.com/doproxy.jsp" post = "page=%s&x=34&y=14" % urllib.quote(host + "/principal") response = httptools.downloadpage(url, post, follow_redirects=False).data @@ -108,7 +108,7 @@ def series(item): logger.info() itemlist = [] - response = httptools.downloadpage("https://kproxy.com/") + httptools.downloadpage("https://kproxy.com/") url = "https://kproxy.com/doproxy.jsp" post = "page=%s&x=34&y=14" % urllib.quote(item.url) response = httptools.downloadpage(url, post, follow_redirects=False).data @@ -126,17 +126,17 @@ def series(item): punt = i.get("puntuacio", "") valoracion = "" if punt and not 0: - valoracion = " (Val: {punt})".format(punt=punt) + valoracion = " (Val: %s)" % punt - title = "{nombre}{val}".format(nombre=i.get("nom", ""), val=valoracion) - url = "{url}?id={id}".format(url=api_temp, id=i.get("id", "")) + title = "%s%s" % (i.get("nom", ""), valoracion) + url = "%s?id=%s" % (api_temp, i.get("id", "")) thumbnail = "" fanart = "" if i.get("posterurl", ""): - thumbnail = "http://image.tmdb.org/t/p/w342{file}".format(file=i.get("posterurl", "")) + thumbnail = "http://image.tmdb.org/t/p/w342%s" % i.get("posterurl", "") if i.get("backurl", ""): - fanart = "http://image.tmdb.org/t/p/w1280{file}".format(file=i.get("backurl", "")) + fanart = "http://image.tmdb.org/t/p/w1280%s" % i.get("backurl", "") plot = i.get("info", "") if plot is None: @@ -165,7 +165,7 @@ def episodios(item): logger.info() itemlist = [] - response = httptools.downloadpage("https://kproxy.com/") + httptools.downloadpage("https://kproxy.com/") url = "https://kproxy.com/doproxy.jsp" post = "page=%s&x=34&y=14" % urllib.quote(item.url) response = httptools.downloadpage(url, post, follow_redirects=False).data @@ -173,48 +173,61 @@ def episodios(item): data = httptools.downloadpage(url).data data = jsontools.load(data) - for i in data.get("temporadas", []): - titulo = "{temporada} ({total} Episodios)".format(temporada=i.get("nomtemporada", ""), - total=len(i.get("capituls", "0"))) - itemlist.append(Item(channel=item.channel, action="episodios", title=titulo, url=item.url, - server="torrent", fanart=item.fanart, thumbnail=item.thumbnail, plot=data.get("info", ""), - folder=False)) + dict_episodes = dict() + + for i in data.get("temporadas", []): for j in i.get("capituls", []): - numero = j.get("infocapitul", "") - if not numero: - numero = "{temp}x{cap}".format(temp=i.get("numerotemporada", ""), cap=j.get("numerocapitul", "")) + numero = j.get("infocapitul", "%sx%s" % (i.get("numerotemporada", 0), j.get("numerocapitul", 0))) - titulo = j.get("nomcapitul", "") - if not titulo: - titulo = "CapĂ­tulo {num}".format(num=j.get("numerocapitul", "")) + if numero not in dict_episodes: + dict_episodes[numero] = {} + dict_episodes[numero]["title"] = j.get("nomcapitul", "Episodio %s" % j.get("numerocapitul", "")) - calidad = "" - if j.get("links", {}).get("calitat", ""): - calidad = " [{calidad}]".format(calidad=j.get("links", {}).get("calitat", "")) + season = i.get("numerotemporada", 0) + if type(season) == str: + season = 0 + dict_episodes[numero]["season"] = season - title = " {numero} {titulo}{calidad}".format(numero=numero, titulo=titulo, calidad=calidad) + episode = j.get("numerocapitul", 0) + if type(episode) == str: + episode = 0 + dict_episodes[numero]["episode"] = episode + + if j.get("links", {}).get("magnet"): + dict_episodes[numero]["url"] = [j.get("links", {}).get("magnet")] + dict_episodes[numero]["quality"] = [j.get("links", {}).get("calitat", "")] + + dict_episodes[numero]["plot"] = j.get("overviewcapitul", "") - if j.get("links", {}).get("magnet", ""): - url = j.get("links", {}).get("magnet", "") else: - return [Item(channel=item.channel, title='No hay enlace magnet disponible para este capitulo')] + if dict_episodes[numero]["title"] == "": + dict_episodes[numero]["title"] = j.get("nomcapitul", "Episodio %s" % j.get("numerocapitul", "")) - plot = i.get("overviewcapitul", "") - if plot is None: - plot = "" + if j.get("links", {}).get("magnet"): + dict_episodes[numero]["url"].append(j.get("links", {}).get("magnet")) + dict_episodes[numero]["quality"].append(j.get("links", {}).get("calitat", "")) - infoLabels = item.infoLabels - if plot: - infoLabels["plot"] = plot - infoLabels["season"] = i.get("numerotemporada") - infoLabels["episode"] = j.get("numerocapitul") - itemlist.append( - Item(channel=item.channel, action="play", title=title, url=url, server="torrent", infoLabels=infoLabels, - thumbnail=item.thumbnail, fanart=item.fanart, show=item.show, contentTitle=item.contentTitle, - contentSeason=i.get("numerotemporada"), contentEpisodeNumber=j.get("numerocapitul"))) + if dict_episodes[numero]["plot"] == "": + dict_episodes[numero]["plot"] = j.get("overviewcapitul", "") + + # logger.debug("\n\n\n dict_episodes: %s " % dict_episodes) + + for key, value in dict_episodes.items(): + list_no_duplicate = list(set(value["quality"])) + title = "%s %s [%s]" % (key, value["title"], "][".join(list_no_duplicate)) + + itemlist.append( + Item(channel=item.channel, action="findvideos", title=title, url=url, server="torrent", + thumbnail=item.thumbnail, fanart=item.fanart, show=item.show, data=value, + contentTitle=item.contentTitle, contentSeason=value["season"], + contentEpisodeNumber=value["episode"])) + + # order list + if len(itemlist) > 1: + itemlist = sorted(itemlist, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) return itemlist @@ -224,7 +237,7 @@ def pelis(item): itemlist = [] - response = httptools.downloadpage("https://kproxy.com/") + httptools.downloadpage("https://kproxy.com/") url = "https://kproxy.com/doproxy.jsp" post = "page=%s&x=34&y=14" % urllib.quote(item.url) response = httptools.downloadpage(url, post, follow_redirects=False).data @@ -242,34 +255,35 @@ def pelis(item): valoracion = "" if punt and not 0: - valoracion = " (Val: {punt})".format(punt=punt) + valoracion = " (Val: %s)" % punt if i.get("magnets", {}).get("M1080", {}).get("magnet", ""): url = i.get("magnets", {}).get("M1080", {}).get("magnet", "") - calidad = "[{calidad}]".format(calidad=i.get("magnets", {}).get("M1080", {}).get("quality", "")) + calidad = "[%s]" % i.get("magnets", {}).get("M1080", {}).get("quality", "") else: url = i.get("magnets", {}).get("M720", {}).get("magnet", "") - calidad = "[{calidad}]".format(calidad=i.get("magnets", {}).get("M720", {}).get("quality", "")) + calidad = "[%s]" % (i.get("magnets", {}).get("M720", {}).get("quality", "")) if not url: continue - title = "{nombre} {calidad}{val}".format(nombre=i.get("nom", ""), val=valoracion, calidad=calidad) + title = "%s %s%s" % (i.get("nom", ""), valoracion, calidad) thumbnail = "" fanart = "" if i.get("posterurl", ""): - thumbnail = "http://image.tmdb.org/t/p/w342{file}".format(file=i.get("posterurl", "")) + thumbnail = "http://image.tmdb.org/t/p/w342%s" % i.get("posterurl", "") if i.get("backurl", ""): - fanart = "http://image.tmdb.org/t/p/w1280{file}".format(file=i.get("backurl", "")) + fanart = "http://image.tmdb.org/t/p/w1280%s" % i.get("backurl", "") plot = i.get("info", "") if plot is None: plot = "" infoLabels = {'plot': plot, 'year': i.get("year"), 'tmdb_id': i.get("id")} - itemlist.append(Item(channel=item.channel, action="play", title=title, url=url, server="torrent", - thumbnail=thumbnail, fanart=fanart, infoLabels=infoLabels, contentTitle=i.get("nom"))) + itemlist.append(Item(channel=item.channel, action="findvideos", title=title, url=url, server="torrent", + contentType="movie", thumbnail=thumbnail, fanart=fanart, infoLabels=infoLabels, + contentTitle=i.get("nom"))) from core import tmdb tmdb.set_infoLabels_itemlist(itemlist, __modo_grafico__) @@ -298,3 +312,22 @@ def search(item, texto): for line in sys.exc_info(): logger.error("%s" % line) return [] + + +def findvideos(item): + logger.info() + + itemlist = [] + + if item.contentType == "movie": + item.title = "Enlace Torrent" + item.action = "play" + itemlist.append(item) + else: + data = item.data + + for index, url in enumerate(data["url"]): + title = "Enlace torrent [%s]" % data["quality"][index] + itemlist.append(item.clone(action="play", title=title, url=url)) + + return itemlist