From 28a70669afb14e9d842190f0e7a7c9a6ee6c9509 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Thu, 21 May 2020 20:26:56 +0200 Subject: [PATCH] Trakt: segna come visti film ed episodi --- core/support.py | 14 +++++++++++--- core/trakt_tools.py | 7 ++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/support.py b/core/support.py index e562ba53..d6090399 100755 --- a/core/support.py +++ b/core/support.py @@ -217,8 +217,12 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t if scraped['season']: stagione = scraped['season'] + item.infoLabels['season'] = int(scraped['season']) + item.infoLabels['episode'] = int(scraped['episode']) episode = str(int(scraped['season'])) +'x'+ str(int(scraped['episode'])).zfill(2) elif item.season: + item.infoLabels['season'] = int(item.season) + item.infoLabels['episode'] = int(scrapertools.find_single_match(scraped['episode'], r'(\d+)')) episode = item.season +'x'+ scraped['episode'] elif item.contentType == 'tvshow' and (scraped['episode'] == '' and scraped['season'] == '' and stagione == ''): item.news = 'season_completed' @@ -228,6 +232,8 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t if 'x' in episode: ep = episode.split('x') episode = str(int(ep[0])).zfill(1) + 'x' + str(int(ep[1])).zfill(2) + item.infoLabels['season'] = int(ep[0]) + item.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) @@ -243,14 +249,16 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t if item.infoLabels["title"] == scraped["title"]: infolabels = item.infoLabels else: - infolabels = {} + if function == 'episodios': + infolabels = item.infoLabels + else: + infolabels = {} if scraped['year']: infolabels['year'] = scraped['year'] if scraped["plot"]: infolabels['plot'] = plot if scraped['duration']: - matches = scrapertools.find_multiple_matches(scraped['duration'], - r'([0-9])\s*?(?:[hH]|:|\.|,|\\|\/|\||\s)\s*?([0-9]+)') + matches = scrapertools.find_multiple_matches(scraped['duration'],r'([0-9])\s*?(?:[hH]|:|\.|,|\\|\/|\||\s)\s*?([0-9]+)') for h, m in matches: scraped['duration'] = int(h) * 60 + int(m) if not matches: diff --git a/core/trakt_tools.py b/core/trakt_tools.py index ad24130e..a29a7432 100644 --- a/core/trakt_tools.py +++ b/core/trakt_tools.py @@ -196,10 +196,7 @@ def get_trakt_watched(id_type, mediatype, update=False): def trakt_check(itemlist): - from core.support import typo id_result = '' - # check = u'\u221a' - check = typo(u'\u221a','color kod bold')+' ' synced = False try: for item in itemlist: @@ -221,7 +218,7 @@ def trakt_check(itemlist): id_result = get_trakt_watched(id_type, mediatype) if info['mediatype'] == 'movie': if info[id_type + '_id'] in id_result: - item.title = check + item.title + item.infoLabels['playcount'] = 1 elif info['mediatype'] == 'episode': if info[id_type + '_id'] in id_result: @@ -236,7 +233,7 @@ def trakt_check(itemlist): season_watched = id_result[id][season] if episode in season_watched: - item.title = check + item.title + item.infoLabels['playcount'] = 1 else: break except: