diff --git a/plugin.video.alfa/channels/yts.json b/plugin.video.alfa/channels/yts.json new file mode 100644 index 00000000..c3a13cb6 --- /dev/null +++ b/plugin.video.alfa/channels/yts.json @@ -0,0 +1,23 @@ +{ + "id": "yts", + "name": "Yts", + "active": true, + "adult": false, + "language": ["*"], + "thumbnail": "yts.jpg", + "categories": [ + "movie", + "torrent", + "vos" + ], + "settings":[ + { + "id": "include_in_global_search", + "type": "bool", + "label": "Incluir en busqueda global", + "default": false, + "enabled": true, + "visible": true + } + ] +} \ No newline at end of file diff --git a/plugin.video.alfa/channels/yts.py b/plugin.video.alfa/channels/yts.py new file mode 100644 index 00000000..183629ff --- /dev/null +++ b/plugin.video.alfa/channels/yts.py @@ -0,0 +1,123 @@ +# -*- coding: utf-8 -*- + +from core import httptools +from core import scrapertools +from core import servertools +from core import tmdb +from core.item import Item +from lib import generictools +from platformcode import logger + +def mainlist(item): + logger.info() + itemlist = [] + itemlist.append(Item(channel = item.channel, + title = "Browse", + action = "movies", + opt = 0, + url = "https://yts.am/browse-movies" + )) + + itemlist.append(Item(channel = item.channel, + title = "Popular", + action = "movies", + opt = 1, + url = "https://yts.am" )) + + itemlist.append(Item(channel = item.channel, + title = "Search", + action = "search", + opt = 0, + url = "https://yts.am/browse-movies" + )) + + return itemlist + +def movies(item): + logger.info() + itemlist = [] + infoLabels = {} + data = httptools.downloadpage(item.url).data + + patron = '(?s)class="browse-movie-wrap.*?a href="([^"]+).*?' #Movie link + patron += 'img class.*?src="([^"]+).*?' #Image + patron += 'movie-title">.*?([^<]+)' #Movie title + patron += '.*?year">(.*?)<' #Year + + matches = scrapertools.find_multiple_matches(data, patron) + idx = 0 + + for scrapedurl, scrapedthumbnail, scrapedtitle, year in matches: + if item.opt == 1: + scrapedthumbnail = 'https://yts.am' + scrapedthumbnail + infoLabels['plot'] = findplot(scrapedurl) + + itemlist.append(Item(action = "findvideo", + channel = item.channel, + infoLabels = infoLabels, + title = scrapedtitle + ' (' + year + ')', + thumbnail = scrapedthumbnail, + url = scrapedurl + )) + idx += 1 + if item.opt == 1 and idx == 4: + break + if itemlist != []: + actual_page = item.url + pattern = '(?s)href="([^"]+)">Next.*?' + next_page = scrapertools.find_single_match(data, pattern) + + if next_page != '': + itemlist.append(Item(channel=item.channel, + action="movies", + title='Next >>>', + url='https://yts.am' + next_page)) + + return itemlist + +def findplot(url): + data = httptools.downloadpage(url).data + + pattern = '(?s)
(.*?)
' #Synopsis + + plot = scrapertools.find_single_match(data, pattern) + + return plot + +def findvideo(item): + itemlist = [] + data = httptools.downloadpage(item.url).data + + patron = '(?s)modal-quality.*?(.*?)' #Quality + patron += '.*?size">(.*?)' #Type + patron += '.*?href="([^"]+)" rel' #Torrent link + + matches = scrapertools.find_multiple_matches(data, patron) + + for quality, videoType, link in matches: + + title = item.title + ' ' + quality + ' ' + videoType + itemlist.append(Item(channel = item.channel, + title=title, + url = link, + thumbnail = item.thumbnail, + action='play', + server='torrent' + )) + + return itemlist + +def search(item, text): + logger.info('search: ' + text) + + try: + item.url = 'https://yts.am/browse-movies/' + text + '/all/all/0/latest' + itemlist = movies(item) + + return itemlist + + except: + import sys + for line in sys.exc_info(): + logger.error("%s" % line) + return [] \ No newline at end of file diff --git a/plugin.video.alfa/resources/media/channels/thumb/yts.jpg b/plugin.video.alfa/resources/media/channels/thumb/yts.jpg new file mode 100644 index 00000000..6804b34a Binary files /dev/null and b/plugin.video.alfa/resources/media/channels/thumb/yts.jpg differ