From fb4044b5b4358a6fc2fc3e62d60d4b6d7f8552d7 Mon Sep 17 00:00:00 2001 From: Intel1 <25161862+Intel11@users.noreply.github.com> Date: Sun, 1 Oct 2017 08:46:36 -0500 Subject: [PATCH] Add files via upload --- plugin.video.alfa/channels/zonatorrent.json | 24 ++++ plugin.video.alfa/channels/zonatorrent.py | 150 ++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 plugin.video.alfa/channels/zonatorrent.json create mode 100644 plugin.video.alfa/channels/zonatorrent.py diff --git a/plugin.video.alfa/channels/zonatorrent.json b/plugin.video.alfa/channels/zonatorrent.json new file mode 100644 index 00000000..f752dadf --- /dev/null +++ b/plugin.video.alfa/channels/zonatorrent.json @@ -0,0 +1,24 @@ +{ + "id": "zonatorrent", + "name": "ZonaTorrent", + "active": true, + "adult": false, + "language": ["cast", "lat"], + "banner": "", + "thumbnail": "https://zonatorrent.org/wp-content/uploads/2017/04/zonatorrent-New-Logo.png", + "version": 1, + "categories": [ + "torrent", + "movie" + ], + "settings": [ + { + "id": "include_in_global_search", + "type": "bool", + "label": "Incluir en busqueda global", + "default": true, + "enabled": true, + "visible": true + } + ] +} \ No newline at end of file diff --git a/plugin.video.alfa/channels/zonatorrent.py b/plugin.video.alfa/channels/zonatorrent.py new file mode 100644 index 00000000..2f410e90 --- /dev/null +++ b/plugin.video.alfa/channels/zonatorrent.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- + +import re + +from channelselector import get_thumb +from core import httptools +from core import scrapertools +from core import servertools +from core.item import Item +from platformcode import logger + +HOST = 'https://zonatorrent.org' + + +def mainlist(item): + logger.info() + + itemlist = list() + itemlist.append(Item(channel=item.channel, title="Últimas Películas", action="listado", url=HOST, page=False)) + itemlist.append(Item(channel=item.channel, title="Alfabético", action="alfabetico")) + itemlist.append(Item(channel=item.channel, title="Géneros", action="generos", url=HOST)) + itemlist.append(Item(channel=item.channel, title="Más vistas", action="listado", url=HOST + "/peliculas-mas-vistas/")) + itemlist.append(Item(channel=item.channel, title="Más votadas", action="listado", url=HOST + "/peliculas-mas-votadas/")) + itemlist.append(Item(channel=item.channel, title="Castellano", action="listado", url=HOST + "/?s=spanish", + page=True)) + itemlist.append(Item(channel=item.channel, title="Latino", action="listado", url=HOST + "/?s=latino", page=True)) + itemlist.append(Item(channel=item.channel, title="Subtitulado", action="listado", url=HOST + "/?s=Subtitulado", + page=True)) + itemlist.append(Item(channel=item.channel, title="Con Torrent", action="listado", url=HOST + "/?s=torrent", + page=True)) + itemlist.append(Item(channel=item.channel, title="Buscar", action="search", url=HOST + "/?s=", + page=False)) + + return itemlist + + +def alfabetico(item): + logger.info() + + itemlist = [] + + for letra in "#ABCDEFGHIJKLMNOPQRSTUVWXYZ": + itemlist.append(Item(channel=item.channel, action="listado", title=letra, page=True, + url=HOST + "/letters/%s/" % letra.replace("#", "0-9"))) + + return itemlist + + +def generos(item): + logger.info() + + itemlist = [] + + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + data = scrapertools.find_single_match(data, 'Generos(.*?)') + matches = scrapertools.find_multiple_matches(data, '(.*?)') + + for url, title in matches: + itemlist.append(Item(channel=item.channel, action="listado", title=title, url=url, page=True)) + + return itemlist + + +def search(item, texto): + logger.info() + item.url = item.url + texto.replace(" ", "+") + + try: + itemlist = listado(item) + except: + import sys + for line in sys.exc_info(): + logger.error("%s" % line) + return [] + + return itemlist + + +def listado(item): + logger.info() + + itemlist = [] + + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + + pattern = ']+>]+>]+src="(?P[^"]+)"[^>]+>' \ + '

(?P.*?)</h2>.*?<span class="Time[^>]+>(?P<duration>.*?)</span><span ' \ + 'class="Date[^>]+>(?P<year>.*?)</span><span class="Qlty">(?P<quality>.*?)</span></p><div ' \ + 'class="Description"><p>.*?\:\s*(?P<plot>.*?)</p>' + matches = re.compile(pattern, re.DOTALL).findall(data) + + for url, thumb, title, duration, year, quality, plot in matches: + title = title.strip().replace("Spanish Online Torrent", "").replace("Latino Online Torrent", "") + infoLabels = {"year": year} + + aux = scrapertools.find_single_match(duration, "(\d+)h\s*(\d+)m") + duration = "%s" % ((int(aux[0]) * 3600) + (int(aux[1]) * 60)) + infoLabels["duration"] = duration + + itemlist.append(Item(channel=item.channel, action="findvideos", title=title, url=url, thumbnail=thumb, + plot=plot, infoLabels=infoLabels)) + + if item.page: + pattern = "<span class='page-numbers current'>[^<]+</span><a class='page-numbers' href='([^']+)'" + url = scrapertools.find_single_match(data, pattern) + + itemlist.append(Item(channel=item.channel, action="listado", title=">> Página siguiente", url=url, page=True, + thumbnail=get_thumb("next.png"))) + + return itemlist + + +def findvideos(item): + logger.info() + + itemlist = [] + + data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(item.url).data) + data = re.sub(r""", '"', data) + data = re.sub(r"<", '<', data) + + titles = re.compile('data-TPlayerNv="Opt\d+">.*? <span>(.*?)</span></li>', re.DOTALL).findall(data) + urls = re.compile('id="Opt\d+"><iframe[^>]+src="([^"]+)"', re.DOTALL).findall(data) + + if len(titles) == len(urls): + for i in range(0, len(titles)): + if i > 0: + title = "Online %s " % titles[i].strip() + else: + title = titles[0] + + if "goo.gl" in urls[i]: + urls[i] = httptools.downloadpage(urls[i], follow_redirects=False, only_headers=True)\ + .headers.get("location", "") + videourl = servertools.findvideos(urls[i]) + if len(videourl) > 0: + itemlist.append(Item(channel=item.channel, action="play", title=title, url=videourl[0][1], + server=videourl[0][0], thumbnail=videourl[0][3], fulltitle=item.title)) + + pattern = '<a[^>]+href="([^"]+)"[^<]+</a></td><td><span><img[^>]+>(.*?)</span></td><td><span><img[^>]+>(.*?)' \ + '</span></td><td><span>(.*?)</span>' + torrents = re.compile(pattern, re.DOTALL).findall(data) + + if len(torrents) > 0: + for url, text, lang, quality in torrents: + title = "%s %s - %s" % (text, lang, quality) + itemlist.append(Item(channel=item.channel, action="play", title=title, url=url, server="torrent", + fulltitle=item.title, thumbnail=get_thumb("channels_torrent.png"))) + + return itemlist