diff --git a/platformcode/config.py b/platformcode/config.py index 934da804..68761974 100644 --- a/platformcode/config.py +++ b/platformcode/config.py @@ -229,9 +229,8 @@ def open_settings(): from specials import videolibrary from platformcode import xbmc_videolibrary - if settings_pre.get('downloadpath', None) != settings_post.get('downloadpath', None) and \ - is_xbmc() and get_setting("videolibrary_kodi"): - xbmc_videolibrary.update_sources(settings_pre.get('downloadpath', None), settings_post.get('downloadpath', None)) + if settings_pre.get('downloadpath', None) != settings_post.get('downloadpath', None): + xbmc_videolibrary.update_sources(settings_post.get('downloadpath', None), settings_pre.get('downloadpath', None)) # si se ha cambiado la ruta de la videoteca llamamos a comprobar directorios para que lo cree y pregunte # automaticamente si configurar la videoteca diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index 5ff3f49e..5377e848 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -884,6 +884,9 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh p += 5 progress.update(p, config.get_localized_string(20000), config.get_localized_string(80013)) + progress.update(100) + xbmc.sleep(1000) + progress.close() xbmc.executebuiltin('XBMC.ReloadSkin()') @@ -961,6 +964,7 @@ def clean_db(): sql = 'DELETE from episode WHERE idEpisode=%s' % idEpisode nun_records, records = execute_sql_kodi(sql) progress.update(100) + xbmc.sleep(1000) progress.close() xbmc.executebuiltin('XBMC.ReloadSkin()') @@ -1030,112 +1034,52 @@ def execute_sql_kodi(sql): return nun_records, records -def add_sources(path): +def update_sources(new='', old=''): logger.info() + if new == old: return True + try: SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml") - - if os.path.exists(SOURCES_PATH): + if filetools.isfile(SOURCES_PATH): xmldoc = minidom.parse(SOURCES_PATH) else: - # Crear documento xmldoc = minidom.Document() - nodo_sources = xmldoc.createElement("sources") + source_nodes = xmldoc.createElement("sources") for type in ['programs', 'video', 'music', 'picture', 'files']: nodo_type = xmldoc.createElement(type) element_default = xmldoc.createElement("default") element_default.setAttribute("pathversion", "1") nodo_type.appendChild(element_default) - nodo_sources.appendChild(nodo_type) - xmldoc.appendChild(nodo_sources) - - # Buscamos el nodo video - nodo_video = xmldoc.childNodes[0].getElementsByTagName("video")[0] - - # Buscamos el path dentro de los nodos_path incluidos en el nodo_video - nodos_paths = nodo_video.getElementsByTagName("path") - list_path = [p.firstChild.data for p in nodos_paths] - logger.debug(list_path) - if path in list_path: - logger.debug("The path %s already exists in sources.xml" % path) - return True - logger.debug("The path %s does not exist in sources.xml" % path) - - # Si llegamos aqui es por q el path no esta en sources.xml, asi q lo incluimos - nodo_source = xmldoc.createElement("source") - - # Nodo - nodo_name = xmldoc.createElement("name") - sep = os.sep - if path.startswith("special://") or scrapertools.find_single_match(path, '(^\w+:\/\/)'): - sep = "/" - name = path - if path.endswith(sep): - name = path[:-1] - nodo_name.appendChild(xmldoc.createTextNode(name.rsplit(sep)[-1])) - nodo_source.appendChild(nodo_name) - - # Nodo - nodo_path = xmldoc.createElement("path") - nodo_path.setAttribute("pathversion", "1") - nodo_path.appendChild(xmldoc.createTextNode(path)) - nodo_source.appendChild(nodo_path) - - # Nodo - nodo_allowsharing = xmldoc.createElement("allowsharing") - nodo_allowsharing.appendChild(xmldoc.createTextNode('true')) - nodo_source.appendChild(nodo_allowsharing) - - # AƱadimos a