diff --git a/channels/animesubita.json b/channels/animesubita.json index 89d78fc6..10d977f5 100644 --- a/channels/animesubita.json +++ b/channels/animesubita.json @@ -31,6 +31,38 @@ "default": true, "enabled": true, "visible": true + }, { + "id": "checklinks", + "type": "bool", + "label": "Verifica se i link esistono", + "default": false, + "enabled": true, + "visible": true + }, + { + "id": "checklinks_number", + "type": "list", + "label": "Numero de link da verificare", + "default": 1, + "enabled": true, + "visible": "eq(-1,true)", + "lvalues": [ "1", "3", "5", "10" ] + }, + { + "id": "autorenumber", + "type": "bool", + "label": "@70712", + "default": false, + "enabled": true, + "visible": true + }, + { + "id": "autorenumber_mode", + "type": "bool", + "label": "@70688", + "default": false, + "enabled": true, + "visible": "eq(-1,true)" } ] } diff --git a/channels/animesubita.py b/channels/animesubita.py index 93fc9f18..8e76d43a 100644 --- a/channels/animesubita.py +++ b/channels/animesubita.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -# Ringraziamo Icarus crew # ------------------------------------------------------------ -# Ringraziamo Icarus crew # Canale per AnimeSubIta # ------------------------------------------------------------ @@ -12,45 +10,25 @@ import urlparse from core import httptools, scrapertools, tmdb, support from core.item import Item from platformcode import logger, config +from core import support __channel__ = "animesubita" -host = config.get_channel_url(__channel__) -PERPAGE = 20 +host = support.config.get_channel_url(__channel__) +headers = {'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0'} -# ---------------------------------------------------------------------------------------------------------------- +list_servers = ['directo'] +list_quality = ['default'] + + +@support.menu def mainlist(item): - logger.info() - itemlist = [Item(channel=item.channel, - action="lista_anime_completa", - title=support.color("Lista Anime", "azure"), - url="%s/lista-anime/" % host, - 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="ultimiep", - title=support.color("Ultimi Episodi", "azure"), - url="%s/category/ultimi-episodi/" % host, - 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="lista_anime", - title=support.color("Anime in corso", "azure"), - url="%s/category/anime-in-corso/" % host, - 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=support.color("Categorie", "azure"), - url="%s/generi/" % host, - 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=support.color("Cerca anime ...", "yellow"), - extra="anime", - thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search") - ] + anime = ['/lista-anime/', + ('Ultimi Episodi',['/category/ultimi-episodi/', 'peliculas', 'updated']), + ('in Corso',['/category/anime-in-corso/', 'peliculas', 'alt']), + ('Generi',['/generi/', 'genres', 'alt'])] + return locals() - return itemlist -# ================================================================================================================ -# ---------------------------------------------------------------------------------------------------------------- def newest(categoria): logger.info() itemlist = [] @@ -58,8 +36,8 @@ def newest(categoria): try: if categoria == "anime": item.url = host - item.action = "ultimiep" - itemlist = ultimiep(item) + item.args = "updated" + itemlist = peliculas(item) if itemlist[-1].action == "ultimiep": itemlist.pop() @@ -72,13 +50,13 @@ def newest(categoria): return itemlist -# ================================================================================================================ -# ---------------------------------------------------------------------------------------------------------------- + def search(item, texto): logger.info() item.url = host + "/?s=" + texto + item.args = 'alt' try: - return lista_anime(item) + return peliculas(item) # Continua la ricerca in caso di errore except: import sys @@ -87,9 +65,13 @@ def search(item, texto): return [] -# ================================================================================================================ +@support.scrape +def genres(item): + blacklist= ['Anime In Corso','Ultimi Episodi'] + patronMenu=r'
  • (?P[^<]+)</a>' + action = 'peliculas' + return locals() -# ---------------------------------------------------------------------------------------------------------------- def categorie(item): logger.info() itemlist = [] @@ -110,234 +92,65 @@ def categorie(item): return itemlist -# ================================================================================================================ -# ---------------------------------------------------------------------------------------------------------------- -def ultimiep(item): - logger.info("ultimiep") - itemlist = lista_anime(item, False, False) - for itm in itemlist: - title = scrapertools.decodeHtmlentities(itm.title) - # Pulizia titolo - title = title.replace("Streaming", "").replace("&", "") - title = title.replace("Download", "") - title = title.replace("Sub Ita", "").strip() - eptype = scrapertools.find_single_match(title, "((?:Episodio?|OAV))") - cleantitle = re.sub(r'%s\s*\d*\s*(?:\(\d+\)|)' % eptype, '', title).strip() - # Creazione URL - url = re.sub(r'%s-?\d*-' % eptype.lower(), '', itm.url) - if "-streaming" not in url: - url = url.replace("sub-ita", "sub-ita-streaming") +@support.scrape +def peliculas(item): + anime = True + if item.args == 'updated': + patron = r'<div class="post-thumbnail">\s*<a href="(?P<url>[^"]+)" title="(?P<title>.*?)\s*(?P<episode>Episodio \d+)[^"]+"[^>]*>\s*<img[^src]+src="(?P<thumb>[^"]+)"' + patronNext = r'<link rel="next" href="([^"]+)"\s*/>' + action = 'findvideos' + elif item.args == 'alt': + # debug = True + patron = r'<div class="post-thumbnail">\s*<a href="(?P<url>[^"]+)" title="(?P<title>.*?)(?: [Oo][Aa][Vv])?(?:\s*(?P<lang>[Ss][Uu][Bb].[Ii][Tt][Aa]))[^"]+">\s*<img[^src]+src="(?P<thumb>[^"]+)"' + patronNext = r'<link rel="next" href="([^"]+)"\s*/>' + action = 'episodios' + else: + pagination = '' + patronBlock = r'<ul class="lcp_catlist"[^>]+>(?P<block>.*?)</ul>' + patron = r'<a href="(?P<url>[^"]+)"[^>]+>(?P<title>.*?)(?: [Oo][Aa][Vv])?(?:\s*(?P<lang>[Ss][Uu][Bb].[Ii][Tt][Aa])[^<]+)?</a>' + action = 'episodios' + return locals() - epnumber = "" - if 'episodio' in eptype.lower(): - epnumber = scrapertools.find_single_match(title.lower(), r'episodio?\s*(\d+)') - eptype += ":? " + epnumber - - extra = "<tr>\s*<td[^>]+><strong>(?:[^>]+>|)%s(?:[^>]+>[^>]+>|[^<]*|[^>]+>)</strong>" % eptype - itm.title = support.color(title, 'azure').strip() - itm.action = "findvideos" - itm.url = url - itm.fulltitle = cleantitle - itm.extra = extra - itm.show = re.sub(r'Episodio\s*', '', title) - itm.thumbnail = item.thumbnail - - tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) +@support.scrape +def episodios(item): + anime = True + patron = r'<td style="[^"]*?">\s*.*?<strong>(?P<episode>[^<]+)</strong>\s*</td>\s*<td[^>]+>\s*<a href="(?P<url>[^"]+)"[^>]+>\s*<img src="(?P<thumb>[^"]+?)"[^>]+>' + return locals() - return itemlist -# ================================================================================================================ - -# ---------------------------------------------------------------------------------------------------------------- -def lista_anime(item, nextpage=True, show_lang=True): - logger.info() +def findvideos(item): + support.log(item) itemlist = [] - data = httptools.downloadpage(item.url).data - blocco = scrapertools.find_single_match(data, r'<div class="post-list group">(.*?)</nav><!--/.pagination-->') - # patron = r'<a href="([^"]+)" title="([^"]+)">\s*<img[^s]+src="([^"]+)"[^>]+>' # Patron con thumbnail, Kodi non scarica le immagini dal sito - patron = r'<a href="([^"]+)" title="([^"]+)">' - matches = re.compile(patron, re.DOTALL).findall(blocco) + if item.args == 'updated': + ep = support.match(item.fulltitle,r'(Episodio\s*\d+)')[0][0] + item.url = support.re.sub(r'episodio-\d+-|oav-\d+-', '',item.url) + if 'streaming' not in item.url: item.url = item.url.replace('sub-ita','sub-ita-streaming') + item.url = support.match(item, r'<a href="([^"]+)"[^>]+>', ep + '(.*?)</tr>', )[0][0] - for scrapedurl, scrapedtitle in matches: - scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle) - scrapedtitle = re.sub(r'\s+', ' ', scrapedtitle) - # Pulizia titolo - scrapedtitle = scrapedtitle.replace("Streaming", "").replace("&", "") - scrapedtitle = scrapedtitle.replace("Download", "") - lang = scrapertools.find_single_match(scrapedtitle, r"([Ss][Uu][Bb]\s*[Ii][Tt][Aa])") - scrapedtitle = scrapedtitle.replace("Sub Ita", "").strip() - eptype = scrapertools.find_single_match(scrapedtitle, "((?:Episodio?|OAV))") - cleantitle = re.sub(r'%s\s*\d*\s*(?:\(\d+\)|)' % eptype, '', scrapedtitle) + urls = support.match(item.url, r'(episodio\d*.php.*)')[0] + for url in urls: + url = host + '/' + url + headers['Referer'] = url + data = support.match(item, headers=headers, url=url)[1] + cookies = "" + matches = support.re.compile('(.%s.*?)\n' % host.replace("http://", "").replace("www.", ""), re.DOTALL).findall(config.get_cookie_data()) + for cookie in matches: + cookies += cookie.split('\t')[5] + "=" + cookie.split('\t')[6] + ";" - - cleantitle = cleantitle.replace(lang, "").strip() - - itemlist.append( - Item(channel=item.channel, - action="episodi", - contentType="tvshow" if 'oav' not in scrapedtitle.lower() else "movie", - title=scrapedtitle.replace(lang, "(%s)" % support.color(lang, "red") if show_lang else "").strip(), - fulltitle=cleantitle, - url=scrapedurl, - show=cleantitle, - folder=True)) - - tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) - - if nextpage: - patronvideos = r'<link rel="next" href="([^"]+)"\s*/>' - matches = re.compile(patronvideos, re.DOTALL).findall(data) + headers['Cookie'] = cookies[:-1] - if len(matches) > 0: - scrapedurl = matches[0] - itemlist.append( - Item(channel=item.channel, - action="lista_anime", - title="[COLOR lightgreen]" + config.get_localized_string(30992) + "[/COLOR]", - url=scrapedurl, - thumbnail="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png", - folder=True)) - - return itemlist - -# ================================================================================================================ - -# ---------------------------------------------------------------------------------------------------------------- -def lista_anime_completa(item): - logger.info() - itemlist = [] - - p = 1 - if '{}' in item.url: - item.url, p = item.url.split('{}') - p = int(p) - - data = httptools.downloadpage(item.url).data - blocco = scrapertools.find_single_match(data, r'<ul class="lcp_catlist"[^>]+>(.*?)</ul>') - patron = r'<a href="([^"]+)"[^>]+>([^<]+)</a>' - matches = re.compile(patron, re.DOTALL).findall(blocco) - - for i, (scrapedurl, scrapedtitle) in enumerate(matches): - if (p - 1) * PERPAGE > i: continue - if i >= p * PERPAGE: break - - scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle.strip()) - cleantitle = scrapedtitle.replace("Sub Ita Streaming", "").replace("Ita Streaming", "") - + url = support.match(data, r'<source src="([^"]+)"[^>]+>')[0][0] + '|' + urllib.urlencode(headers) itemlist.append( Item(channel=item.channel, - action="episodi", - contentType="tvshow" if 'oav' not in scrapedtitle.lower() else "movie", - title=support.color(scrapedtitle, 'azure'), - fulltitle=cleantitle, - show=cleantitle, - url=scrapedurl, - folder=True)) - - tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) - - if len(matches) >= p * PERPAGE: - scrapedurl = item.url + '{}' + str(p + 1) - itemlist.append( - Item(channel=item.channel, - extra=item.extra, - action="lista_anime_completa", - title="[COLOR lightgreen]" + config.get_localized_string(30992) + "[/COLOR]", - url=scrapedurl, - thumbnail="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png", - folder=True)) - - return itemlist - -# ================================================================================================================ - -# ---------------------------------------------------------------------------------------------------------------- -def episodi(item): - logger.info() - itemlist = [] - - data = httptools.downloadpage(item.url).data - - patron = '<td style="[^"]*?">\s*.*?<strong>(.*?)</strong>.*?\s*</td>\s*<td style="[^"]*?">\s*<a href="([^"]+?)"[^>]+>\s*<img.*?src="([^"]+?)".*?/>\s*</a>\s*</td>' - matches = re.compile(patron, re.DOTALL).findall(data) - - for scrapedtitle, scrapedurl, scrapedimg in matches: - if 'nodownload' in scrapedimg or 'nostreaming' in scrapedimg: - continue - if 'vvvvid' in scrapedurl.lower(): - itemlist.append(Item(title='I Video VVVVID Non sono supportati')) - continue - - scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle) - scrapedtitle = re.sub(r'<[^>]*?>', '', scrapedtitle) - scrapedtitle = '[COLOR azure][B]' + scrapedtitle + '[/B][/COLOR]' - itemlist.append( - Item(channel=item.channel, - action="findvideos", - contentType="episode", - title=scrapedtitle, - url=urlparse.urljoin(host, scrapedurl), - fulltitle=item.title, - show=scrapedtitle, - plot=item.plot, - fanart=item.thumbnail, - thumbnail=item.thumbnail)) - - # Comandi di servizio - if config.get_videolibrary_support() and len(itemlist) != 0: - itemlist.append( - Item(channel=item.channel, - title="[COLOR lightblue]%s[/COLOR]" % config.get_localized_string(30161), - url=item.url, - action="add_serie_to_library", - extra="episodios", + action="play", + title='diretto', + quality='', + url=url, + server='directo', + fulltitle=item.fulltitle, show=item.show)) - return itemlist - -# ================================================================================================================ - -# ---------------------------------------------------------------------------------------------------------------- -def findvideos(item): - logger.info() - itemlist = [] - - headers = {'Upgrade-Insecure-Requests': '1', - 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0'} - - if item.extra: - data = httptools.downloadpage(item.url, headers=headers).data - blocco = scrapertools.find_single_match(data, r'%s(.*?)</tr>' % item.extra) - item.url = scrapertools.find_single_match(blocco, r'<a href="([^"]+)"[^>]+>') - - patron = r'http:\/\/link[^a]+animesubita[^o]+org\/[^\/]+\/.*?(episodio\d*)[^p]+php(\?.*)' - for phpfile, scrapedurl in re.findall(patron, item.url, re.DOTALL): - url = "%s/%s.php%s" % (host, phpfile, scrapedurl) - headers['Referer'] = url - data = httptools.downloadpage(url, headers=headers).data - # ------------------------------------------------ - cookies = "" - matches = re.compile('(.%s.*?)\n' % host.replace("http://", "").replace("www.", ""), re.DOTALL).findall(config.get_cookie_data()) - for cookie in matches: - name = cookie.split('\t')[5] - value = cookie.split('\t')[6] - cookies += name + "=" + value + ";" - headers['Cookie'] = cookies[:-1] - # ------------------------------------------------ - scrapedurl = scrapertools.find_single_match(data, r'<source src="([^"]+)"[^>]+>') - url = scrapedurl + '|' + urllib.urlencode(headers) - itemlist.append( - Item(channel=item.channel, - action="play", - text_color="azure", - title="[%s] %s" % (support.color("Diretto", "orange"), item.title), - fulltitle=item.fulltitle, - url=url, - thumbnail=item.thumbnail, - fanart=item.thumbnail, - plot=item.plot)) - - return itemlist + return support.server(item,url,itemlist) diff --git a/core/support.py b/core/support.py index 63f1c394..941e84da 100644 --- a/core/support.py +++ b/core/support.py @@ -731,9 +731,9 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''): # Simply add this function to add video library support # Function_level is useful if the function is called by another function. # If the call is direct, leave it blank - log(item) + log() - if item.contentType != 'episode': + if item.contentType == 'movie': action = 'add_pelicula_to_library' extra = 'findvideos' contentType = 'movie' @@ -742,8 +742,7 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''): extra = 'episodios' contentType = 'tvshow' - log('FUNCTION = ',function) - + function = function if function else inspect.stack()[function_level][3] if not typography: typography = 'color kod bold' @@ -751,8 +750,8 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''): contentSerieName=item.contentSerieName if item.contentSerieName else '' contentTitle=item.contentTitle if item.contentTitle else '' - if (inspect.stack()[function_level][3] == 'findvideos' and contentType == 'movie' \ - or inspect.stack()[function_level][3] != 'findvideos' and contentType != 'movie'): + if (function == 'findvideos' and contentType == 'movie') \ + or (function == 'episodios' and contentType != 'movie'): if config.get_videolibrary_support() and len(itemlist) > 0: itemlist.append( Item(channel=item.channel, diff --git a/resources/media/channels/banner/animesubita.png b/resources/media/channels/banner/animesubita.png new file mode 100644 index 00000000..b62bf2bf Binary files /dev/null and b/resources/media/channels/banner/animesubita.png differ diff --git a/resources/media/channels/thumb/animesubita.png b/resources/media/channels/thumb/animesubita.png new file mode 100644 index 00000000..63115262 Binary files /dev/null and b/resources/media/channels/thumb/animesubita.png differ