Tune advancedsettings.xml

- Only set backgroundupdate to false for music library, if music is
enabled
This commit is contained in:
tomkat83 2016-04-22 12:34:35 +02:00
parent 6b1b9438d9
commit 97c261bc4d
3 changed files with 57 additions and 62 deletions

View file

@ -281,14 +281,18 @@ class InitialSetup():
line1=string(39016)):
self.logMsg("User opted to disable Plex music library.", 1)
utils.settings('enableMusic', value="false")
if goToSettings:
xbmc.executebuiltin(
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
else:
utils.advancedSettingsXML()
if goToSettings is False:
# Open Settings page now? You will need to restart!
if dialog.yesno(heading=self.addonName,
line1=string(39017)):
goToSettings = dialog.yesno(heading=self.addonName,
line1=string(39017))
if goToSettings:
utils.window('emby_serverStatus', value="Stop")
xbmc.executebuiltin(
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
else:
xbmc.executebuiltin('RestartApp')
# We should always restart to ensure e.g. Kodi settings for Music
# are in use!

View file

@ -1576,7 +1576,6 @@ class LibrarySync(Thread):
log("---===### Starting LibrarySync ###===---", 0)
if self.enableMusic:
# utils.musiclibXML()
utils.advancedSettingsXML()
while not threadStopped():

View file

@ -615,47 +615,6 @@ def indent(elem, level=0):
elem.tail = i
def musiclibXML():
"""
UNUSED - WORK IN PROGRESS
Deactivates Kodi trying to scan music library on startup
Changes guisettings.xml in Kodi userdata folder:
updateonstartup: set to "false"
"""
path = xbmc.translatePath("special://profile/").decode('utf-8')
xmlpath = "%sguisettings.xml" % path
try:
xmlparse = etree.parse(xmlpath)
except:
# Document is blank or missing
root = etree.Element('settings')
else:
root = xmlparse.getroot()
music = root.find('musiclibrary')
if music is None:
music = etree.SubElement(root, 'musiclibrary')
startup = music.find('updateonstartup')
if startup is None:
# Setting does not exist yet; create it
startup = etree.SubElement(music,
'updateonstartup',
attrib={'default': "true"}).text = "false"
else:
startup.text = "false"
# Prettify and write to file
try:
indent(root)
except:
pass
etree.ElementTree(root).write(xmlpath)
def guisettingsXML():
"""
Returns special://userdata/guisettings.xml as an etree xml root element
@ -673,14 +632,51 @@ def guisettingsXML():
return root
def __setXMLTag(element, tag, value, attrib=None):
"""
Looks for an element's subelement and sets its value.
If "subelement" does not exist, create it using attrib and value.
element : etree element
tag : string/unicode for subelement
value : string/unicode
attrib : dict; will use etree attrib method
Returns the subelement
"""
subelement = element.find(tag)
if subelement is None:
# Setting does not exist yet; create it
if attrib is None:
etree.SubElement(element, tag).text = value
else:
etree.SubElement(element, tag, attrib=attrib).text = value
else:
subelement.text = value
return subelement
def __setSubElement(element, subelement):
"""
Returns an etree element's subelement. Creates one if not exist
"""
answ = element.find(subelement)
if answ is None:
answ = etree.SubElement(element, subelement)
return answ
def advancedSettingsXML():
"""
UNUSED
Deactivates Kodi popup for scanning of music library
Kodi tweaks
Changes advancedsettings.xml, musiclibrary:
backgroundupdate set to "true"
Overrides guisettings.xml in Kodi userdata folder:
updateonstartup : set to "false"
usetags : set to "false"
findremotethumbs : set to "false"
"""
path = xbmc.translatePath("special://profile/").decode('utf-8')
xmlpath = "%sadvancedsettings.xml" % path
@ -693,18 +689,14 @@ def advancedSettingsXML():
else:
root = xmlparse.getroot()
music = root.find('musiclibrary')
if music is None:
music = etree.SubElement(root, 'musiclibrary')
music = __setSubElement(root, 'musiclibrary')
__setXMLTag(music, 'backgroundupdate', "true")
# __setXMLTag(music, 'updateonstartup', "false")
backgroundupdate = music.find('backgroundupdate')
if backgroundupdate is None:
# Setting does not exist yet; create it
backgroundupdate = etree.SubElement(
music,
'backgroundupdate').text = "true"
else:
backgroundupdate.text = "true"
# Subtag 'musicfiles'
# music = __setSubElement(root, 'musicfiles')
# __setXMLTag(music, 'usetags', "false")
# __setXMLTag(music, 'findremotethumbs', "false")
# Prettify and write to file
try: