diff --git a/channels/animesaturn.json b/channels/animesaturn.json new file mode 100644 index 00000000..7c3b07b2 --- /dev/null +++ b/channels/animesaturn.json @@ -0,0 +1,70 @@ +{ + "id": "animesaturn", + "name": "AnimeSaturn", + "active": false, + "adult": false, + "language": ["ita"], + "thumbnail": "animesaturn.png", + "banner": "animesaturn.png", + "categories": ["anime"], + "settings": [ + { + "id": "channel_host", + "type": "text", + "label": "Host del canale", + "default": "https://www.animesaturn.com", + "enabled": true, + "visible": true + }, + { + "id": "include_in_global_search", + "type": "bool", + "label": "Includi ricerca globale", + "default": true, + "enabled": true, + "visible": true + }, + { + "id": "include_in_newest_anime", + "type": "bool", + "label": "Includi in Novità - Anime", + "default": true, + "enabled": true, + "visible": true + }, + { + "id": "include_in_newest_italiano", + "type": "bool", + "label": "Includi in Novità - Italiano", + "default": true, + "enabled": true, + "visible": true + }, + { + "id": "comprueba_enlaces", + "type": "bool", + "label": "Verifica se i link esistono", + "default": false, + "enabled": true, + "visible": true + }, + { + "id": "comprueba_enlaces_num", + "type": "list", + "label": "Numero de link da verificare", + "default": 1, + "enabled": true, + "visible": "eq(-1,true)", + "lvalues": [ "1", "3", "5", "10" ] + }, + { + "id": "filter_languages", + "type": "list", + "label": "Mostra link in lingua...", + "default": 0, + "enabled": true, + "visible": true, + "lvalues": ["Non filtrare","IT"] + } + ] +} diff --git a/channels/animesaturn.py b/channels/animesaturn.py new file mode 100644 index 00000000..c0a3d675 --- /dev/null +++ b/channels/animesaturn.py @@ -0,0 +1,432 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------ +# Canale per AnimeSaturn +# Thanks to me +# ---------------------------------------------------------- +import inspect +import re +import time +import urlparse + +import channelselector +from channels import autoplay, support, filtertools +from core import httptools, tmdb, scrapertools, servertools +from core.item import Item +from platformcode import logger, config +__channel__ = "animesaturn" +host = config.get_setting("channel_host", __channel__) +headers = [['Referer', host]] + +IDIOMAS = {'Italiano': 'IT'} +list_language = IDIOMAS.values() +list_servers = ['openload','fembed'] +list_quality = ['default'] + +# __comprueba_enlaces__ = config.get_setting('comprueba_enlaces', __channel__) +# __comprueba_enlaces_num__ = config.get_setting('comprueba_enlaces_num', __channel__) + + +def mainlist(item): + support.log(item.channel + 'mainlist') + itemlist = [] + support.menu(itemlist, 'Anime bold', 'lista_anime', "%s/animelist?load_all=1" % host,'anime') + # support.menu(itemlist, 'Novità submenu', 'ultimiep', "%s/fetch_pages.php?request=episodes" % host,'anime') + itemlist.append( + Item(channel=item.channel, + action="ultimiep", + url="%s/fetch_pages.php?request=episodes" % host, + title=support.typo("Novità submenu"), + extra="", + contentType='anime', + folder=True, + thumbnail=support.thumb()) + ) + # itemlist.append( + # Item(channel=item.channel, + # action="lista_anime", + # url="%s/animeincorso" % host, + # title=support.typo("In corso submenu"), + # extra="anime", + # contentType='anime', + # folder=True, + # thumbnail=channelselector.get_thumb('on_the_air.png')) + # ) + itemlist.append( + Item(channel=item.channel, + action="list_az", + url="%s/animelist?load_all=1" % host, + title=support.typo("Archivio A-Z submenu"), + extra="anime", + contentType='anime', + folder=True, + thumbnail=channelselector.get_thumb('channels_tvshow_az.png')) + ) + support.menu(itemlist, 'Cerca', 'search', host,'anime') + + + autoplay.init(item.channel, list_servers, list_quality) + autoplay.show_option(item.channel, itemlist) + + itemlist.append( + Item(channel='setting', + action="channel_config", + title=support.typo("Configurazione Canale color lime"), + config=item.channel, + folder=False, + thumbnail=channelselector.get_thumb('setting_0.png')) + ) + + return itemlist + + +# ---------------------------------------------------------------------------------------------------------------- +def cleantitle(scrapedtitle): + scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle.strip()) + scrapedtitle = scrapedtitle.replace('[HD]', '').replace('’', '\'').replace('×','x') + year = scrapertools.find_single_match(scrapedtitle, '\((\d{4})\)') + if year: + scrapedtitle = scrapedtitle.replace('(' + year + ')', '') + + return scrapedtitle.strip() + + +# ================================================================================================================ + +# ---------------------------------------------------------------------------------------------------------------- +def lista_anime(item): + support.log(item.channel + " lista_anime") + itemlist = [] + + PERPAGE = 15 + + p = 1 + if '{}' in item.url: + item.url, p = item.url.split('{}') + p = int(p) + + if '||' in item.url: + series = item.url.split('\n\n') + matches = [] + for i, serie in enumerate(series): + matches.append(serie.split('||')) + else: + # Carica la pagina + data = httptools.downloadpage(item.url).data + + # Estrae i contenuti + patron = r']*?>[^>]*?>(.+?)<' + matches = re.compile(patron, re.DOTALL).findall(data) + + + scrapedplot = "" + scrapedthumbnail = "" + for i, (scrapedurl, scrapedtitle) in enumerate(matches): + if (p - 1) * PERPAGE > i: continue + if i >= p * PERPAGE: break + title = cleantitle(scrapedtitle).replace('(ita)','(ITA)') + showtitle = title + if '(ITA)' in title: + title = title.replace('(ITA)','').strip() + showtitle = title + title += ' '+support.typo(' [ITA] color kod') + + infoLabels = {} + itemlist.append( + Item(channel=item.channel, + extra=item.extra, + action="episodios", + title=title, + url=scrapedurl, + thumbnail=scrapedthumbnail, + fulltitle=showtitle, + show=showtitle, + plot=scrapedplot, + contentType='episode', + originalUrl=scrapedurl, + infoLabels=infoLabels, + folder=True)) + + tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) + + # Paginazione + if len(matches) >= p * PERPAGE: + scrapedurl = item.url + '{}' + str(p + 1) + itemlist.append( + Item(channel=item.channel, + action='lista_anime', + contentType=item.contentType, + title=support.typo(config.get_localized_string(30992), 'color kod bold'), + url=scrapedurl, + args=item.args, + thumbnail=support.thumb())) + + return itemlist + + +# ================================================================================================================ + + +# ---------------------------------------------------------------------------------------------------------------- +def episodios(item): + support.log(item.channel + " episodios") + itemlist = [] + + data = httptools.downloadpage(item.url).data + + anime_id = scrapertools.find_single_match(data, r'\?anime_id=(\d+)') + + data = httptools.downloadpage( + host + "/loading_anime?anime_id=" + anime_id, + headers={ + 'X-Requested-With': 'XMLHttpRequest' + }).data + + patron = r'