From 48996688a62dd76456ad761c8d31a4b4abf6c5f4 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Sat, 23 Oct 2021 10:51:56 +0200 Subject: [PATCH] Riscritto News e fix vari --- channels.json | 2 +- channels/altadefinizionecommunity.py | 327 ++++++++++++++------------- channels/animeunity.py | 113 +++++---- channels/aniplay.py | 37 +-- channels/streamingcommunity.json | 12 +- channels/streamingcommunity.py | 88 +++---- channels/vvvvid.py | 18 +- core/support.py | 10 +- platformcode/launcher.py | 3 +- platformcode/platformtools.py | 127 ++++++----- specials/news.py | 51 +++-- 11 files changed, 433 insertions(+), 355 deletions(-) diff --git a/channels.json b/channels.json index fe68161b..25631448 100644 --- a/channels.json +++ b/channels.json @@ -6,7 +6,7 @@ "animeforce": "https://www.animeforce.it", "animeleggendari": "https://animezeus.com", "animesaturn": "https://www.animesaturn.it", - "animeunity": "https://www.animeunity.it", + "animeunity": "https://www.animeunity.tv", "animeuniverse": "https://www.animeuniverse.it", "animeworld": "https://www.animeworld.tv", "aniplay": "https://aniplay.it", diff --git a/channels/altadefinizionecommunity.py b/channels/altadefinizionecommunity.py index 8fd35be2..1630aaf1 100644 --- a/channels/altadefinizionecommunity.py +++ b/channels/altadefinizionecommunity.py @@ -2,47 +2,190 @@ # ------------------------------------------------------------ # Canale per Altadefinizione Community -from core import jsontools, support +from core import support from lib.fakeMail import Gmailnator from platformcode import config, platformtools, logger from core import scrapertools, httptools def findhost(url): - global register_url - register_url = url return support.match(url, patron=r'Accedi').match host = config.get_channel_url(findhost) -# register_url = 'https://altaregistrazione.com' -headers = {'Referer': host, 'x-requested-with': 'XMLHttpRequest'} +register_url = 'https://altaregistrazione.net' + +if 'altadefinizionecommunity' not in host: + config.get_channel_url(findhost, forceFindhost=True) + +if host.endswith('/'): + host = host[:-1] + +headers = {'Referer': host} +order = ['', 'i_piu_visti', 'i_piu_votati', 'i_piu_votati_dellultimo_mese', 'titolo_az', 'voto_imdb_piu_alto'][config.get_setting('order', 'altadefinizionecommunity')] @support.menu def mainlist(item): logger.debug(item) - film = ['/load-more-film?anno=&order=&support_webp=1&type=movie&page=1', - # Voce Menu,['url','action','args',contentType] - ('Generi Film', ['', 'genres', 'genres']), - ] + film = ['/type/movie', + ('Generi', ['/type/movie', 'genres', 'genres']), + ('Anni', ['/type/movie', 'genres', 'year']),] - tvshow = ['/load-more-film?type=tvshow&anno=&order=&support_webp=1&page=1', - # Voce Menu,['url','action','args',contentType] - ('Generi Serie TV', ['', 'genres', 'genres']), - ] - - altri = [ - # ('A-Z', ['/lista-film', 'genres', 'letters']), - ('Qualità', ['', 'genres', 'quality']), - ('Anni', ['/anno', 'genres', 'years']) - ] - search = '' + tvshow = ['/serie-tv/tvshow', + ('Generi', ['/serie-tv/tvshow', 'genres', 'genres']), + ('Anni', ['/serie-tv/tvshow', 'genres', 'year'])] return locals() +def search(item, text): + logger.debug("search ", text) + # per evitare fastidi da ricerca globale + if not item.globalsearch: + registerOrLogin() + + item.args = 'search' + item.url = host + "/search?s={}&f={}".format(text.replace(' ', '+'), item.contentType) + try: + return movies(item) + + # Continua la ricerca in caso di errore + except: + import sys + for line in sys.exc_info(): + support.logger.error("%s" % line) + return [] + + +@support.scrape +def genres(item): + registerOrLogin() + logger.debug(item) + data = support.httptools.downloadpage(item.url).data + blacklist= ['Film', 'Serie TV'] + + if item.args == 'genres': + categories ={} + res = support.match(host + '/cerca', patron=r'for="cat-(\d+)[^>]+>([^<]+)').matches + for _id, name in res: + categories[name] = _id + + patronBlock = r'{}(?P.*?)\s*(?P[^<]+)' + + def itemHook(it): + it.cat_id = categories[it.fulltitle] + return it + + if item.args == 'year': + patronMenu = r'value="(?P<year_id>[^"]+)"[^>]*>(?P<title>\d+)' + patronBlock = r'Anno</option>(?P<block>.*?</select>)' + + elif item.args == 'quality': + patronMenu = r'quality/(?P<quality_id>[^"]+)">(?P<title>[^<]+)' + patronBlock = r'Risoluzione(?P<block>.*?)</ul>' + + action = 'movies' + return locals() + + +@support.scrape +def movies(item): + item.quality = 'HD' + json = {} + if not item.page: item.page = 1 + params ={'type':item.contentType, 'anno':item.year_id, 'quality':item.quality_id, 'cat':item.cat_id, 'order':order, 'page':item.page} + # debug = True + + action = 'findvideos' if item.contentType == 'movie' else 'episodes' + + try: + # support.dbg() + if item.args in ['search']: + page = support.httptools.downloadpage(item.url, headers=headers) + if page.json: + data = "\n".join(page.json['data']) + else: + data = page.data + else: + params['page'] = item.page + + url = '{}/load-more-film?{}'.format(host, support.urlencode(params)) + json = support.httptools.downloadpage(url, headers=headers).json + data = "\n".join(json['data']) + except: + data = ' ' + + patron = r'wrapFilm"[^>]*>\s*<a href="(?P<url>[^"]+)">[^>]+>(?P<year>\d+)(?:[^>]+>){2}(?P<rating>[^<]+)(?:[^>]+>){4}\s*<img src="(?P<thumb>[^"]+)(?:[^>]+>){2,6}\s+<h3>(?P<title>[^<[]+)(?:\[(?P<lang>[sSuUbBiItTaA -]+))?' + # patron = r'wrapFilm">\s*<a href="(?P<url>[^"]+)">[^>]+>(?P<year>\d+)(?:[^>]+>){2}(?P<rating>[^<]+)(?:[^>]+>){4}\s*<img src="(?P<thumb>[^"]+)(?:[^>]+>){3}(?P<title>[^<[]+)(?:\[(?P<lang>[sSuUbBiItTaA-]+))?' + + def itemHook(item): + item.quality = item.quality.replace('2K', 'HD').replace('4K', 'HD') + item.title = item.title.replace('2K', 'HD').replace('4K', 'HD') + return item + + # paginazione + if json.get('have_next') or support.match(data, patron=r'have_next_film\s*=\s*true').match: + def fullItemlistHook(itemlist): + cat_id = support.match(data, patron=r''''cat':"(\d+)"''').match + if cat_id: item.cat_id = cat_id + item.page += 1 + support.nextPage(itemlist, item, function_or_level='movies') + return itemlist + + return locals() + + +@support.scrape +def episodes(item): + logger.debug(item) + # debug = True + data = item.data + patron = r'class="playtvshow "\s+data-href="(?P<url>[^"]+)' + + def itemHook(it): + spl = it.url.split('/')[-2:] + it.infoLabels['season'] = int(spl[0])+1 + it.infoLabels['episode'] = int(spl[1])+1 + it.url = it.url.replace('/watch-unsubscribed', '/watch-external') + it.title = '{}x{:02d} - {}'.format(it.contentSeason, it.contentEpisodeNumber, it.fulltitle) + return it + + return locals() + + +def findvideos(item): + itemlist = [] + resolve_url(item) + + itemlist.append(item.clone(action='play', url=support.match(item.url, patron='allowfullscreen[^<]+src="([^"]+)"', cloudscraper=True).match, quality='')) + + return support.server(item, itemlist=itemlist) + + +def play(item): + if host in item.url: # intercetto il server proprietario + # if registerOrLogin(): + return support.get_jwplayer_mediaurl(support.httptools.downloadpage(item.url, cloudscraper=True).data, 'Diretto') + # else: + # platformtools.play_canceled = True + # return [] + else: + return [item] + + +def resolve_url(item): + registerOrLogin() + if '/watch-unsubscribed' not in item.url and '/watch-external' not in item.url: + playWindow = support.match(support.httptools.downloadpage(item.url, cloudscraper=True).data, patron='playWindow" href="([^"]+)') + video_url = playWindow.match + item.data = playWindow.data + item.url = video_url.replace('/watch-unsubscribed', '/watch-external') + return item + + def login(): r = support.httptools.downloadpage(host, cloudscraper=True) Token = support.match(r.data, patron=r'name=\s*"_token"\s*value=\s*"([^"]+)', cloudscraper=True).match @@ -51,12 +194,12 @@ def login(): else: logger.info('Login in corso') post = {'_token': '', - 'form_action':'login', + 'form_action':'login', 'email': config.get_setting('username', channel='altadefinizionecommunity'), 'password':config.get_setting('password', channel='altadefinizionecommunity')} r = support.httptools.downloadpage(host + '/login', post=post, headers={'referer': host}, cloudscraper=True) - if not r.status_code in [200, 302] or 'Email o Password non validi' in r.data: + if r.code not in [200, 302] or 'Email o Password non validi' in r.data: platformtools.dialog_ok('AltadefinizioneCommunity', 'Username/password non validi') return False @@ -127,143 +270,3 @@ def registerOrLogin(): return False return True - - -@support.scrape -def movies(item): - json = {} - # debug=True - - if item.contentType == 'undefined': - # tmdbEnabled = False - action = 'check' - elif item.contentType == 'movie': - action = 'findvideos' - else: - action = 'episodes' - try: - if '/load-more-film' not in item.url and '/search' not in item.url: # generi o altri menu, converto - import ast - ajax = support.match(item.url, patron='ajax_data\s*=\s*"?\s*([^;]+)', cloudscraper=True).match - item.url = host + '/load-more-film?' + support.urlencode(ast.literal_eval(ajax)) + '&page=1' - if not '/search' in item.url: - json = support.httptools.downloadpage(item.url, headers=headers, cloudscraper=True).json - data = "\n".join(json['data']) - else: - json = support.httptools.downloadpage(item.url, headers=headers, cloudscraper=True).json - data = "\n".join(json['data']) - except: - data = ' ' - - patron = r'wrapFilm">\s*<a href="(?P<url>[^"]+)">\s*<span class="year">(?P<year>[0-9]{4})</span>\s*<span[^>]+>(?P<rating>[^<]+)</span>\s*<span class="qual">(?P<quality>[^<]+)(?:[^>]+>){2}\s*<img src="(?P<thumbnail>[^"]+)(?:[^>]+>){1,6}\s*<h3>(?P<title>[^<[]+)(?:\[(?P<lang>[sSuUbBiItTaA-]+))?' - - # paginazione - logger.debug('JSON FIND',jsontools.load(json)) - if json.get('have_next'): - def fullItemlistHook(itemlist): - spl = item.url.split('=') - url = '='.join(spl[:-1]) - page = str(int(spl[-1])+1) - total_pages = json.get('lastPage', 0) - support.nextPage(itemlist, item, 'movies', next_page='='.join((url, page)), total_pages=total_pages) - return itemlist - - return locals() - - -def search(item, texto): - logger.debug("search ", texto) - - item.args = 'search' - item.url = host + "/search?s={}&page=1".format(texto) - try: - return movies(item) - # Continua la ricerca in caso di errore - except: - import sys - for line in sys.exc_info(): - logger.error('{}'.format(line)) - return [] - - -@support.scrape -def genres(item): - logger.debug(item) - data = support.httptools.downloadpage(item.url, cloudscraper=True).data - blacklist = ['Film', 'Serie TV', 'Trovatore', 'Lista A-Z'] - patronGenreMenu = r'<a href="(?P<url>[^"]+)">(?P<title>[^<]+)' - if item.args == 'quality': - item.contentType = 'undefined' - patronBlock = r'Risoluzione(?P<block>.*?)</ul>' - def itemlistHook(itemlist): - support.thumb(itemlist, mode='quality') - quality_list = ['4k','2k','hd','sd', '2k.md', 'hd.md', 'ts.md', 'cam'] - itemlist.sort(key=lambda it: quality_list.index(it.title.lower()) if it.title.lower() in quality_list else 99) - return itemlist - elif item.args == 'years': - item.contentType = 'undefined' - patronBlock = r'ANNO(?P<block>.*?</section>)' - else: - patronBlock = ('Film' if item.contentType == 'movie' else 'Serie TV') + r'<span></span></a>\s+<ul class="dropdown-menu(?P<block>.*?)active-parent-menu' - action = 'movies' - - return locals() - - -@support.scrape -def episodes(item): - logger.debug() - data = item.data - patron = r'class="playtvshow "\s*data-href="(?P<url>[^"]+)' - - def itemHook(it): - spl = it.url.split('/')[-2:] - it.contentSeason = int(spl[0])+1 - it.contentEpisodeNumber = int(spl[1])+1 - it.url = it.url.replace('/watch-unsubscribed', '/watch-external') - return it - - return locals() - - -def check(item): - resolve_url(item) - if '/tvshow' in item.url: - item.contentType = 'tvshow' - return episodes(item) - else: - item.contentType = 'movie' - return findvideos(item) - - -def findvideos(item): - itemlist = [] - # logger.dbg() - resolve_url(item) - - itemlist.append(item.clone(action='play', url=support.match(item.url, patron='allowfullscreen[^<]+src="([^"]+)"', cloudscraper=True).match, quality='')) - - return support.server(item, itemlist=itemlist) - - -def play(item): - if host in item.url: # intercetto il server proprietario - if registerOrLogin(): - return support.get_jwplayer_mediaurl(support.httptools.downloadpage(item.url, cloudscraper=True).data, 'Diretto') - else: - platformtools.play_canceled = True - return [] - else: - return [item] - - -def resolve_url(item): - registerOrLogin() - if '/watch-unsubscribed' not in item.url and '/watch-external' not in item.url: - data = support.httptools.downloadpage(item.url, headers=headers, cloudscraper=True).data - logger.debug() - playWindow = support.match(data, patron='playWindow" href="([^"]+)') - video_url = playWindow.match - item.data = playWindow.data - item.url = video_url.replace('/watch-unsubscribed', '/watch-external') - return item diff --git a/channels/animeunity.py b/channels/animeunity.py index 956437ad..494a5b4c 100644 --- a/channels/animeunity.py +++ b/channels/animeunity.py @@ -4,7 +4,8 @@ # ------------------------------------------------------------ import cloudscraper, json, copy, inspect -from core import jsontools, support +from core import jsontools, support, config +from core.httptools import downloadpage from platformcode import autorenumber, logger session = cloudscraper.create_scraper() @@ -13,10 +14,10 @@ host = support.config.get_channel_url() response = session.get(host + '/archivio') csrf_token = support.match(response.text, patron='name="csrf-token" content="([^"]+)"').match headers = {'content-type': 'application/json;charset=UTF-8', + 'Referer': host, 'x-csrf-token': csrf_token, 'Cookie' : '; '.join([x.name + '=' + x.value for x in response.cookies])} - @support.menu def mainlist(item): top = [('Ultimi Episodi', ['', 'news'])] @@ -40,13 +41,13 @@ def menu(item): Terminato = copy.copy(item.args) Terminato['status'] = 'Terminato' itemlist = [item.clone(title=support.typo('Tutti','bold')), - item.clone(title=support.typo('ITA','bold'), args=ITA), - item.clone(title=support.typo('Genere','bold'), action='genres'), - item.clone(title=support.typo('Anno','bold'), action='years')] + item.clone(title='ITA', args=ITA), + item.clone(title='Genere', action='genres'), + item.clone(title='Anno', action='years')] if item.contentType == 'tvshow': - itemlist += [item.clone(title=support.typo('In Corso','bold'), args=InCorso), - item.clone(title=support.typo('Terminato','bold'), args=Terminato)] - itemlist +=[item.clone(title=support.typo('Cerca...','bold'), action='search', thumbnail=support.thumb('search'))] + itemlist += [item.clone(title='In Corso', args=InCorso), + item.clone(title='Terminato', args=Terminato)] + itemlist +=[item.clone(title=support.typo(config.get_localized_string(70741).replace(' %s', '…'),'bold'), action='search', thumbnail=support.thumb('search'))] return itemlist @@ -58,7 +59,7 @@ def genres(item): for genre in genres: item.args['genres'] = [genre] - itemlist.append(item.clone(title=support.typo(genre['name'],'bold'), action='movies')) + itemlist.append(item.clone(title=genre['name'], action='movies')) return support.thumb(itemlist) def years(item): @@ -71,7 +72,7 @@ def years(item): for year in list(reversed(range(oldest_year, current_year + 1))): item.args['year']=year - itemlist.append(item.clone(title=support.typo(year,'bold'), action='movies')) + itemlist.append(item.clone(title=year, action='movies')) return itemlist @@ -121,11 +122,14 @@ def news(item): session = cloudscraper.create_scraper() fullJs = json.loads(support.match(session.get(item.url).text, headers=headers, patron=r'items-json="([^"]+)"').match.replace('"','"')) + # logger.debug(jsontools.dump(fullJs)) js = fullJs['data'] for it in js: itemlist.append( - item.clone(title= support.typo(it['anime']['title'] + ' - EP. ' + it['number'], 'bold'), + item.clone(title=it['anime']['title'], + contentTitle = it['anime']['title'], + contentEpisodeNumber = int(it['number']), fulltitle=it['anime']['title'], thumbnail=it['anime']['imageurl'], forcethumb = True, @@ -133,8 +137,8 @@ def news(item): plot=it['anime']['plot'], action='findvideos') ) - if 'next_page_url' in fullJs: - itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'),thumbnail=support.thumb(), url=fullJs['next_page_url'])) + if fullJs.get('next_page_url'): + support.nextPage(itemlist, item, 'news', next_page=fullJs['next_page_url'], total_pages=int(fullJs['last_page_url'].split('=')[-1])) return itemlist @@ -151,7 +155,9 @@ def movies(item): item.args['order'] = order_list[order] payload = json.dumps(item.args) - records = session.post(host + '/archivio/get-animes', headers=headers, data=payload).json()['records'] + js = session.post(host + '/archivio/get-animes', headers=headers, data=payload).json() + records = js['records'] + total_pages = int(js['tot'] / 30) for it in records: logger.debug(jsontools.dump(it)) @@ -161,18 +167,25 @@ def movies(item): if 'ita' in lang.lower(): language = 'ITA' else: language = 'Sub-ITA' - itm = item.clone(title=support.typo(title,'bold') + support.typo(language,'_ [] color kod') + (support.typo(it['title_eng'],'_ ()') if it['title_eng'] else '')) - itm.contentLanguage = language - itm.type = it['type'] - itm.thumbnail = it['imageurl'] - itm.plot = it['plot'] - itm.url = item.url + itm = item.clone(title=title, + contentLanguage = language, + type = it['type'], + thumbnail = it['imageurl'], + plot = it['plot'], + url = '{}/{}-{}'.format(item.url, it['id'], it['slug']) + ) + # itm.contentLanguage = language + # itm.type = it['type'] + # itm.thumbnail = it['imageurl'] + # itm.plot = it['plot'] + # itm.url = item.url if it['episodes_count'] == 1: itm.contentType = 'movie' itm.fulltitle = itm.show = itm.contentTitle = title itm.contentSerieName = '' - itm.action = 'findvideos' + itm.action = 'play' + item.forcethumb=True itm.video_url = it['episodes'][0]['scws_id'] else: @@ -181,33 +194,31 @@ def movies(item): itm.fulltitle = itm.show = itm.contentSerieName = title itm.action = 'episodes' itm.episodes = it['episodes'] if 'episodes' in it else it['scws_id'] - itm.video_url = item.url + # itm.video_url = item.url itemlist.append(itm) autorenumber.start(itemlist) - if len(itemlist) >= 30: - itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), thumbnail=support.thumb(), page=page + 1)) + if len(itemlist) == 30: + support.nextPage(itemlist, item, 'movies', page=page + 1, total_pages=total_pages) return itemlist def episodes(item): logger.debug() itemlist = [] - title = 'Parte ' if item.type.lower() == 'movie' else 'Episodio ' + # title = 'Parte ' if item.type.lower() == 'movie' else 'Episodio ' for it in item.episodes: + + episode2 = it['number'].split('.')[-1] + episode = it['number'].split('.')[0] itemlist.append( - item.clone(title=title, - episode = it['number'], - fulltitle=item.title, - show=item.title, - contentTitle='', - contentEpisodeNumber=it['number'], - contentSerieName=item.contentSerieName, - thumbnail=item.thumbnail, - plot=item.plot, - action='findvideos', + item.clone(episodes = [], + contentEpisodeNumber=int(float(it['number'])), + episodeExtra = '.' + it['number'].split('.')[-1] if '.' in it['number'] else '', + action='play', contentType='episode', + forcethumb=True, video_url=it['scws_id'])) if inspect.stack()[1][3] not in ['find_episodes']: @@ -217,29 +228,17 @@ def episodes(item): return itemlist -def findvideos(item): - directLink = False - if item.video_url == None: - if item.extra == "tvshow": - epnum = item.episode - logger.info('it is a episode', epnum) - episode = None - for ep in item.episodes: - if ep["number"] == epnum: - episode = ep - break - if episode == None: - logger.warn('cannot found episode') - else: - item.url = episode["link"] - directLink = True - - if directLink: - logger.info('try direct link') - return support.server(item, itemlist=[item.clone(title=support.config.get_localized_string(30137), url=item.url, server='directo', action='play')]) - else: - return support.server(item, itemlist=[item.clone(title="StreamingCommunityWS", url=str(item.video_url), manifest = 'hls', server='streamingcommunityws', action='play')]) +def play(item): + from time import time + from base64 import b64encode + from hashlib import md5 + # Calculate Token + client_ip = support.httptools.downloadpage('https://scws.xyz/videos/{}'.format(item.video_url), headers=headers).json.get('client_ip') + expires = int(time() + 172800) + token = b64encode(md5('{}{} Yc8U6r8KjAKAepEA'.format(expires, client_ip).encode('utf-8')).digest()).decode('utf-8').replace('=', '').replace('+', '-').replace('/', '_') + url = 'https://scws.xyz/master/{}?token={}&expires={}&n=1'.format(item.video_url, token, expires) + return [item.clone(server='directo', url=url, manifest='hls')] diff --git a/channels/aniplay.py b/channels/aniplay.py index 68a341d4..5cfb3937 100644 --- a/channels/aniplay.py +++ b/channels/aniplay.py @@ -1,5 +1,5 @@ from platformcode import config, logger, autorenumber -from core import httptools, scrapertools, support, tmdb +from core import httptools, jsontools, scrapertools, support, tmdb from inspect import stack import sys @@ -27,7 +27,7 @@ def mainlist(item): def submenu_az(item): itemlist = [] for letter in ['0-9'] + list('ABCDEFGHIJKLMNOPQRSTUVWXYZ'): - itemlist.append(item.clone(title = support.typo(letter, 'bold'), + itemlist.append(item.clone(title = letter, url= host + '/api/anime/find-by-char', action= 'movies', variable= '&character=' + letter, @@ -40,7 +40,7 @@ def submenu_year(item): current = date.today().year first = int(httptools.downloadpage('{}/api/anime/advanced-search?page=0&size=1&sort=startDate,asc&sort=id'.format(host)).json[0]['startDate'].split('-')[0]) -1 for year in range(current, first, -1): - itemlist.append(item.clone(title = support.typo(year, 'bold'), + itemlist.append(item.clone(title = year, action= 'submenu_season', variable= year, thumbnail=support.thumb('year'))) @@ -51,7 +51,7 @@ def submenu_top(item): links = {'Top del giorno':'daily-top', 'Top della settimana':'weekly-top', 'Top del mese':'monthly-top'} for label in links: link = links[label] - itemlist.append(item.clone(title = support.typo(label, 'bold'), + itemlist.append(item.clone(title = label, action= 'submenu_top_of', variable= link)) return itemlist @@ -80,9 +80,9 @@ def submenu_top_of(item): title = fulltitle.split('(')[0].strip() scrapedlang = scrapertools.find_single_match(fulltitle, r'\(([^\)]+)') lang = scrapedlang.upper() if scrapedlang else 'Sub-ITA' - long_title = support.typo(title, 'bold') + support.typo(lang, '_ [] color kod') + # long_title = support.typo(title, 'bold') + support.typo(lang, '_ [] color kod') - itemlist.append(item.clone(title=long_title, + itemlist.append(item.clone(title=title, id=anime['animeId'], url = '{}/api/anime/{}'.format(host, anime['animeId']), thumbnail = get_thumbnail(anime, 'animeHorizontalImages'), @@ -123,18 +123,21 @@ def newest(category): def latest_added(item): itemlist = [] + if config.get_setting("window_type") == 0: + item.window = True + item.folder = False page = item.page if item.page else 0 url= '{}/api/home/latest-episodes?page={}'.format(host, page) js = httptools.downloadpage(url).json for episode in js: - title = episode['title'] + logger.debug(jsontools.dump(episode)) + title = episode['title'] if episode['title'] else episode['animeTitle'] animeTitle, lang = get_lang(episode['animeTitle']) quality = 'Full HD' if episode['fullHd'] else 'HD' - long_title = support.typo('{}. {}{}'.format(int(float(episode['episodeNumber'])), title + ' - ' if title else '', animeTitle), 'bold') + support.typo(lang, '_ [] color kod') + support.typo(quality, '_ [] color kod') image = get_thumbnail(episode, 'episodeImages') - itemlist.append(item.clone(title=long_title, + itemlist.append(item.clone(title=title, fulltitle=title, animeId = episode['animeId'], id=episode['id'], @@ -165,9 +168,7 @@ def movies(item): for it in js: title, lang = get_lang(it['title']) - long_title = support.typo(title, 'bold') + support.typo(lang, '_ [] color kod') - - itemlist.append(item.clone(title = long_title, + itemlist.append(item.clone(title = title, fulltitle = title, show = title, contentLanguage = lang, @@ -193,6 +194,10 @@ def episodes(item): logger.debug() itemlist = [] + if config.get_setting("window_type") == 0: + item.window = True + item.folder = False + # url = '{}/api/anime/{}'.format(host, item.id) json = httptools.downloadpage(item.url, CF=False ).json @@ -208,6 +213,7 @@ def episodes(item): title = it['name'] itemlist.append(item.clone(title = title, + contentTitle = title, id= '{}/season/{}'.format(it['animeId'], it['id']), contentType = 'season', action = 'list_episodes', @@ -259,10 +265,11 @@ def list_episodes(item, json=None): else: episode = '{:02d}'.format(int(it['episodeNumber'].split('.')[0])) - title = support.typo('{}. {}'.format(episode, it['title']), 'bold') + # title = support.typo('{}. {}'.format(episode, it['title']), 'bold') image = get_thumbnail(it, 'episodeImages') - itemlist.append(item.clone(title = title, + itemlist.append(item.clone(title = it['title'], + contentTitle = it['title'], id= it['id'], url= 'api/episode/{}'.format(it['id']), contentType = 'episode', @@ -283,7 +290,7 @@ def list_episodes(item, json=None): def findvideos(item): logger.debug() - url = '{}/api/{}/{}'.format(host, 'episode' if item.contentType == 'episode' else 'anime', item.id) + url = '{}/api/{}/{}'.format(host, 'episode' if item.contentType != 'movie' else 'anime', item.id) json = httptools.downloadpage(url, CF=False ).json diff --git a/channels/streamingcommunity.json b/channels/streamingcommunity.json index c26b106e..c0d0728c 100644 --- a/channels/streamingcommunity.json +++ b/channels/streamingcommunity.json @@ -6,5 +6,15 @@ "thumbnail": "streamingcommunity.png", "banner": "streamingcommunity.png", "categories": ["movie","tvshow"], - "settings": [] + "settings": [ + { + "id": "pagination", + "type": "list", + "label": "Pagination", + "default": 1, + "enabled": true, + "visible": true, + "lvalues": ["10", "20", "30", "40", "50", "60"] + } + ] } diff --git a/channels/streamingcommunity.py b/channels/streamingcommunity.py index eed5eb6c..c7dfb5fc 100644 --- a/channels/streamingcommunity.py +++ b/channels/streamingcommunity.py @@ -5,7 +5,7 @@ import json, requests, sys from core import support, channeltools -from platformcode import logger +from platformcode import config, logger if sys.version_info[0] >= 3: from concurrent import futures else: @@ -17,12 +17,17 @@ def findhost(url): host = support.config.get_channel_url(findhost) session = requests.Session() headers = {} +perpage = config.get_setting('pagination', 'streamingcommunity', default=1) * 10 + 10 def getHeaders(): global headers + global host + # support.dbg() if not headers: headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'} response = session.get(host, headers=headers) + if response.status_code != 200 or response.url != host: + host = support.config.get_channel_url(findhost, forceFindhost=True) csrf_token = support.match(response.text, patron='name="csrf-token" content="([^"]+)"').match headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', 'content-type': 'application/json;charset=UTF-8', @@ -55,7 +60,7 @@ def genres(item): args = support.match(data, patronBlock=r'genre-options-json="([^\]]+)\]', patron=r'name"\s*:\s*"([^"]+)').matches for arg in args: itemlist.append(item.clone(title=support.typo(arg, 'bold'), args=arg, action='movies')) - support.thumb(itemlist, genre=True) + support.thumb(itemlist, mode=True) return itemlist @@ -105,14 +110,12 @@ def movies(item): # getHeaders() logger.debug() itemlist = [] - recordlist = [] videoType = 'movie' if item.contentType == 'movie' else 'tv' page = item.page if item.page else 0 - offset = page * 60 - if item.records: - records = item.records - elif type(item.args) == int: + offset = page * perpage + + if type(item.args) == int: data = support.scrapertools.decodeHtmlentities(support.match(item).data) records = json.loads(support.match(data, patron=r'slider-title titles-json="(.*?)" slider-name="').matches[item.args]) elif not item.search: @@ -129,20 +132,27 @@ def movies(item): else: js = records - for i, it in enumerate(js): - if i < 20: - itemlist.append(makeItem(i, it, item)) - else: - recordlist.append(it) + itemlist = makeItems(item, js) - itemlist.sort(key=lambda item: item.n) - if recordlist: - itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), thumbnail=support.thumb(), page=page, records=recordlist)) - elif len(itemlist) >= 20: - itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), thumbnail=support.thumb(), records=[], page=page + 1)) support.tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) + + if len(itemlist) == perpage: + support.nextPage(itemlist, item, 'movies', page=page + 1) + return itemlist + +def makeItems(item, items): + itemlist = [] + with futures.ThreadPoolExecutor() as executor: + itlist = [executor.submit(makeItem, n, it, item) for n, it in enumerate(items) if n < perpage] + for res in futures.as_completed(itlist): + if res.result(): + itemlist.append(res.result()) + itemlist.sort(key=lambda item: item.n) + return itemlist + + def makeItem(n, it, item): info = session.post(host + '/api/titles/preview/{}'.format(it['id']), headers=headers).json() title, lang = support.match(info['name'], patron=r'([^\[|$]+)(?:\[([^\]]+)\])?').match @@ -196,34 +206,26 @@ def episodes(item): def findvideos(item): - video_urls = [] - data = support.match(item.url + item.episodeid, headers=headers).data.replace('"','"').replace('\\','') - url = support.match(data, patron=r'video_url"\s*:\s*"([^"]+)"').match + channelParams = channeltools.get_channel_parameters(item.channel) + itemlist = [item.clone(title = channelParams['title'], server='directo', thumbnail=channelParams["thumbnail"], forcethumb=True, action='play')] + return support.server(item, itemlist=itemlist) - def calculateToken(): - from time import time - from base64 import b64encode as b64 - import hashlib - o = 48 - n = support.match(host + '/client-address').data - i = 'Yc8U6r8KjAKAepEA' - t = int(time() + (3600 * o)) - l = '{}{} {}'.format(t, n, i) - md5 = hashlib.md5(l.encode()) - s = '?token={}&expires={}'.format(b64(md5.digest()).decode().replace('=', '').replace('+', "-").replace('\\', "_"), t) - return s - token = calculateToken() +def play(item): + from time import time + from base64 import b64encode + from hashlib import md5 + data = support.httptools.downloadpage(item.url + item.episodeid, headers=headers).data.replace('"','"').replace('\\','') + scws_id = support.match(data, patron=r'scws_id"\s*:\s*(\d+)').match - def videourls(res): - newurl = '{}/{}{}'.format(url, res, token) - if requests.head(newurl, headers=headers).status_code == 200: - video_urls.append({'type':'m3u8', 'res':res, 'url':newurl}) + if not scws_id: + return [] - with futures.ThreadPoolExecutor() as executor: - for res in ['480p', '720p', '1080p']: - executor.submit(videourls, res) + # Calculate Token + client_ip = support.httptools.downloadpage('https://scws.xyz/videos/' + scws_id, headers=headers).json.get('client_ip') + expires = int(time() + 172800) + token = b64encode(md5('{}{} Yc8U6r8KjAKAepEA'.format(expires, client_ip).encode('utf-8')).digest()).decode('utf-8').replace('=', '').replace('+', '-').replace('/', '_') - if not video_urls: video_urls = [{'type':'m3u8', 'url':url + token}] - itemlist = [item.clone(title = channeltools.get_channel_parameters(item.channel)['title'], server='directo', video_urls=video_urls, thumbnail=channeltools.get_channel_parameters(item.channel)["thumbnail"], forcethumb=True)] - return support.server(item, itemlist=itemlist) \ No newline at end of file + url = 'https://scws.xyz/master/{}?token={}&expires={}&n=1'.format(scws_id, token, expires) + + return [item.clone(server='directo', url=url, manifest='hls')] \ No newline at end of file diff --git a/channels/vvvvid.py b/channels/vvvvid.py index faab6ba9..df538f33 100644 --- a/channels/vvvvid.py +++ b/channels/vvvvid.py @@ -3,8 +3,8 @@ # Canale per vvvvid # ---------------------------------------------------------- import requests, sys, inspect -from core import support, tmdb -from platformcode import autorenumber, logger, config +from core import channeltools, support, tmdb +from platformcode import autorenumber, logger, config, platformtools host = support.config.get_channel_url() @@ -140,6 +140,10 @@ def movies(item): def episodes(item): itemlist = [] + if config.get_setting("window_type") == 0: + item.window = True + item.folder = False + if item.episodes: episodes = item.episodes show_id = item.show_id @@ -164,10 +168,11 @@ def episodes(item): if type(title) == tuple: title = title[0] itemlist.append( item.clone(title = title, + contentType = 'episode', contentEpisodeNumber = int(episode['number']), - url= main_host + show_id + '/season/' + str(season_id), - action= 'findvideos', - video_id= episode['video_id'])) + url= main_host + show_id + '/season/' + str(season_id), + action= 'findvideos', + video_id= episode['video_id'])) if inspect.stack()[1][3] not in ['find_episodes']: autorenumber.start(itemlist, item) @@ -209,8 +214,7 @@ def findvideos(item): item.clone(action= 'play', title=config.get_localized_string(30137), url= item.url + '?' + key, - server= 'directo') - ) + server= 'directo')) return support.server(item, itemlist=itemlist, Download=False) diff --git a/core/support.py b/core/support.py index 6b9ffb82..8fab6952 100755 --- a/core/support.py +++ b/core/support.py @@ -853,6 +853,9 @@ def nextPage(itemlist, item, function_or_level=1, **kwargs): page = kwargs.get('page', None) total_pages = kwargs.get('total_pages', None) + if total_pages and total_pages % 1: + total_pages = int(total_pages) + 1 + # get next_page from data if data and patron: next_page = scrapertools.find_single_match(data, patron) @@ -885,9 +888,10 @@ def nextPage(itemlist, item, function_or_level=1, **kwargs): nextPage=True, page=page if page else item.page + 1 if item.page else 2, prevthumb = item.thumbnail, + folder=True, thumbnail=thumb())) - if total_pages: + itemlist.append(item.clone(action='gotopage', real_action = inspect.stack()[function_or_level][3] if type(function_or_level) == int else function_or_level, title=typo(config.get_localized_string(90007), 'color kod bold'), @@ -1051,7 +1055,11 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru if videoitem.quality: vi.quality = videoitem.quality if not vi.referer: vi.referer = item.url if videoitem.contentType == 'episode': vi.fanart=videoitem.thumbnail + if videoitem.forcethumb: + vi.thumbnail = videoitem.thumbnail + vi.forcethumb = True videoitem = vi + # videoitem = item.clone(serverName = videoitem.title if videoitem.title else videoitem.ser) # quality = videoitem.quality if videoitem.quality else item.quality if item.quality else '' # videoitem.contentLanguage = videoitem.contentLanguage if videoitem.contentLanguage else item.contentLanguage if item.contentLanguage else 'ITA' diff --git a/platformcode/launcher.py b/platformcode/launcher.py index bce34fc4..bd2b8b48 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -168,7 +168,7 @@ def run(item=None): if page and int(page) > -1: import xbmc item.action = item.real_action - item.page = page + item.page = int(page) import re item.url = re.sub('([=/])[0-9]+(/?)$', '\g<1>{}\g<2>'.format(page), item.url) xbmc.executebuiltin("Container.Update(%s?%s)" % (sys.argv[0], item.tourl())) @@ -228,6 +228,7 @@ def run(item=None): # Special action for findvideos, where the plugin looks for known urls elif item.action == "findvideos": + # logger.dbg() from core import servertools p_dialog = None if item.window: diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index f19f794f..2a86bea8 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -336,8 +336,6 @@ def render_items(itemlist, parent_item): logger.debug('START render_items') thumb_type = config.get_setting('video_thumbnail_type') from platformcode import shortcuts - from core.support import typo - from core import servertools _handle = int(sys.argv[1]) default_fanart = config.get_fanart() def_context_commands = shortcuts.context() @@ -365,31 +363,7 @@ def render_items(itemlist, parent_item): icon_image = "DefaultFolder.png" if item.folder else "DefaultVideo.png" - title = item.title if item.title else item.contentTitle - episode = '' - - if title[:1] not in ['[', '•']: - # if item.contentTitle: title = item.contentTitle - # elif item.contentSerieName: title = item.contentSerieName - if type(item.contentSeason) == int and type(item.contentEpisodeNumber) == int and not item.onlyep: - episode = '{}x{:02d}'.format(item.contentSeason, item.contentEpisodeNumber) - elif type(item.contentEpisodeNumber) == int: - episode = '{:02d}'.format(item.contentEpisodeNumber) - if episode and item.episode2: - if len(item.episode2) < 4: episode = '{}-{}'.format(episode, '-'.join('{:02d}'.format(int(e)) for e in item.episode2)) - else: episode = '{} -> {:02d}'.format(episode, item.episode2[-1]) - if episode: title = '{}. {}'.format(episode, title) - if item.title2: title = '{} - {}'.format(title, item.title2) - - if config.get_setting('format_title') or item.server: - server = typo(item.serverName, '__ [] bold') if item.server else '' - quality = typo(item.quality, '_ [] color kod') if item.quality else '' - lang = typo(item.contentLanguage, '_ [] color kod') if item.contentLanguage else '' - extra = typo(item.extraInfo, '_ [] color kod') if item.extraInfo else '' - size = typo(item.size, '_ [] color kod') if item.size else '' - seed = typo('Seed: ' + item.seed, '_ [] color kod') if item.seed else '' - - title = '{}{}{}{}{}{}{}'.format(server, title, quality, lang, extra, size, seed) + title = setTitle(item) listitem = xbmcgui.ListItem(title) @@ -463,7 +437,7 @@ def render_items(itemlist, parent_item): xbmcplugin.setPluginCategory(handle=_handle, category=breadcrumb) set_view_mode(itemlist[0], parent_item) - xbmcplugin.endOfDirectory(_handle, succeeded=True, updateListing=False, cacheToDisc=False) + xbmcplugin.endOfDirectory(_handle, succeeded=True, updateListing=False, cacheToDisc=True) logger.debug('END render_items') @@ -479,39 +453,79 @@ def render_items(itemlist, parent_item): pos = position + (1 if xbmc.getInfoLabel('Container(10138).HasParent') else 0) ctrl.selectItem(pos) +def setTitle(item): + from core.support import typo + title = item.title if item.title else item.contentTitle + episode = '' + + if title[:1] not in ['[', '•']: + # if item.contentTitle: title = item.contentTitle + # elif item.contentSerieName: title = item.contentSerieName + if type(item.contentSeason) == int and type(item.contentEpisodeNumber) == int and not item.onlyep: + episode = '{}x{:02d}'.format(item.contentSeason, item.contentEpisodeNumber) + elif type(item.contentEpisodeNumber) == int: + episode = '{:02d}'.format(item.contentEpisodeNumber) + if item.episodeExtra: episode += item.episodeExtra + if episode and item.episode2: + if len(item.episode2) < 4: episode = '{}-{}'.format(episode, '-'.join('{:02d}'.format(int(e)) for e in item.episode2)) + else: episode = '{} -> {:02d}'.format(episode, item.episode2[-1]) + if episode: title = '{}. {}'.format(episode, title) + if item.title2: title = '{} - {}'.format(title, item.title2) + + if config.get_setting('format_title') or item.server: + server = typo(item.serverName, '__ [] bold') if item.server else '' + quality = typo(item.quality, '_ [] color kod') if item.quality else '' + lang = typo(item.contentLanguage, '_ [] color kod') if item.contentLanguage else '' + extra = typo(item.extraInfo, '_ [] color kod') if item.extraInfo else '' + size = typo(item.size, '_ [] color kod') if item.size else '' + seed = typo('Seed: ' + item.seed, '_ [] color kod') if item.seed else '' + + title = '{}{}{}{}{}{}{}'.format(server, title, quality, lang, extra, size, seed) + return title + def viewmodeMonitor(): if get_window() == 'WINDOW_VIDEO_NAV': try: currentModeName = xbmc.getInfoLabel('Container.Viewmode') - win = xbmcgui.Window(xbmcgui.getCurrentWindowId()) + parent_info = xbmc.getInfoLabel('Container.FolderPath') + item_info = xbmc.getInfoLabel('Container.ListItemPosition(2).FileNameAndPath') + parent_item = Item().fromurl(parent_info) + win = xbmcgui.Window(10025) currentMode = int(win.getFocusId()) - if currentModeName and 'plugin.video.kod' in xbmc.getInfoLabel('Container.FolderPath') and currentMode < 1000 and currentMode >= 50: # inside addon and in itemlist view - content, Type = getCurrentView() + if currentModeName and 'plugin.video.kod' in parent_info and 50 <= currentMode < 1000: # inside addon and in itemlist view + content, Type = getCurrentView(Item().fromurl(item_info) if item_info else Item(), Item().fromurl(parent_info)) if content: - defaultMode = int(config.get_setting('view_mode_{}'.format(content)).split(',')[-1]) + defaultMode = int(config.get_setting('view_mode_%s' % content).split(',')[-1]) if currentMode != defaultMode: - logger.debug('viewmode changed: ' + currentModeName + '-' + str(currentMode) + ' - content: ' + content) - config.set_setting('view_mode_{}'.format(content), currentModeName + ', ' + str(currentMode)) - dialog_notification(config.get_localized_string(70153), - config.get_localized_string(70187) % (content, currentModeName), - sound=False) + config.set_setting('view_mode_%s' % content, currentModeName + ', ' + str(currentMode)) + # dialog_notification(config.get_localized_string(70153), + # config.get_localized_string(70187) % (content, currentModeName), + # sound=False) except: import traceback logger.error(traceback.print_exc()) def getCurrentView(item=None, parent_item=None): - if not parent_item: - info = xbmc.getInfoLabel('Container.FolderPath') - if not info: - return None, None - parent_item = Item().fromurl(info) + if not item: - info = xbmc.getInfoLabel('Container.ListItemPosition(2).FileNameAndPath') # first addon listitem (consider "..") - if not info: - return None, None - item = Item().fromurl(info) if info else Item() + item = Item() + if not parent_item: + logger.debug('ESCO') + return None, None + + # if not parent_item: + # info = xbmc.getInfoLabel('Container.FolderPath') + # if not info: + # return None, None + # parent_item = Item().fromurl(info) + # if not item: + # info = xbmc.getInfoLabel('Container.ListItemPosition(2).FileNameAndPath') # first addon listitem (consider "..") + # if not info: + # item = Item() + # else: + # item = Item().fromurl(info) if info else Item() parent_actions = ['movies', 'news', 'search', 'get_from_temp', 'newest', 'discover_list', 'new_search', 'channel_search'] addons = 'addons' if config.get_setting('touch_view') else '' @@ -532,21 +546,25 @@ def getCurrentView(item=None, parent_item=None): or (item.channel in ['videolibrary'] and parent_item.action in ['list_tvshows']): return 'tvshow', 'tvshows' - elif parent_item.action in ['get_seasons'] or item.contentType == 'season': + elif parent_item.action in ['episode', 'get_episodes'] or item.contentType == 'episode': + return 'episode', 'tvshows' + + elif parent_item.action in ['get_seasons']: + logger.debug('CONTENTTYPE:',item.contentType) return 'season', 'tvshows' - elif parent_item.action in ['episodes', 'get_episodes'] or item.contentType == 'episode': - return 'episode', 'episodes' - - elif not parent_item.action or parent_item.action in ['getmainlist']: + elif parent_item.action in ['getmainlist', '', 'getchanneltypes']: return 'home', addons elif parent_item.action in ['filterchannels']: return 'channels', addons - else: + elif item.action: return 'menu', addons + else: + return None, None + def set_view_mode(item, parent_item): def reset_view_mode(): @@ -1082,6 +1100,8 @@ def play_video(item, strm=False, force_direct=False, autoplay=False): xlistitem.setProperty('inputstream' if PY3 else 'inputstreamaddon', 'inputstream.adaptive') xlistitem.setProperty('inputstream.adaptive.manifest_type', 'hls') xlistitem.setMimeType('application/x-mpegURL') + xlistitem.setProperty("inputstream.adaptive.license_type", item.drm) + xlistitem.setProperty("inputstream.adaptive.license_key", item.license) if force_direct: item.window = True @@ -1850,6 +1870,7 @@ def serverwindow(item, itemlist): self.itemlist = itemlist self.item = item self.servers = [] + items = [] self.selection = -1 for videoitem in self.itemlist: @@ -1870,6 +1891,8 @@ def serverwindow(item, itemlist): it.setProperties({'name': title, 'channel': videoitem.ch_name, 'color': color if color else 'FF0082C2'}) it.setArt({'poster':self.item.contentThumbnail if self.item.contentThumbnail else self.item.thumbnail, 'thumb':videoitem.thumbnail, 'fanart':videoitem.fanart}) self.servers.append(it) + items.append(videoitem) + self.itemlist = items self.doModal() return self.selection diff --git a/specials/news.py b/specials/news.py index 717f6ce8..c40e57ec 100644 --- a/specials/news.py +++ b/specials/news.py @@ -14,6 +14,7 @@ else: from concurrent_py2 import futures mode = config.get_setting('result_mode', 'news') +cacheTime = 10 def mainlist(item): logger.debug() @@ -76,6 +77,7 @@ def news(item): else: itemlist = [] + itlist = [] results = cache(item.extra) if not results: progress = platformtools.dialog_progress(item.category, config.get_localized_string(60519)) @@ -83,17 +85,24 @@ def news(item): channelNames = [c[0] for c in channels] count = 0 - progress.update(int(count / len(channels)), ', '.join(c for c in channelNames)) + # progress.update(int(count / len(channels)), ', '.join(c for c in channelNames)) + # logger.dbg() with futures.ThreadPoolExecutor() as executor: - itlist = [executor.submit(get_newest, channel, item.extra, channels) for channel in channels] + for channel in channels: + if progress.iscanceled(): return + itlist.append(executor.submit(get_newest, channel, item.extra, channels)) for res in futures.as_completed(itlist): if res.result(): name = res.result()[0] channelNames.remove(name) - progress.update(int(count + 1 / len(channels)), ', '.join(c for c in channelNames)) + count += 1 + percent = int((float(count) / len(channels)) * 100) + progress.update(percent, ', '.join(c for c in channelNames)) results.append(res.result()) + if progress: + # progress.update(100, '') progress.close() cache(item.extra, results) @@ -110,7 +119,7 @@ def news(item): plot = '' items = [] for it in res[2]: - plot += '\n{}'.format(it.title) + plot += '\n{}'.format(platformtools.setTitle(it)) items.append(it.tourl()) if items: itemlist.append(Item(title='{} [{}]'.format(res[0], len(items)), @@ -120,8 +129,8 @@ def news(item): thumbnail=channeltools.get_channel_parameters(res[1])["thumbnail"], items=items)) itemlist.sort(key=lambda it: it.title) - elif mode in [0]: + elif mode in [0]: items = {} for res in results: _name, _id, _list = res @@ -129,9 +138,10 @@ def news(item): if it.fulltitle not in items: items[it.fulltitle] = [] + it.channelName = _name items[it.fulltitle].append(it.tourl()) - itemlist = [Item(title='{} [{}]'.format(k, len(items)), infoLabels=Item().fromurl(v[0]).infoLabels, channel='news', action='movies', items = v) for k, v in items.items()] + itemlist = [Item(title='{} [{}]'.format(v, len(v) if len(v) > 1 else Item().fromurl(v[0]).channelName), infoLabels=Item().fromurl(v[0]).infoLabels, channel='news', action='movies', items = v) for v in items.values()] if mode in [0, 2]: itemlist = support.pagination(itemlist, item, 'news') @@ -167,27 +177,38 @@ def get_newest(channel, category, channels): def movies(item): - itemlist = [Item().fromurl(url=it) for it in item.items] - if mode == 1: tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) + if item.itemlist: + itemlist = support.itemlistdb() + else: + itemlist = [Item().fromurl(url=it) for it in item.items] + if len(itemlist) == 1: + from platformcode.launcher import run + run(itemlist[0]) + if mode == 0: + for it in itemlist: + it.title = '{} [{}]'.format(it.title, it.channelName) + itemlist = support.pagination(itemlist, item, 'movies') + tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) return itemlist def cache(_type, results=None): from core import db from time import time - news = db['news'] # logger.dbg() + news = dict(db['news'][_type]) + if results != None: - news[_type] = {} - news[_type]['time'] = time() - news[_type]['results'] = results - db['news'] = news + news = {} + news['time'] = time() + news['results'] = results + db['news'][_type] = news - elif news.get(_type, {}).get('time', 0) + 60 < time() : + elif news.get('time', 0) + 60 * cacheTime < time() : results = [] else: - results = news.get(_type, {}).get('results', []) + results = news.get('results', []) db.close() return results