From 5e49b8b6e1042ce2f2eaba67e8e61187727e6faa Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 27 May 2018 19:54:52 +0200 Subject: [PATCH] Add files via upload --- plugin.video.alfa/core/scraper.py | 1 + plugin.video.alfa/core/scrapertools.py | 6 +++--- plugin.video.alfa/core/videolibrarytools.py | 20 ++++++++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/plugin.video.alfa/core/scraper.py b/plugin.video.alfa/core/scraper.py index 1dcef673..897270f3 100755 --- a/plugin.video.alfa/core/scraper.py +++ b/plugin.video.alfa/core/scraper.py @@ -263,6 +263,7 @@ def get_nfo(item): def sort_episode_list(episodelist): + episodelist.sort(key=lambda e: e.title, reverse=True) scraper_actual = ['tmdb', 'tvdb'][config.get_setting("scraper_tvshows", "videolibrary")] if scraper_actual == "tmdb": diff --git a/plugin.video.alfa/core/scrapertools.py b/plugin.video.alfa/core/scrapertools.py index 5682ae82..faa20dde 100755 --- a/plugin.video.alfa/core/scrapertools.py +++ b/plugin.video.alfa/core/scrapertools.py @@ -458,14 +458,14 @@ def get_season_and_episode(title): """ filename = "" - patrons = ["(\d+)x(\d+)", "(\d+)×(\d+)", "(?:s|t)(\d+)e(\d+)", - "(?:season|temp\w*)\s*(\d+)\s*(?:capitulo|epi\w*)\s*(\d+)"] + patrons = ["(\d+)\s*[x-]\s*(\d+)", "(\d+)\s*×\s*(\d+)", "(?:s|t)(\d+)e(\d+)", + "(?:season|temp\w*)\s*(\d+)\s*(?:capitulo|epi|episode\w*)\s*(\d+)"] for patron in patrons: try: matches = re.compile(patron, re.I).search(title) if matches: - filename = matches.group(1) + "x" + matches.group(2).zfill(2) + filename = matches.group(1).lstrip('0') + "x" + matches.group(2).zfill(2) break except: pass diff --git a/plugin.video.alfa/core/videolibrarytools.py b/plugin.video.alfa/core/videolibrarytools.py index 2fcae901..eae0b8e7 100644 --- a/plugin.video.alfa/core/videolibrarytools.py +++ b/plugin.video.alfa/core/videolibrarytools.py @@ -123,7 +123,7 @@ def save_movie(item): else: base_name = item.contentTitle - base_name = unicode(filetools.validate_path(base_name.replace('/', '-')), "utf8").lower().encode("utf8") + base_name = unicode(filetools.validate_path(base_name.replace('/', '-')), "utf8").encode("utf8") for raiz, subcarpetas, ficheros in filetools.walk(MOVIES_PATH): for c in subcarpetas: @@ -244,7 +244,7 @@ def save_tvshow(item, episodelist): else: base_name = item.contentSerieName - base_name = unicode(filetools.validate_path(base_name.replace('/', '-')), "utf8").lower().encode("utf8") + base_name = unicode(filetools.validate_path(base_name.replace('/', '-')), "utf8").encode("utf8") for raiz, subcarpetas, ficheros in filetools.walk(TVSHOWS_PATH): for c in subcarpetas: @@ -348,6 +348,15 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): raiz, carpetas_series, ficheros = filetools.walk(path).next() ficheros = [filetools.join(path, f) for f in ficheros] + nostrm_episodelist = [] + for root, folders, files in filetools.walk(path): + for file in files: + season_episode = scrapertools.get_season_and_episode(file) + if season_episode == "" or filetools.exists(filetools.join(path, "%s.strm" % season_episode)): + continue + nostrm_episodelist.append(season_episode) + nostrm_episodelist = sorted(set(nostrm_episodelist)) + # Silent es para no mostrar progreso (para videolibrary_service) if not silent: # progress dialog @@ -356,7 +365,12 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): new_episodelist = [] # Obtenemos el numero de temporada y episodio y descartamos los q no lo sean + tags = [] + if config.get_setting("enable_filter", "videolibrary"): + tags = [x.strip() for x in config.get_setting("filters", "videolibrary").lower().split(",")] for e in episodelist: + if tags != [] and tags != None and any(tag in e.title.lower() for tag in tags): + continue try: season_episode = scrapertools.get_season_and_episode(e.title) @@ -383,6 +397,8 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): nfo_path = filetools.join(path, "%s.nfo" % season_episode) json_path = filetools.join(path, ("%s [%s].json" % (season_episode, e.channel)).lower()) + if season_episode in nostrm_episodelist: + continue strm_exists = strm_path in ficheros nfo_exists = nfo_path in ficheros json_exists = json_path in ficheros