From 48bc1f8a2f33e3a8b4a401f701749e7c388e47be Mon Sep 17 00:00:00 2001 From: Alhaziel Date: Mon, 30 Sep 2019 12:41:05 +0200 Subject: [PATCH] Fix Autorenumber con paginazione in lista episodi nota: Riscrivere autorenumber per migliorarne le prestazioni --- core/support.py | 5 ++- specials/autorenumber.py | 69 +++++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/core/support.py b/core/support.py index dfdeddc0..c20939f6 100644 --- a/core/support.py +++ b/core/support.py @@ -323,6 +323,7 @@ def scrape(func): itemlist = [] args = func(*args) + log('STACK= ',inspect.stack()[1][3]) item = args['item'] @@ -344,7 +345,7 @@ def scrape(func): typeActionDict = args['type_action_dict'] if 'type_action_dict' in args else {} typeContentDict = args['type_content_dict'] if 'type_content_dict' in args else {} debug = args['debug'] if 'debug' in args else False - if 'pagination' in args: pagination = args['pagination'] if args['pagination'] else 20 + if 'pagination' in args and inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes']: pagination = args['pagination'] if args['pagination'] else 20 else: pagination = '' lang = args['deflang'] if 'deflang' in args else '' pag = item.page if item.page else 1 # pagination @@ -392,6 +393,8 @@ def scrape(func): action = item.action, contentType=item.contentType, title=typo(config.get_localized_string(30992), 'color kod bold'), + fulltitle= item.fulltitle, + show= item.show, url=item.url, args=item.args, page=pag + 1, diff --git a/specials/autorenumber.py b/specials/autorenumber.py index 62482c12..34120da6 100644 --- a/specials/autorenumber.py +++ b/specials/autorenumber.py @@ -238,7 +238,7 @@ def renumber(itemlist, item='', typography=''): item.context = context(exist) def renumeration (itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE, TITLE): - log() + log('EPISODE= ', EPISODE) # Se ID รจ 0 salta la rinumerazione if ID == '0': return itemlist @@ -247,24 +247,26 @@ def renumeration (itemlist, item, typography, dict_series, ID, SEASON, EPISODE, elif SEASON == '0': EpisodeDict = {} for item in itemlist: - number = scrapertoolsV2.find_single_match(item.title, r'\d+') - item.title = typo('0x' + number + ' - ', typography) + item.title + if config.get_localized_string(30992) not in item.title: + number = scrapertoolsV2.find_single_match(item.title, r'\d+') + item.title = typo('0x' + number + ' - ', typography) + item.title # Usa la lista degli Episodi se esiste nel Json elif EPISODE: EpisodeDict = json.loads(base64.b64decode(EPISODE)) + log('EPISODE DICT= ', EpisodeDict) # Controlla che la lista egli Episodi sia della stessa lunghezza di Itemlist if EpisodeDict == 'none': return error(itemlist) - if len(EpisodeDict) >= len(itemlist): + if len(EpisodeDict) >= len(itemlist) and EpisodeDict.has_key(scrapertoolsV2.find_single_match(itemlist[0].title, r'\d+')): for item in itemlist: - number = scrapertoolsV2.find_single_match(item.title, r'\d+') - log('TIPO NUMBER= ', type(number)) - number = int(number) - item.title = typo(EpisodeDict[str(number)] + ' - ', typography) + item.title + if config.get_localized_string(30992) not in item.title: + number = scrapertoolsV2.find_single_match(item.title, r'\d+') + number = int(number) # if number !='0': number.lstrip('0') + item.title = typo(EpisodeDict[str(number)] + ' - ', typography) + item.title else: make_list(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE, TITLE) @@ -276,7 +278,10 @@ def make_list(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE log() page = 1 EpList = [] - EpisodeDict = {} + if EPISODE: + EpisodeDict = json.loads(base64.b64decode(EPISODE)) + else: + EpisodeDict = {} exist = True item.infoLabels['tvdb_id'] = ID tvdb.set_infoLabels_item(item) @@ -329,33 +334,33 @@ def make_list(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE addiction = 0 for item in itemlist: # Otiene Numerazione Episodi - episode = int(scrapertoolsV2.find_single_match(item.title, r'\d+')) - log('EPISODE= ',episode) - number = episode + FirstOfSeason - addiction - count = number + addiction - # find = episode + FirstOfSeason - # log('FIND= ',find, ' ',str(episode) + ' ' + str(FirstOfSeason)) - # Crea Dizionario Episodi + if config.get_localized_string(30992) not in item.title: + episode = int(scrapertoolsV2.find_single_match(item.title, r'\d+')) + log('EPISODE= ',episode) + number = episode + FirstOfSeason - addiction + count = number + addiction + # find = episode + FirstOfSeason + # log('FIND= ',find, ' ',str(episode) + ' ' + str(FirstOfSeason)) + # Crea Dizionario Episodi - # log(episode, ' ', number, ' ', count) - if episode == 0: - EpisodeDict[str(episode)] = str(complete[regular[FirstOfSeason+1][2]][0]) - elif addiction < len(SPECIAL): - if episode in SPECIAL: - season = complete[regular[count][2]][0] - EpisodeDict[str(episode)] = str(complete[regular[count][2]][0]) if season.startswith( '0' ) else '0x' + platformtools.dialog_numeric(0, item.title + '?', '') - addiction = addiction + 1 - else: + if episode == 0: + EpisodeDict[str(episode)] = str(complete[regular[FirstOfSeason+1][2]][0]) + elif addiction < len(SPECIAL): + if episode in SPECIAL: + season = complete[regular[count][2]][0] + EpisodeDict[str(episode)] = str(complete[regular[count][2]][0]) if season.startswith( '0' ) else '0x' + platformtools.dialog_numeric(0, item.title + '?', '') + addiction = addiction + 1 + else: + EpisodeDict[str(episode)] = str(regular[number][0]) + elif number <= len(regular): EpisodeDict[str(episode)] = str(regular[number][0]) - elif number <= len(regular): - EpisodeDict[str(episode)] = str(regular[number][0]) - else: - try: EpisodeDict[str(episode)] = str(complete[regular[number+2][2]][0]) - except: EpisodeDict[str(episode)] = '0x0' + else: + try: EpisodeDict[str(episode)] = str(complete[regular[number+2][2]][0]) + except: EpisodeDict[str(episode)] = '0x0' - # Aggiunge numerazione agli Episodi + # Aggiunge numerazione agli Episodi - item.title = typo(EpisodeDict[str(episode)] + ' - ', typography) + item.title + item.title = typo(EpisodeDict[str(episode)] + ' - ', typography) + item.title # Scrive Dizionario Episodi sul json EpisodeDict = base64.b64encode(json.dumps(EpisodeDict))