From 18684204257269add890adbe28940efb4e6ddeef Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Sat, 5 Jun 2021 15:51:46 +0200 Subject: [PATCH] Formattazione Titoli in render_items + correzione di alcuni canali --- addon.xml | 2 +- channels.json | 17 ++-- channels/animeuniverse.py | 2 +- channels/animeworld.py | 7 +- channels/vvvvid.py | 9 +- core/support.py | 178 +++++++++++++++++----------------- core/videolibrarytools.py | 24 ++--- platformcode/autorenumber.py | 74 ++++++++------ platformcode/platformtools.py | 26 ++++- specials/videolibrary.py | 9 +- 10 files changed, 194 insertions(+), 154 deletions(-) diff --git a/addon.xml b/addon.xml index 22466139..8db4fc5c 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/channels.json b/channels.json index 87fc8197..af78f550 100644 --- a/channels.json +++ b/channels.json @@ -1,7 +1,7 @@ { "direct": { "altadefinizione01": "https://www.altadefinizione01.games", - "altadefinizione01_link": "https://altadefinizione01.cheap", + "altadefinizione01_link": "https://altadefinizione01.travel", "animealtadefinizione": "https://www.animealtadefinizione.it", "animeforce": "https://www.animeforce.it", "animeleggendari": "https://animezeus.com", @@ -12,7 +12,7 @@ "casacinema": "https://www.casacinema.page", "cb01anime": "https://www.cineblog01.red", "cineblog01": "https://cb01.uno", - "cinemalibero": "https://cinemalibero.monster", + "cinemalibero": "https://cinemalibero.blog", "cinetecadibologna": "http://cinestore.cinetecadibologna.it", "discoveryplus": "https://www.discoveryplus.com", "dreamsub": "https://dreamsub.stream", @@ -26,26 +26,27 @@ "ilcorsaronero": "https://ilcorsaronero.link", "ilgeniodellostreaming": "https://ilgeniodellostreaming.ist", "ilgeniodellostreaming_cam": "https://ilgeniodellostreaming.shop", - "italiaserie": "https://italiaserie.work", + "italiaserie": "https://italiaserie.cam", "mediasetplay": "https://www.mediasetplay.mediaset.it", "mondoserietv": "https://mondoserietv.club", "paramount": "https://www.paramountnetwork.it", - "piratestreaming": "https://www.piratestreaming.bar", + "piratestreaming": "https://www.piratestreaming.shop", "polpotv": "https://roma.polpo.tv", "raiplay": "https://www.raiplay.it", "serietvonline": "https://serietvonline.art", "serietvsubita": "http://serietvsubita.xyz", "serietvu": "https://www.serietvu.link", - "streamingcommunity": "https://streamingcommunity.one", + "streamingcommunity": "https://streamingcommunity.xyz", "streamtime": "https://t.me/s/StreamTime", - "toonitalia": "https://toonitalia.pro", + "tantifilm": "https://www.tantifilm.vision", + "tapmovie": "https://it.tapmovie.net", + "toonitalia": "https://toonitalia.co", "vvvvid": "https://www.vvvvid.it" }, "findhost": { "altadefinizioneclick": "https://altadefinizione-nuovo.click", "animealtadefinizione": "https://www.animealtadefinizione.it", "filmpertutti": "https://filmpertuttiii.nuovo.live", - "seriehd": "https://nuovoindirizzo.info/seriehd", - "tantifilm": "https://tantinuovo.com/tantifilm-nuovo-indirizzo" + "seriehd": "https://nuovoindirizzo.info/seriehd" } } \ No newline at end of file diff --git a/channels/animeuniverse.py b/channels/animeuniverse.py index da4248e1..76031a42 100644 --- a/channels/animeuniverse.py +++ b/channels/animeuniverse.py @@ -10,7 +10,7 @@ headers = {} perpage_list = ['20','30','40','50','60','70','80','90','100'] perpage = perpage_list[support.config.get_setting('perpage' , 'animeuniverse')] -epPatron = r'\s*(?P[^<]+)[^>]+>[^>]+>\s*<a href="(?P<url>[^"]+)"' +epPatron = r'<td>\s*(?P<title>[^ <]+)\s*(?P<episode>\d+)?[^>]+>[^>]+>\s*<a href="(?P<url>[^"]+)"' @support.menu diff --git a/channels/animeworld.py b/channels/animeworld.py index f443070c..59bbda24 100644 --- a/channels/animeworld.py +++ b/channels/animeworld.py @@ -155,8 +155,7 @@ def episodios(item): patronBlock= r'<div class="server\s*active\s*"(?P<block>.*?)(?:<div class="server|<link)' patron = r'<li[^>]*>\s*<a.*?href="(?P<url>[^"]+)"[^>]*>(?P<episode>[^-<]+)(?:-(?P<episode2>[^<]+))?' def itemHook(item): - item.number = support.re.sub(r'\[[^\]]+\]', '', item.title) - item.title += support.typo(item.fulltitle,'-- bold') + item.title = item.fulltitle return item action='findvideos' return locals() @@ -172,8 +171,8 @@ def findvideos(item): data = resp.data for ID, name in resp.matches: - if not item.number: item.number = support.match(item.title, patron=r'(\d+) -').match - match = support.match(data, patronBlock=r'data-name="' + ID + r'"[^>]+>(.*?)(?:<div class="(?:server|download)|link)', patron=r'data-id="([^"]+)" data-episode-num="' + (item.number if item.number else '1') + '"' + r'.*?href="([^"]+)"').match + # if not item.number: item.number = support.match(item.title, patron=r'(\d+) -').match + match = support.match(data, patronBlock=r'data-name="{}"[^>]+>(.*?)(?:<div class="(?:server|download)|link)', patron=r'data-id="([^"]+)" data-episode-num="{}".*?href="([^"]+)"'.format(ID, item.contentEpisodeNumber if item.contentEpisodeNumber else 1)).match if match: epID, epurl = match # if 'vvvvid' in name.lower(): diff --git a/channels/vvvvid.py b/channels/vvvvid.py index 6e736f83..c09f825b 100644 --- a/channels/vvvvid.py +++ b/channels/vvvvid.py @@ -154,19 +154,22 @@ def episodios(item): for episode in episodes: try: - title = 'Episodio ' + episode['number'] + ' - ' + episode['title'].encode('utf8') + title = episode['title'].encode('utf8') except: - title = 'Episodio ' + episode['number'] + ' - ' + episode['title'] + title = episode['title'] if type(title) == tuple: title = title[0] itemlist.append( - item.clone(title = support.typo(title, 'bold'), + item.clone(title = title, + contentEpisodeNumber = int(episode['number']), 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) + for i in itemlist: + logger.debug(i) support.videolibrary(itemlist,item) return itemlist diff --git a/core/support.py b/core/support.py index 436e0652..12dd21f3 100755 --- a/core/support.py +++ b/core/support.py @@ -131,7 +131,7 @@ def regexDbg(item, patron, headers, data=''): webbrowser.open(url + "/r/" + permaLink) -def scrapeLang(scraped, lang, longtitle): +def scrapeLang(scraped, lang): ## Aggiunto/modificato per gestire i siti che hanno i video ## in ita e subita delle serie tv nella stessa pagina # altrimenti dopo un sub-ita mette tutti quelli a seguire in sub-ita @@ -143,14 +143,15 @@ def scrapeLang(scraped, lang, longtitle): if 'sub' in scraped['lang'].lower(): language = 'Sub-' + language if not language: language = lang - if language: longtitle += typo(language, '_ [] color kod') - return language, longtitle + # if language: longtitle += typo(language, '_ [] color kod') + return language def cleantitle(title): cleantitle = '' if title: if type(title) != str: title.decode('UTF-8') + title = scrapertools.unescape(title) title = scrapertools.decodeHtmlentities(title) cleantitle = title.replace('"', "'").replace('×', 'x').replace('–', '-').strip() return cleantitle @@ -191,7 +192,10 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t # lang = lingua del video. Es: ITA, Sub-ITA, Sub, SUB ITA. # AVVERTENZE: Se il titolo è trovato nella ricerca TMDB/TVDB/Altro allora le locandine e altre info non saranno quelle recuperate nel sito.!!!! - stagione = '' # per quei siti che hanno la stagione nel blocco ma non nelle puntate + season = '' # per quei siti che hanno la stagione nel blocco ma non nelle puntate + episode = '' + second_episode = '' + extraInfo = '' contents = [] for i, match in enumerate(matches): @@ -221,8 +225,7 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t title = cleantitle(scraped.get('title', '')) if group and scraped.get('title', '') in contents and not item.grouped: # same title and grouping enabled continue - if item.grouped and scraped.get('title', - '') != item.fulltitle: # inside a group different tvshow should not be included + if item.grouped and scraped.get('title', '') != item.fulltitle: # inside a group different tvshow should not be included continue contents.append(title) title2 = cleantitle(scraped.get('title2', '')) if not group or item.grouped else '' @@ -230,6 +233,7 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t # Type = scraped['type'] if scraped['type'] else '' plot = cleantitle(scraped.get("plot", '')) + # if title is set, probably this is a list of episodes or video sources # necessaria l'aggiunta di == scraped["title"] altrimenti non prende i gruppi dopo le categorie if item.infoLabels["title"] == scraped["title"]: @@ -244,8 +248,7 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t if scraped["plot"]: infolabels['plot'] = plot if scraped['duration']: - dur = scrapertools.find_multiple_matches(scraped['duration'], - r'([0-9])\s*?(?:[hH]|:|\.|,|\\|\/|\||\s)\s*?([0-9]+)') + dur = scrapertools.find_multiple_matches(scraped['duration'], r'([0-9])\s*?(?:[hH]|:|\.|,|\\|\/|\||\s)\s*?([0-9]+)') for h, m in dur: scraped['duration'] = int(h) * 60 + int(m) if not dur: @@ -260,55 +263,52 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t if scraped["rating"]: infolabels['rating'] = scrapertools.decodeHtmlentities(scraped["rating"]) - episode = '' if not group or item.grouped: - if scraped['season'] and scraped['episode']: - stagione = scraped['season'] - ep = unifyEp(scraped['episode']) + # dbg() + ep = unifyEp(scraped['episode']) if scraped['episode'] else '' + se = scraped['season'] if scraped['season'].isdigit() else '' + if ep and se: + season = int(se) if 'x' in ep: - episode = ep.split('x')[0].strip() - second_episode = ep.split('x')[1].strip() + ep_list = ep.split('x') + episode = ep_list.strip() + second_episode = ep_list[1:] else: episode = ep - second_episode = '' - infolabels['season'] = int(scraped['season']) - infolabels['episode'] = int(episode) - episode = str(int(scraped['season'])) +'x'+ str(int(episode)).zfill(2) + ('x' + str(int(second_episode)).zfill(2) if second_episode else '') + elif item.season: - infolabels['season'] = int(item.season) - infolabels['episode'] = int(scrapertools.find_single_match(scraped['episode'], r'(\d+)')) - episode = item.season +'x'+ scraped['episode'].zfill(2) - elif item.contentType == 'tvshow' and (scraped['episode'] == '' and scraped['season'] == '' and stagione == ''): + season = int(item.season) + if ep: episode = int(scrapertools.find_single_match(scraped['episode'], r'(\d+)')) + + elif item.contentType == 'tvshow' and (scraped['episode'] == '' and scraped['season'] == '' and season == ''): item.news = 'season_completed' - episode = '' + else: - episode = unifyEp(scraped['episode']) if scraped['episode'] else '' try: - if 'x' in episode: - ep = episode.split('x') - episode = str(int(ep[0])).zfill(1) + 'x' + str(int(ep[1])).zfill(2) - infolabels['season'] = int(ep[0]) - infolabels['episode'] = int(ep[1]) - second_episode = scrapertools.find_single_match(episode, r'x\d+x-\d+)') - if second_episode: episode = re.sub(r'(\d+x\d+)x\d+',r'\1-', episode) + second_episode.zfill(2) + if 'x' in ep: + ep_list = ep.split('x') + episode = ep_list[1].strip() + season = ep_list[2].strip() + if len(ep_list) > 2: + second_episode = ep_list[2:] + else: + episode = ep except: logger.debug('invalid episode: ' + episode) pass if scraped['episode2']: - episode += '-' + scrapertools.find_single_match(scraped['episode2'], r'(\d+)') + ep2 = scrapertools.find_single_match(scraped['episode2'], r'(\d+)') + ep_list = ep2.split('x') + second_episode = ep_list - # make formatted Title [longtitle] - s = ' - ' - # title = episode + (s if episode and title else '') + title - longtitle = episode + (s if episode and (title or title2) else '') + title + (s if title and title2 else '') + title2 if sceneTitle: from lib.guessit import guessit try: parsedTitle = guessit(title) - title = longtitle = parsedTitle.get('title', '') + title = parsedTitle.get('title', '') logger.debug('TITOLO',title) if parsedTitle.get('source'): quality = str(parsedTitle.get('source')) @@ -316,43 +316,36 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t quality += ' ' + str(parsedTitle.get('screen_size', '')) if not scraped['year']: if type(parsedTitle.get('year', '')) == list: - infolabels['year'] =parsedTitle.get('year', '')[0] + infolabels['year'] = parsedTitle.get('year', '')[0] else: infolabels['year'] = parsedTitle.get('year', '') if parsedTitle.get('episode') and parsedTitle.get('season'): - longtitle = title + s - if type(parsedTitle.get('season')) == list: - longtitle += str(parsedTitle.get('season')[0]) + '-' + str(parsedTitle.get('season')[-1]) - infolabels['season'] = parsedTitle.get('season')[0] - else: - longtitle += str(parsedTitle.get('season')) - infolabels['season'] = parsedTitle.get('season') + season = parsedTitle.get('season')[0] + elif parsedTitle.get('season'): + season = parsedTitle.get('season') if type(parsedTitle.get('episode')) == list: - longtitle += 'x' + str(parsedTitle.get('episode')[0]).zfill(2) + '-' + str(parsedTitle.get('episode')[-1]).zfill(2) - infolabels['episode'] = parsedTitle.get('episode')[0] + episode = parsedTitle.get('episode')[0] + second_episode = parsedTitle.get('episode')[1:] else: - longtitle += 'x' + str(parsedTitle.get('episode')).zfill(2) infolabels['episode'] = parsedTitle.get('episode') elif parsedTitle.get('season') and type(parsedTitle.get('season')) == list: - longtitle += s + config.get_localized_string(30140) + " " +str(parsedTitle.get('season')[0]) + '-' + str(parsedTitle.get('season')[-1]) + extraInfo = '{}: {}-{}'.format(config.get_localized_string(30140), parsedTitle.get('season')[0], parsedTitle.get('season')[-1]) elif parsedTitle.get('season'): - longtitle += s + config.get_localized_string(60027) % str(parsedTitle.get('season')) - infolabels['season'] = parsedTitle.get('season') + season = parsedTitle.get('season') if parsedTitle.get('episode_title'): - longtitle += s + parsedTitle.get('episode_title') - infolabels['episodeName'] = parsedTitle.get('episode_title') + extraInfo += parsedTitle.get('episode_title') except: import traceback logger.error(traceback.format_exc()) - longtitle = typo(longtitle, 'bold') - lang1, longtitle = scrapeLang(scraped, lang, longtitle) - longtitle += typo(quality, '_ [] color kod') if quality else '' - longtitle += typo(scraped['size'], '_ [] color kod') if scraped['size'] else '' - longtitle += typo(scraped['seed'] + ' SEEDS', '_ [] color kod') if scraped['seed'] else '' + if season: infolabels['season'] = int(season) + if episode: infolabels['episode'] = int(episode) + + lang1 = scrapeLang(scraped, lang) + AC = CT = '' if typeContentDict: @@ -368,29 +361,33 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t break else: AC = action - if (not scraped['title'] or scraped["title"] not in blacklist) and (search.lower() in longtitle.lower()): + if (not scraped['title'] or scraped["title"] not in blacklist) and (search.lower() in title.lower()): contentType = 'episode' if function == 'episodios' else CT if CT else item.contentType it = Item( - channel=item.channel, - action=AC if AC else action, - contentType=contentType, - title=longtitle, - fulltitle=item.fulltitle if function == 'episodios' else title, + channel = item.channel, + action = AC if AC else action, + contentType = contentType, + title = title, + fulltitle = item.fulltitle if function == 'episodios' else title, show=item.show if function == 'episodios' else title, - quality=quality, - url=scraped["url"] if scraped["url"] else item.url, - infoLabels=infolabels, - thumbnail=item.prevthumb if item.prevthumb else item.thumbnail if not scraped["thumb"] else scraped["thumb"], - args=item.args, - contentSerieName= title if 'movie' not in [contentType] and function != 'episodios' else item.contentSerieName, - contentTitle= title if 'movie' in [contentType] and function == 'peliculas' else item.contentTitle, - contentLanguage = lang1 if lang1 else item.contentLanguage, - contentSeason= infolabels.get('season', ''), + quality = quality, + url = scraped["url"] if scraped["url"] else item.url, + infoLabels = infolabels, + thumbnail = item.prevthumb if item.prevthumb else item.thumbnail if not scraped["thumb"] else scraped["thumb"], + args = item.args, + contentSerieName = title if 'movie' not in [contentType] and function != 'episodios' else item.contentSerieName, + contentTitle = title if 'movie' in [contentType] and function == 'peliculas' else item.contentTitle, + contentLanguage = lang1 if lang1 else item.contentLanguage if item.contentLanguage else 'ITA', + contentSeason = infolabels.get('season', ''), contentEpisodeNumber=infolabels.get('episode', ''), - news= item.news if item.news else '', + news = item.news if item.news else '', other = scraped['other'] if scraped['other'] else '', - grouped=group + grouped = group, + title2 = cleantitle(title2) if title2 else '', + episode2 = second_episode, + extraInfo = extraInfo ) + if scraped['episode'] and group and not item.grouped: # some adjustment for grouping feature it.action = function if it.action == 'findvideos': @@ -478,10 +475,10 @@ def scrape(func): typeContentDict, typeActionDict, blacklist, search, pag, function, lang, sceneTitle, group) for it in blockItemlist: if 'lang' in bl: - it.contentLanguage, it.title = scrapeLang(bl, it.contentLanguage, it.title) + it.contentLanguage = scrapeLang(bl, it.contentLanguage, it.title) if 'quality' in bl and bl['quality']: it.quality = bl['quality'].strip() - it.title = it.title + typo(bl['quality'].strip(), '_ [] color kod') + # it.title = it.title + typo(bl['quality'].strip(), '_ [] color kod') itemlist.extend(blockItemlist) matches.extend(blockMatches) elif patron: @@ -546,13 +543,13 @@ def scrape(func): if patronNext and inspect.stack()[1][3] not in ['newest'] and len(inspect.stack()) > 2 and inspect.stack()[2][3] not in ['get_channel_results']: nextPage(itemlist, item, data, patronNext, function) - for it in itemlist: - if it.contentEpisodeNumber and it.contentSeason: - it.title = '[B]{:d}x{:02d} - {}[/B]'.format(it.contentSeason, it.contentEpisodeNumber, it.infoLabels['title'] if it.infoLabels['title'] else it.fulltitle) - if it.contentLanguage: - it.title += typo(it.contentLanguage, '_ [] color kod') - if it.quality: - it.title += typo(it.quality, '_ [] color kod') + # for it in itemlist: + # if it.contentEpisodeNumber and it.contentSeason: + # it.title = '[B]{:d}x{:02d} - {}[/B]'.format(it.contentSeason, it.contentEpisodeNumber, it.infoLabels['title'] if it.infoLabels['title'] else it.fulltitle) + # if it.contentLanguage: + # it.title += typo(it.contentLanguage, '_ [] color kod') + # if it.quality: + # it.title += typo(it.quality, '_ [] color kod') # next page for pagination if pagination and len(matches) > pag * pagination and not search: @@ -1207,15 +1204,16 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru # logger.debug(videoitem) if videoitem.video_urls or srv_param.get('active', False): # dbg() - item.title = typo(item.contentTitle.strip(), 'bold') if item.contentType == 'movie' and item.contentTitle or (config.get_localized_string(30161) in item.fulltitle) else item.fulltitle + item.title = item.contentTitle.strip() if item.contentType == 'movie' and item.contentTitle or (config.get_localized_string(30161) in item.fulltitle) else item.fulltitle 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' - videoitem.title = (item.title if item.channel not in ['url'] else '')\ - + (typo(videoitem.title, '_ color kod [] bold') if videoitem.title else "")\ - + (typo(videoitem.quality, '_ color kod []') if videoitem.quality else "")\ - + (typo(videoitem.contentLanguage, '_ color kod []') if videoitem.contentLanguage else "")\ - + (typo(videoitem.extraInfo, '_ color kod []') if videoitem.extraInfo else "") + videoitem.title = item.title + # videoitem.title = (item.title if item.channel not in ['url'] else '')\ + # + (typo(videoitem.title, '_ color kod [] bold') if videoitem.title else "")\ + # + (typo(videoitem.quality, '_ color kod []') if videoitem.quality else "")\ + # + (typo(videoitem.contentLanguage, '_ color kod []') if videoitem.contentLanguage else "")\ + # + (typo(videoitem.extraInfo, '_ color kod []') if videoitem.extraInfo else "") videoitem.plot = typo(videoitem.title, 'bold') + (typo(quality, '_ [] bold') if quality else '') videoitem.channel = item.channel videoitem.fulltitle = item.fulltitle diff --git a/core/videolibrarytools.py b/core/videolibrarytools.py index 7973a986..6d6bb376 100644 --- a/core/videolibrarytools.py +++ b/core/videolibrarytools.py @@ -471,7 +471,7 @@ def save_tvshow(item, episodelist, silent=False): if not head_nfo: return 0, 0, -1, '' # support.dbg() extra_info = get_fanart_tv(item) - if not item.infoLabels.get('posters'): item.infoLabels['posters'] = [] + if not item.infoLabels.get('posters'):item.infoLabels['posters'] = [] item.infoLabels['posters'] += extra_info['poster'].get('all',[]) if not item.infoLabels.get('fanarts'): item.infoLabels['fanarts'] = [] item.infoLabels['fanarts'] += extra_info['fanart'] @@ -481,7 +481,7 @@ def save_tvshow(item, episodelist, silent=False): item.infoLabels['cleararts'] += extra_info['clearart'] if not item.infoLabels.get('landscapes'): item.infoLabels['landscapes'] = [] item.infoLabels['landscapes'] += extra_info['landscape'].get('all',[]) - if not item.infoLabels.get('banners'): item.infoLabels['banners'] = [] + if not item.infoLabels.get('banners'):item.infoLabels['banners'] = [] item.infoLabels['banners'] += extra_info['banner'].get('all',[]) @@ -498,10 +498,10 @@ def save_tvshow(item, episodelist, silent=False): if not tvshow_item.videolibrary_id: tvshow_item.videolibrary_id = _id if not tvshow_item.thumbnail: tvshow_item.thumbnail = item.infoLabels['thumbnail'] if not tvshow_item.fanart: tvshow_item.fanart = item.infoLabels['fanart'] - if not tvshow_item.landscape: tvshow_item.landscape = item.infoLabels['landscapes'][0] if item.infoLabels['landscapes'] else item.infoLabels['fanart'] - if not tvshow_item.banner and item.infoLabels['banners']: tvshow_item.clearart = item.infoLabels['banners'][0] - if not tvshow_item.clearart and item.infoLabels['cleararts']: tvshow_item.clearart = item.infoLabels['cleararts'][0] - if not tvshow_item.clearlogo and item.infoLabels['clearlogos']: tvshow_item.clearlogo = item.infoLabels['clearlogos'][0] + if not tvshow_item.infoLabels.get('landscape'): tvshow_item.infoLabels['landscape'] = item.infoLabels['landscapes'][0] if item.infoLabels['landscapes'] else item.infoLabels['fanart'] + if not tvshow_item.infoLabels.get('banner') and item.infoLabels['banners']: tvshow_item.infoLabels['banner'] = item.infoLabels['banners'][0] + if not tvshow_item.infoLabels.get('clearart') and item.infoLabels['cleararts']: tvshow_item.infoLabels['clearart'] = item.infoLabels['cleararts'][0] + if not tvshow_item.infoLabels.get('clearlogo') and item.infoLabels['clearlogos']: tvshow_item.infoLabels['clearlogo'] = item.infoLabels['clearlogos'][0] if not tvshow_item.base_name: tvshow_item.base_name = base_name if tvshow_item.active == '': tvshow_item.active = True if not tvshow_item.prefered_lang: tvshow_item.prefered_lang = '' @@ -555,13 +555,13 @@ def save_episodes(item, episodelist, extra_info, host, local_files, silent=False episode = None season_episode = None - season_episode = scrapertools.get_season_and_episode(e.title) - if season_episode: + if e.contentSeason and e.contentEpisodeNumber: + season_episode = '{}x{:02d}'.format(e.contentSeason, e.contentEpisodeNumber) strm_path = filetools.join(item.base_name, "{}.strm".format(season_episode)) - e.contentSeason = int(season_episode.split('x')[0]) - e.contentEpisodeNumber = int(season_episode.split('x')[1]) + # e.contentSeason = int(season_episode.split('x')[0]) + # e.contentEpisodeNumber = int(season_episode.split('x')[1]) if item.infoLabels.get('imdb_id'): e.infoLabels['imdb_id'] = item.infoLabels['imdb_id'] if item.infoLabels.get('tmdb_id'): e.infoLabels['tmdb_id'] = item.infoLabels['tmdb_id'] if item.infoLabels.get('tvdb_id'): e.infoLabels['tvdb_id'] = item.infoLabels['tvdb_id'] @@ -581,7 +581,7 @@ def save_episodes(item, episodelist, extra_info, host, local_files, silent=False videolibrary_id = item.videolibrary_id, thumbnail = e.infoLabels.get('poster_path') if e.infoLabels.get('poster_path') else item.thumbnail, fanart = e.infoLabels.get('poster_path') if e.infoLabels.get('poster_path') else item.fanart, - title = '{}. {}'.format(e.contentEpisodeNumber, e.infoLabels['title'])) + title = e.infoLabels['title']) episode = episodes.get(season_episode, {}) @@ -879,7 +879,7 @@ def add_tvshow(item, channel=None): it = item.clone() itemlist = getattr(channel, it.action)(it) item.host = channel.host - if itemlist and not scrapertools.find_single_match(itemlist[0].title, r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)'): + if itemlist: from platformcode.autorenumber import start, check if not check(item): action = item.action diff --git a/platformcode/autorenumber.py b/platformcode/autorenumber.py index 7e44a2cc..f97b8d0c 100644 --- a/platformcode/autorenumber.py +++ b/platformcode/autorenumber.py @@ -69,7 +69,7 @@ def b64(json, mode = 'encode'): def find_episodes(item): logger.debug() - ch = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel]) + ch = __import__('channels.' + item.channel, fromlist=["channels.{}".format(item.channel)]) itemlist = ch.episodios(item) return itemlist @@ -111,14 +111,14 @@ class autorenumber(): self.renumberdict = load(item) self.auto = config.get_setting('autorenumber', item.channel) self.title = self.item.fulltitle.strip() - if match(self.itemlist[0].title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match: + if item.contentSeason: item.exit = True return elif (self.item.channel in self.item.channel_prefs and RENUMBER in self.item.channel_prefs[item.channel] and self.title not in self.renumberdict) or self.item.renumber: from core.videolibrarytools import check_renumber_options - from specials.videolibrary import update_videolibrary + # from specials.videolibrary import update_videolibrary check_renumber_options(self.item) - update_videolibrary(self.item) + # update_videolibrary(self.item) self.series = self.renumberdict.get(self.title,{}) self.id = self.series.get(ID, 0) @@ -177,13 +177,18 @@ class autorenumber(): def renumber(self): def sub_thread(item): - if not match(item.title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match: - number = match(item.title, patron=r'(\d+)').match.lstrip('0') + if not item.contentSeason: + number = str(item.contentEpisodeNumber) if number: if not number in self.episodes: self.makelist() - item.title = '{} - {}'.format(typo(self.episodes[number], 'bold'), item.title) - item.contentSeason = int(self.episodes[number].split('x')[0]) - item.contentEpisodeNumber = int(self.episodes[number].split('x')[1]) + if number in self.episodes: + item.contentSeason = int(self.episodes[number].split('x')[0]) + item.contentEpisodeNumber = int(self.episodes[number].split('x')[1]) + + # support.dbg() + # for i in self.itemlist: + # sub_thread(i) + if not self.item.setrenumber and self.itemlist: with futures.ThreadPoolExecutor() as executor: renumber_list = [executor.submit(sub_thread, item,) for item in self.itemlist] @@ -244,9 +249,9 @@ class autorenumber(): count = 0 if self.epdict: for item in itemlist: - if not match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match: + if not item.contentSeason: # Otiene Numerazione Episodi - scraped_ep = match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'(\d+)').match + scraped_ep = item.contentEpisodeNumber if scraped_ep: episode = int(scraped_ep) if episode == 0: @@ -325,7 +330,7 @@ def SelectreNumeration(opt, itemlist, manual=False): ep = '1' position = 0 for i, item in enumerate(self.itemlist): - title = match(item.title, patron=r'(\d+)').match.lstrip('0') + title = str(item.contentEpisodeNumber) it = xbmcgui.ListItem(title) if int(title) <= len(self.episodes): se, ep = self.episodes[title].split('x') @@ -345,10 +350,14 @@ def SelectreNumeration(opt, itemlist, manual=False): # MAIN / SPECIALS else: for item in self.itemlist: - if not match(item.title, patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match: - title = match(item.title, patron=r'(\d+)').match.lstrip('0') + if not item.contentSeason: + title = str(item.contentEpisodeNumber) it = xbmcgui.ListItem(title) - self.items.append(it) + if title not in self.specials.keys(): + self.items.append(it) + else: + self.selected.append(it) + it.setProperty('title', title) self.getControl(POSTER).setImage(thumb) self.getControl(MPOSTER).setImage(thumb) @@ -357,6 +366,7 @@ def SelectreNumeration(opt, itemlist, manual=False): self.getControl(MBACKGROUND).setImage(fanart) self.getControl(INFO).setLabel(typo(config.get_localized_string(70824) + self.title, 'bold')) self.getControl(LIST).addItems(self.items) + self.getControl(SELECTED).addItems(self.selected) if self.sp: self.getControl(SPECIALS).setVisible(True) @@ -492,7 +502,7 @@ def SelectreNumeration(opt, itemlist, manual=False): ep = str(int(ep) + 1) item.setProperties({'season': se, "episode": ep}) items.append(item) - self.seasons[item.getLabel()] = '%sx%s' % (se, ep) + self.seasons[item.getLabel()] = '{}x{}'.format(se, ep) self.items = items else: self.makerenumber() @@ -520,7 +530,7 @@ def SelectreNumeration(opt, itemlist, manual=False): p1 = self.getControl(SELECTED).getSelectedPosition() if control_id in [LIST]: item = self.getControl(LIST).getSelectedItem() - it = xbmcgui.ListItem(str(len(self.selected) + len(self.specials) + 1)) + it = xbmcgui.ListItem(str(len(self.selected) + 1)) it.setProperty('title', item.getLabel()) self.selected.append(it) index = self.getControl(SELECTED).getSelectedPosition() @@ -541,7 +551,6 @@ def SelectreNumeration(opt, itemlist, manual=False): self.selected[p1], self.selected[p2] = self.selected[p2], self.selected[p1] for i, it in enumerate(self.selected): it.setLabel(str(i + 1)) - break self.getControl(SELECTED).reset() self.getControl(SELECTED).addItems(self.selected) self.getControl(SELECTED).selectItem(p2) @@ -552,7 +561,6 @@ def SelectreNumeration(opt, itemlist, manual=False): self.selected[p1], self.selected[p2] = self.selected[p2], self.selected[p1] for i, it in enumerate(self.selected): it.setLabel(str(i + 1)) - break self.getControl(SELECTED).reset() self.getControl(SELECTED).addItems(self.selected) self.getControl(SELECTED).selectItem(p2) @@ -579,19 +587,21 @@ def SelectreNumeration(opt, itemlist, manual=False): # RELOAD SPECIALS if control_id in [SELECTED]: epnumber = platformtools.dialog_numeric(0, config.get_localized_string(60386)) - it = self.getControl(SELECTED).getSelectedItem() - it.setLabel(str(epnumber)) - self.selected.sort(key=lambda it: int(it.getLabel())) - for i, it in enumerate(self.selected): - if it.getLabel() == epnumber: pos = i + if epnumber: + it = self.getControl(SELECTED).getSelectedItem() + it.setLabel(str(epnumber)) self.selected.sort(key=lambda it: int(it.getLabel())) - self.getControl(SELECTED).reset() - self.getControl(SELECTED).addItems(self.selected) - self.getControl(SELECTED).selectItem(pos) - break + for i, it in enumerate(self.selected): + if it.getLabel() == epnumber: pos = i + self.selected.sort(key=lambda it: int(it.getLabel())) + self.getControl(SELECTED).reset() + self.getControl(SELECTED).addItems(self.selected) + self.getControl(SELECTED).selectItem(pos) + break if len(self.selected) > 0: self.getControl(SPECIALCOMMANDS).setVisible(True) else: + self.setFocusId(LIST) self.getControl(SPECIALCOMMANDS).setVisible(False) ## MANUAL SECTION @@ -619,8 +629,10 @@ def SelectreNumeration(opt, itemlist, manual=False): self.getControl(MLIST).selectItem(pos) # OK if control_id in [OK]: + if not self.selected: + self.specials = {} for it in self.selected: - self.specials[int(it.getProperty('title'))] = '0x' + it.getLabel() + self.specials[it.getProperty('title')] = '0x' + it.getLabel() self.close() # CLOSE elif control_id in [CLOSE]: @@ -645,7 +657,7 @@ def SelectreNumeration(opt, itemlist, manual=False): if i > pos: prevEpisode += 1 item.setProperties({'season': self.season, 'episode': prevEpisode}) items.append(item) - self.seasons[item.getLabel()] = '%sx%s' % (item.getProperty('season'), item.getProperty('episode')) + self.seasons[item.getLabel()] = '{}x{}'.format(item.getProperty('season'), item.getProperty('episode')) self.items = items logger.debug('SELF', self.seasons) @@ -662,7 +674,7 @@ def SelectreNumeration(opt, itemlist, manual=False): if season in seasonlist: if season not in self.episodes: self.episodes[season] = [] - item = xbmcgui.ListItem('%s - Ep. %s' % (value, ep)) + item = xbmcgui.ListItem('{} - Ep. {}'.format(value, ep)) item.setProperty('episode', ep) self.episodes[season].append(item) logger.log('EPISODES', self.episodes[season]) diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 48a27eb6..23c500b0 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -317,6 +317,7 @@ 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 httptools _handle = int(sys.argv[1]) default_fanart = config.get_fanart() @@ -358,7 +359,30 @@ def render_items(itemlist, parent_item): # break icon_image = "DefaultFolder.png" if item.folder else "DefaultVideo.png" - listitem = xbmcgui.ListItem(item.title) + + title = item.title + episode = '' + + if type(item.contentSeason) == int and type(item.contentEpisodeNumber) == int and not parent_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(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 not config.get_setting('format_title') and title[:1] not in ['[', '•']: + server = typo(item.server, '_ []') 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 '' + + + title = '[B]{}{}[/B]{}{}{}'.format(title, server, quality, lang, extra) + + listitem = xbmcgui.ListItem(title) art = {'icon': icon_image, 'thumb': item.thumbnail, 'poster': item.thumbnail, 'fanart': item.fanart if item.fanart else default_fanart} if item.infoLabels.get('landscape'): art['landscape'] = item.infoLabels['landscape'] if item.infoLabels.get('clearlogo'): art['clearlogo'] = item.infoLabels['clearlogo'] diff --git a/specials/videolibrary.py b/specials/videolibrary.py index c5db9a95..3c816f1a 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -279,7 +279,7 @@ def get_episodes(item): if it.contentSeason == item.contentSeason or item.all: if config.get_setting('no_pile_on_seasons', 'videolibrary') == 2 or item.all: - it.title = '{}x{}'.format(it.contentSeason, it.title) + item.onlyep = True it = get_host(it) it.window = True if item.window_type == 1 or (config.get_setting("window_type") == 0) else False if it.window: @@ -934,24 +934,27 @@ def add_download_items(item, itemlist): url=item.url, action='save_download', from_action='findvideos', - contentTitle=item.contentTitle, + contentTitle=config.get_localized_string(60355), path=item.path, thumbnail=thumb('downloads'), parent=item.tourl()) if item.action == 'findvideos': if item.contentType != 'movie': downloadItem.title = '{} {}'.format(typo(config.get_localized_string(60356), 'color kod bold'), item.title) + downloadItem.contentTitle = '{} {}'.format(config.get_localized_string(60356), item.title) else: # film downloadItem.title = typo(config.get_localized_string(60354), 'color kod bold') + downloadItem.title = config.get_localized_string(60354) downloadItem.downloadItemlist = [i.tourl() for i in itemlist] itemlist.append(downloadItem) else: if item.contentSeason: # season downloadItem.title = typo(config.get_localized_string(60357), 'color kod bold') + downloadItem.title = config.get_localized_string(60357) itemlist.append(downloadItem) else: # tvshow + not seen itemlist.append(downloadItem) - itemlist.append(downloadItem.clone(title=typo(config.get_localized_string(60003), 'color kod bold'), unseen=True)) + itemlist.append(downloadItem.clone(title=typo(config.get_localized_string(60003), 'color kod bold'), contentTitle=config.get_localized_string(60003), unseen=True)) #-------------- DELETE --------------