Configurazione libreria Kodi rivista
This commit is contained in:
@@ -219,31 +219,25 @@ def open_settings():
|
||||
set_setting('adult_aux_new_password1', '')
|
||||
set_setting('adult_aux_new_password2', '')
|
||||
|
||||
|
||||
from specials import move_videolibrary
|
||||
move_videolibrary.set_new_path(settings_pre.get('downloadpath'), settings_post.get('downloadpath'))
|
||||
|
||||
# si se ha puesto que se quiere autoconfigurar y se había creado el directorio de la videoteca
|
||||
if not settings_pre.get("videolibrary_kodi", None) and settings_post.get("videolibrary_kodi", None) \
|
||||
and settings_post.get("videolibrary_kodi_flag", None) == 1:
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.ask_set_content(2, silent=True)
|
||||
xbmc.sleep(2000)
|
||||
xbmc_videolibrary.update(settings_post.get("folder_movies", None))
|
||||
xbmc_videolibrary.update(settings_post.get("folder_tvshows", None))
|
||||
elif settings_pre.get("videolibrary_kodi", None) and not settings_post.get("videolibrary_kodi", None) \
|
||||
and settings_post.get("videolibrary_kodi_flag", None) == 2:
|
||||
move_videolibrary.clear_videolibrary_db()
|
||||
if settings_pre.get('downloadpath', None) != settings_post.get('downloadpath', None):
|
||||
move_videolibrary.update_sources(settings_pre.get('downloadpath', None), settings_post.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
|
||||
"""if settings_pre.get("videolibrarypath", None) != settings_post.get("videolibrarypath", None) or \
|
||||
settings_pre.get("folder_movies", None) != settings_post.get("folder_movies", None) or \
|
||||
settings_pre.get("folder_tvshows", None) != settings_post.get("folder_tvshows", None):
|
||||
verify_directories_created()"""
|
||||
move_videolibrary.move_videolibrary(settings_pre.get("videolibrarypath", None), settings_post.get("videolibrarypath", None),
|
||||
settings_pre.get("folder_movies", None), settings_post.get("folder_movies", None),
|
||||
settings_pre.get("folder_tvshows", None), settings_post.get("folder_tvshows", None))
|
||||
if settings_pre.get("videolibrarypath", None) != settings_post.get("videolibrarypath", None) or \
|
||||
settings_pre.get("folder_movies", None) != settings_post.get("folder_movies", None) or \
|
||||
settings_pre.get("folder_tvshows", None) != settings_post.get("folder_tvshows", None):
|
||||
move_videolibrary.move_videolibrary(settings_pre.get("videolibrarypath", None), settings_post.get("videolibrarypath", None),
|
||||
settings_pre.get("folder_movies", None), settings_post.get("folder_movies", None),
|
||||
settings_pre.get("folder_tvshows", None), settings_post.get("folder_tvshows", None))
|
||||
|
||||
# si se ha puesto que se quiere autoconfigurar y se había creado el directorio de la videoteca
|
||||
if not settings_pre.get("videolibrary_kodi", None) and settings_post.get("videolibrary_kodi", None):
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.ask_set_content(silent=True)
|
||||
elif settings_pre.get("videolibrary_kodi", None) and not settings_post.get("videolibrary_kodi", None):
|
||||
move_videolibrary.clear_db()
|
||||
|
||||
|
||||
def get_setting(name, channel="", server="", default=None):
|
||||
|
||||
@@ -84,7 +84,7 @@ def run(item=None):
|
||||
item = Item(channel="channelselector", action="getmainlist", viewmode="movie")
|
||||
if not config.get_setting('show_once'):
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.ask_set_content(1, config.get_setting('videolibrary_kodi_force'))
|
||||
xbmc_videolibrary.ask_set_content(silent=False)
|
||||
config.set_setting('show_once', True)
|
||||
|
||||
logger.info(item.tostring())
|
||||
|
||||
@@ -538,26 +538,26 @@ def search_library_path():
|
||||
return None
|
||||
|
||||
|
||||
def set_content(content_type, silent=False):
|
||||
def set_content(content_type, silent=False, custom=False):
|
||||
"""
|
||||
Procedimiento para auto-configurar la videoteca de kodi con los valores por defecto
|
||||
@type content_type: str ('movie' o 'tvshow')
|
||||
@param content_type: tipo de contenido para configurar, series o peliculas
|
||||
"""
|
||||
logger.info()
|
||||
continuar = True
|
||||
msg_text = ""
|
||||
videolibrarypath = config.get_setting("videolibrarypath")
|
||||
forced = config.get_setting('videolibrary_kodi_force')
|
||||
|
||||
if content_type == 'movie':
|
||||
scraper = [config.get_localized_string(70093), config.get_localized_string(70096)]
|
||||
if forced:
|
||||
if not custom:
|
||||
seleccion = 0 # tmdb
|
||||
else:
|
||||
seleccion = platformtools.dialog_select(config.get_localized_string(70094), scraper)
|
||||
|
||||
|
||||
# Instalar The Movie Database
|
||||
# Instalar The Movie Database
|
||||
if seleccion == -1 or seleccion == 0:
|
||||
if not xbmc.getCondVisibility('System.HasAddon(metadata.themoviedb.org)'):
|
||||
if not silent:
|
||||
@@ -577,7 +577,6 @@ def set_content(content_type, silent=False):
|
||||
continuar = (install and xbmc.getCondVisibility('System.HasAddon(metadata.themoviedb.org)'))
|
||||
if not continuar:
|
||||
msg_text = config.get_localized_string(60047)
|
||||
|
||||
if continuar:
|
||||
xbmc.executebuiltin('xbmc.addon.opensettings(metadata.themoviedb.org)', True)
|
||||
|
||||
@@ -607,7 +606,7 @@ def set_content(content_type, silent=False):
|
||||
|
||||
else: # SERIES
|
||||
scraper = [config.get_localized_string(70098), config.get_localized_string(70093)]
|
||||
if forced:
|
||||
if not custom:
|
||||
seleccion = 0 # tvdb
|
||||
else:
|
||||
seleccion = platformtools.dialog_select(config.get_localized_string(70107), scraper)
|
||||
@@ -631,7 +630,7 @@ def set_content(content_type, silent=False):
|
||||
|
||||
continuar = (install and xbmc.getCondVisibility('System.HasAddon(metadata.tvdb.com)'))
|
||||
if not continuar:
|
||||
msg_text = config.get_localized_string(70099)
|
||||
msg_text = config.get_localized_string(60049)
|
||||
if continuar:
|
||||
xbmc.executebuiltin('xbmc.addon.opensettings(metadata.tvdb.com)', True)
|
||||
|
||||
@@ -641,7 +640,7 @@ def set_content(content_type, silent=False):
|
||||
continuar = False
|
||||
if not silent:
|
||||
# Preguntar si queremos instalar metadata.tvshows.themoviedb.org
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(70100))
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60050))
|
||||
else:
|
||||
install = True
|
||||
|
||||
@@ -656,7 +655,7 @@ def set_content(content_type, silent=False):
|
||||
|
||||
continuar = (install and continuar)
|
||||
if not continuar:
|
||||
msg_text = config.get_localized_string(60047)
|
||||
msg_text = config.get_localized_string(60051)
|
||||
if continuar:
|
||||
xbmc.executebuiltin('xbmc.addon.opensettings(metadata.tvshows.themoviedb.org)', True)
|
||||
|
||||
@@ -719,6 +718,9 @@ def set_content(content_type, silent=False):
|
||||
elif seleccion == 1:
|
||||
strScraper = 'metadata.universal'
|
||||
path_settings = xbmc.translatePath("special://profile/addon_data/metadata.universal/settings.xml")
|
||||
if not os.path.exists(path_settings):
|
||||
logger.info("%s: %s" % (content_type, path_settings + " doesn't exist"))
|
||||
return continuar
|
||||
settings_data = filetools.read(path_settings)
|
||||
strSettings = ' '.join(settings_data.split()).replace("> <", "><")
|
||||
strSettings = strSettings.replace("\"","\'")
|
||||
@@ -735,6 +737,9 @@ def set_content(content_type, silent=False):
|
||||
elif seleccion == 1:
|
||||
strScraper = 'metadata.tvshows.themoviedb.org'
|
||||
path_settings = xbmc.translatePath("special://profile/addon_data/metadata.tvshows.themoviedb.org/settings.xml")
|
||||
if not os.path.exists(path_settings):
|
||||
logger.info("%s: %s" % (content_type, path_settings + " doesn't exist"))
|
||||
return continuar
|
||||
settings_data = filetools.read(path_settings)
|
||||
strSettings = ' '.join(settings_data.split()).replace("> <", "><")
|
||||
strSettings = strSettings.replace("\"","\'")
|
||||
@@ -784,9 +789,9 @@ def set_content(content_type, silent=False):
|
||||
else:
|
||||
heading = config.get_localized_string(70103) % content_type
|
||||
msg_text = config.get_localized_string(70104)
|
||||
platformtools.dialog_notification(heading, msg_text, icon=1, time=3000)
|
||||
|
||||
logger.info("%s: %s" % (heading, msg_text))
|
||||
return continuar
|
||||
|
||||
|
||||
def execute_sql_kodi(sql):
|
||||
@@ -856,99 +861,117 @@ def execute_sql_kodi(sql):
|
||||
|
||||
def add_sources(path):
|
||||
logger.info()
|
||||
from xml.dom import minidom
|
||||
try:
|
||||
from xml.dom import minidom
|
||||
|
||||
SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml")
|
||||
SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml")
|
||||
|
||||
if os.path.exists(SOURCES_PATH):
|
||||
xmldoc = minidom.parse(SOURCES_PATH)
|
||||
else:
|
||||
# Crear documento
|
||||
xmldoc = minidom.Document()
|
||||
nodo_sources = xmldoc.createElement("sources")
|
||||
if os.path.exists(SOURCES_PATH):
|
||||
xmldoc = minidom.parse(SOURCES_PATH)
|
||||
else:
|
||||
# Crear documento
|
||||
xmldoc = minidom.Document()
|
||||
nodo_sources = 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)
|
||||
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 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("La ruta %s ya esta en sources.xml" % path)
|
||||
return
|
||||
logger.debug("La ruta %s NO esta en sources.xml" % path)
|
||||
# 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("La ruta %s ya esta en sources.xml" % path)
|
||||
return True
|
||||
logger.debug("La ruta %s NO esta en 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")
|
||||
# Si llegamos aqui es por q el path no esta en sources.xml, asi q lo incluimos
|
||||
nodo_source = xmldoc.createElement("source")
|
||||
|
||||
# Nodo <name>
|
||||
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 <name>
|
||||
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 <path>
|
||||
nodo_path = xmldoc.createElement("path")
|
||||
nodo_path.setAttribute("pathversion", "1")
|
||||
nodo_path.appendChild(xmldoc.createTextNode(path))
|
||||
nodo_source.appendChild(nodo_path)
|
||||
# Nodo <path>
|
||||
nodo_path = xmldoc.createElement("path")
|
||||
nodo_path.setAttribute("pathversion", "1")
|
||||
nodo_path.appendChild(xmldoc.createTextNode(path))
|
||||
nodo_source.appendChild(nodo_path)
|
||||
|
||||
# Nodo <allowsharing>
|
||||
nodo_allowsharing = xmldoc.createElement("allowsharing")
|
||||
nodo_allowsharing.appendChild(xmldoc.createTextNode('true'))
|
||||
nodo_source.appendChild(nodo_allowsharing)
|
||||
# Nodo <allowsharing>
|
||||
nodo_allowsharing = xmldoc.createElement("allowsharing")
|
||||
nodo_allowsharing.appendChild(xmldoc.createTextNode('true'))
|
||||
nodo_source.appendChild(nodo_allowsharing)
|
||||
|
||||
# Añadimos <source> a <video>
|
||||
nodo_video.appendChild(nodo_source)
|
||||
# Añadimos <source> a <video>
|
||||
nodo_video.appendChild(nodo_source)
|
||||
|
||||
# Guardamos los cambios
|
||||
if not PY3:
|
||||
filetools.write(SOURCES_PATH,
|
||||
'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]))
|
||||
else:
|
||||
filetools.write(SOURCES_PATH,
|
||||
b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]),
|
||||
vfs=False)
|
||||
# Guardamos los cambios
|
||||
if not PY3:
|
||||
filetools.write(SOURCES_PATH,
|
||||
'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]))
|
||||
else:
|
||||
filetools.write(SOURCES_PATH,
|
||||
b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]),
|
||||
vfs=False)
|
||||
logger.debug("The path %s has been added to sources.xml" % path)
|
||||
return True
|
||||
except:
|
||||
logger.debug("An error occurred. The path %s has not been added to sources.xml" % path)
|
||||
return False
|
||||
|
||||
|
||||
def ask_set_content(flag, silent=False):
|
||||
def ask_set_content(silent=False):
|
||||
logger.info()
|
||||
logger.debug("videolibrary_kodi_flag %s" % config.get_setting("videolibrary_kodi_flag"))
|
||||
logger.debug("videolibrary_kodi %s" % config.get_setting("videolibrary_kodi"))
|
||||
|
||||
def do_config():
|
||||
logger.debug("hemos aceptado")
|
||||
config.set_setting("videolibrary_kodi", True)
|
||||
set_content("movie", silent=True)
|
||||
set_content("tvshow", silent=True)
|
||||
add_sources(config.get_setting("videolibrarypath"))
|
||||
add_sources(config.get_setting("downloadpath"))
|
||||
def do_config(custom=False):
|
||||
if set_content("movie", True, custom) and set_content("tvshow", True, custom) and \
|
||||
add_sources(config.get_setting("videolibrarypath")) and \
|
||||
add_sources(config.get_setting("downloadpath")):
|
||||
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(70104))
|
||||
config.set_setting("videolibrary_kodi", True)
|
||||
update()
|
||||
else:
|
||||
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80024))
|
||||
config.set_setting("videolibrary_kodi", False)
|
||||
|
||||
if not silent:
|
||||
heading = config.get_localized_string(59971)
|
||||
linea1 = config.get_localized_string(70105)
|
||||
linea2 = config.get_localized_string(70106)
|
||||
if platformtools.dialog_yesno(heading, linea1, linea2):
|
||||
do_config()
|
||||
if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80015)):
|
||||
if not platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80016), "", "", config.get_localized_string(80017), config.get_localized_string(80018)):
|
||||
path = platformtools.dialog_browse(3, config.get_localized_string(80019), config.get_setting("videolibrarypath"))
|
||||
if path != "":
|
||||
config.set_setting("videolibrarypath", path)
|
||||
folder = platformtools.dialog_input(config.get_setting("folder_movies"), config.get_localized_string(80020))
|
||||
if folder != "":
|
||||
config.set_setting("folder_movies", folder)
|
||||
folder = platformtools.dialog_input(config.get_setting("folder_tvshows"), config.get_localized_string(80021))
|
||||
if folder != "":
|
||||
config.set_setting("folder_tvshows", folder)
|
||||
config.verify_directories_created()
|
||||
do_config(True)
|
||||
else:
|
||||
do_config(False)
|
||||
else:
|
||||
# no hemos aceptado
|
||||
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80022))
|
||||
config.set_setting("videolibrary_kodi", False)
|
||||
|
||||
else:
|
||||
do_config()
|
||||
|
||||
config.set_setting("videolibrary_kodi_flag", flag)
|
||||
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80023))
|
||||
do_config(True)
|
||||
Reference in New Issue
Block a user