Tune advancedsettings.xml
- Only set backgroundupdate to false for music library, if music is enabled
This commit is contained in:
parent
6b1b9438d9
commit
97c261bc4d
3 changed files with 57 additions and 62 deletions
|
@ -281,14 +281,18 @@ class InitialSetup():
|
||||||
line1=string(39016)):
|
line1=string(39016)):
|
||||||
self.logMsg("User opted to disable Plex music library.", 1)
|
self.logMsg("User opted to disable Plex music library.", 1)
|
||||||
utils.settings('enableMusic', value="false")
|
utils.settings('enableMusic', value="false")
|
||||||
|
else:
|
||||||
|
utils.advancedSettingsXML()
|
||||||
|
|
||||||
|
if goToSettings is False:
|
||||||
|
# Open Settings page now? You will need to restart!
|
||||||
|
goToSettings = dialog.yesno(heading=self.addonName,
|
||||||
|
line1=string(39017))
|
||||||
if goToSettings:
|
if goToSettings:
|
||||||
|
utils.window('emby_serverStatus', value="Stop")
|
||||||
xbmc.executebuiltin(
|
xbmc.executebuiltin(
|
||||||
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
||||||
else:
|
else:
|
||||||
# Open Settings page now? You will need to restart!
|
xbmc.executebuiltin('RestartApp')
|
||||||
if dialog.yesno(heading=self.addonName,
|
# We should always restart to ensure e.g. Kodi settings for Music
|
||||||
line1=string(39017)):
|
# are in use!
|
||||||
utils.window('emby_serverStatus', value="Stop")
|
|
||||||
xbmc.executebuiltin(
|
|
||||||
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
|
||||||
|
|
|
@ -1576,7 +1576,6 @@ class LibrarySync(Thread):
|
||||||
log("---===### Starting LibrarySync ###===---", 0)
|
log("---===### Starting LibrarySync ###===---", 0)
|
||||||
|
|
||||||
if self.enableMusic:
|
if self.enableMusic:
|
||||||
# utils.musiclibXML()
|
|
||||||
utils.advancedSettingsXML()
|
utils.advancedSettingsXML()
|
||||||
|
|
||||||
while not threadStopped():
|
while not threadStopped():
|
||||||
|
|
|
@ -615,47 +615,6 @@ def indent(elem, level=0):
|
||||||
elem.tail = i
|
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():
|
def guisettingsXML():
|
||||||
"""
|
"""
|
||||||
Returns special://userdata/guisettings.xml as an etree xml root element
|
Returns special://userdata/guisettings.xml as an etree xml root element
|
||||||
|
@ -673,14 +632,51 @@ def guisettingsXML():
|
||||||
return root
|
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():
|
def advancedSettingsXML():
|
||||||
"""
|
"""
|
||||||
UNUSED
|
Kodi tweaks
|
||||||
|
|
||||||
Deactivates Kodi popup for scanning of music library
|
|
||||||
|
|
||||||
Changes advancedsettings.xml, musiclibrary:
|
Changes advancedsettings.xml, musiclibrary:
|
||||||
backgroundupdate set to "true"
|
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')
|
path = xbmc.translatePath("special://profile/").decode('utf-8')
|
||||||
xmlpath = "%sadvancedsettings.xml" % path
|
xmlpath = "%sadvancedsettings.xml" % path
|
||||||
|
@ -693,18 +689,14 @@ def advancedSettingsXML():
|
||||||
else:
|
else:
|
||||||
root = xmlparse.getroot()
|
root = xmlparse.getroot()
|
||||||
|
|
||||||
music = root.find('musiclibrary')
|
music = __setSubElement(root, 'musiclibrary')
|
||||||
if music is None:
|
__setXMLTag(music, 'backgroundupdate', "true")
|
||||||
music = etree.SubElement(root, 'musiclibrary')
|
# __setXMLTag(music, 'updateonstartup', "false")
|
||||||
|
|
||||||
backgroundupdate = music.find('backgroundupdate')
|
# Subtag 'musicfiles'
|
||||||
if backgroundupdate is None:
|
# music = __setSubElement(root, 'musicfiles')
|
||||||
# Setting does not exist yet; create it
|
# __setXMLTag(music, 'usetags', "false")
|
||||||
backgroundupdate = etree.SubElement(
|
# __setXMLTag(music, 'findremotethumbs', "false")
|
||||||
music,
|
|
||||||
'backgroundupdate').text = "true"
|
|
||||||
else:
|
|
||||||
backgroundupdate.text = "true"
|
|
||||||
|
|
||||||
# Prettify and write to file
|
# Prettify and write to file
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue