diff --git a/core/videolibrarytools.py b/core/videolibrarytools.py index 5d792721..3759c514 100644 --- a/core/videolibrarytools.py +++ b/core/videolibrarytools.py @@ -566,8 +566,6 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): @return: the number of failed episodes """ logger.info() - update = False - exist = False episodelist = filter_list(episodelist, serie.action, path) # No episode list, nothing to save if not len(episodelist): @@ -577,6 +575,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): # process local episodes local_episodes_path = '' local_episodelist = [] + update = False nfo_path = filetools.join(path, "tvshow.nfo") head_nfo, item_nfo = read_nfo(nfo_path) if item_nfo.update_last: @@ -590,9 +589,9 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): filetools.write(nfo_path, head_nfo + item_nfo.tojson()) if local_episodes_path: - from platformcode.xbmc_videolibrary import check_if_exist, clean - if check_if_exist(local_episodes_path): - exist = True + from platformcode.xbmc_videolibrary import check_db, clean + # check if the local episodes are in the Kodi video library + if check_db(local_episodes_path): local_episodelist += get_local_content(local_episodes_path) clean_list = [] for f in filetools.listdir(path): @@ -609,7 +608,6 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): clean_list.append(clean_path) clean_list.append(clean_path.replace('/','\\')) - # from core.support import dbg;dbg() if clean_list: clean(clean_list) update = True @@ -630,7 +628,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): item_nfo.local_episodes_list = sorted(local_episodelist) filetools.write(nfo_path, head_nfo + item_nfo.tojson()) - + # the local episodes are not in the Kodi video library else: process_local_episodes(local_episodes_path, path) @@ -713,12 +711,13 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): logger.info("There is no episode list, we go out without creating strm") return 0, 0, 0 + local_episodelist += get_local_content(path) + # fix float because division is done poorly in python 2.x try: t = float(100) / len(new_episodelist) except: t = 0 - local_episodelist += get_local_content(path) for i, e in enumerate(scraper.sort_episode_list(new_episodelist)): if not silent: p_dialog.update(int(math.ceil((i + 1) * t)), config.get_localized_string(60064), e.title) @@ -874,6 +873,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): # ... if it was correct we update the Kodi video library if config.is_xbmc() and config.get_setting("videolibrary_kodi") and not silent: update = True + if update: from platformcode import xbmc_videolibrary xbmc_videolibrary.update() @@ -952,6 +952,7 @@ def process_local_episodes(local_episodes_path, path): filetools.write(nfo_path, head_nfo + item_nfo.tojson()) + def get_local_content(path): logger.info() @@ -966,6 +967,7 @@ def get_local_content(path): return local_episodelist + def add_movie(item): """ Keep a movie at the movie library. The movie can be a link within a channel or a previously downloaded video. diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index be0dfbaa..299fc60b 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -1000,7 +1000,8 @@ def clean(path_list=[]): xbmc.sleep(1000) progress.close() -def check_if_exist(path): + +def check_db(path): if '\\' in path: sep = '\\' else: sep = '/' if path.endswith(sep): path = path[:-len(sep)] @@ -1013,6 +1014,7 @@ def check_if_exist(path): ret = True return ret + def execute_sql_kodi(sql): """ Run sql query against kodi database