From 1090a4b5d8a49e69fd14e1a541031a3a535068fa Mon Sep 17 00:00:00 2001 From: mac12m99 Date: Sun, 28 Apr 2019 14:02:27 +0200 Subject: [PATCH] ops, restored guardogratis --- channels/guardogratis.py | 221 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) diff --git a/channels/guardogratis.py b/channels/guardogratis.py index e69de29b..f5808ef4 100644 --- a/channels/guardogratis.py +++ b/channels/guardogratis.py @@ -0,0 +1,221 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------ +# Ringraziamo Icarus crew +# Canale per guardogratis +# +# ---------------------------------------------------------- +import re +import urlparse + +from core import httptools +from platformcode import logger, config +from core import scrapertools +from core import servertools +from core.item import Item +from core import tmdb + +__channel__ = "guardogratis" + +host = "https://guardogratis.it/" + +headers = [['Referer', host]] + +def mainlist(item): + logger.info("[guardogratis.py] mainlist") + + # Main options + itemlist = [Item(channel=item.channel, + action="list_titles", + title="[COLOR azure]Film[/COLOR]", + url="%s/movies/" % host, + extra="movie", + thumbnail="http://orig03.deviantart.net/6889/f/2014/079/7/b/movies_and_popcorn_folder_icon_by_matheusgrilo-d7ay4tw.png"), + Item(channel=item.channel, + action="list_titles", + title="[COLOR azure]Top Film[/COLOR]", + url="%s/top-imdb/" % host, + extra="movie", + thumbnail="http://orig03.deviantart.net/6889/f/2014/079/7/b/movies_and_popcorn_folder_icon_by_matheusgrilo-d7ay4tw.png"), + Item(channel=item.channel, + action="categorie", + title="[COLOR azure]Categorie[/COLOR]", + url="%s" % host, + extra="categorie", + thumbnail="http://orig03.deviantart.net/6889/f/2014/079/7/b/movies_and_popcorn_folder_icon_by_matheusgrilo-d7ay4tw.png"), + Item(channel=item.channel, + action="list_titles", + title="[COLOR azure]Serie Tv[/COLOR]", + url="%s/series/" % host, + extra="tvshow", + thumbnail="http://orig03.deviantart.net/6889/f/2014/079/7/b/movies_and_popcorn_folder_icon_by_matheusgrilo-d7ay4tw.png"), + Item(channel=item.channel, + action="search", + title="[COLOR yellow]Cerca Film[/COLOR]", + extra="movie", + thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search"), + Item(channel=item.channel, + action="search", + title="[COLOR yellow]Cerca SerieTV[/COLOR]", + extra="tvshow", + thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search")] + + return itemlist + +def list_titles(item): + logger.info("[guardogratis.py] list_titles") + itemlist = [] + + tipo='movie' + if 'tvshow' in item.extra: tipo='tv' + + if item.url == "": + item.url = host + # Carica la pagina + data = httptools.downloadpage(item.url, headers=headers).data + + patronvideos = '
([^<]+)<\/h2>.*?[I,T]MDb:\s*([^<]+)<\/div>' + + matches = re.compile(patronvideos, re.DOTALL).finditer(data) + + for match in matches: + scrapedurl = urlparse.urljoin(item.url, match.group(1)) + scrapedthumbnail = urlparse.urljoin(item.url, match.group(2)) + scrapedthumbnail = scrapedthumbnail.replace(" ", "%20") + rate=' IMDb: [[COLOR orange]%s[/COLOR]]' % match.group(4) if match.group(4)!='N/A'else '' + scrapedtitle = scrapertools.unescape(match.group(3)) + #scrapedtitle = scrapertools.unescape(match.group(3))+rate + itemlist.append( + Item(channel=item.channel, + action="findvideos" if not 'tvshow' in item.extra else 'serietv', + contentType="movie" if not 'tvshow' in item.extra else 'serie', + fulltitle=scrapedtitle, + show=scrapedtitle, + title=scrapedtitle, + url=scrapedurl, + thumbnail=scrapedthumbnail, + extra=item.extra, + viewmode="movie_with_plot")) + + nextpage_regex='' + if item.extra in "movies,tvshow": + nextpage_regex='' + elif item.extra=="categorie": + nextpage_regex='
  • .*?href=\'([^\']+)\'.*?
  • ' + + if nextpage_regex: + next_page = scrapertools.find_single_match(data, nextpage_regex) + if next_page != "": + itemlist.append( + Item(channel=item.channel, + action="list_titles", + title="[COLOR lightgreen]" + config.get_localized_string(30992) + "[/COLOR]", + url="%s" % next_page, + extra=item.extra, + thumbnail="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png")) + + tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) + return itemlist + +def search(item, texto): + logger.info("[guardogratis.py] search") + item.url = host + "/?s=" + texto + try: + if item.extra == "movie": + return list_titles(item) + if item.extra == "tvshow": + return list_titles(item) + # Continua la ricerca in caso di errore + except: + import sys + for line in sys.exc_info(): + logger.error("%s" % line) + return [] + +def categorie(item): + logger.info("[guardogratis.py] categorie") + itemlist = [] + + if item.url == "": + item.url = host + + # Carica la pagina + data = httptools.downloadpage(item.url, headers=headers).data + patronvideos = '