From a1a074b66f544867407d6f95d69e68c2af80055f Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Mon, 16 Mar 2015 23:37:31 +0100 Subject: [PATCH] advancedsettings.xml can get the watchedstates imported --- resources/lib/Utils.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py index 30a8f9c2..203a1323 100644 --- a/resources/lib/Utils.py +++ b/resources/lib/Utils.py @@ -118,9 +118,30 @@ def addKodiSource(name, path, type): SubElement(source, "path").text = path tree.write(sourcesFile) #return bool that reboot is needed and manual add of path to kodi - #return True + return KodiAdvancedSettingsCheck() + +def KodiAdvancedSettingsCheck(): + #setting that kodi should import watched state and resume points from the nfo files + settingsFile = xbmc.translatePath( "special://profile/advancedsettings.xml" ) + # add an empty sources file to work with + if xbmcvfs.exists(settingsFile) == False: + sources = Element("advancedsettings") + video = SubElement(sources, "videolibrary") + ET.ElementTree(sources).write(settingsFile) + + if xbmcvfs.exists(settingsFile): + tree = ET.ElementTree(file=settingsFile) + root = tree.getroot() + video = root.find("videolibrary") + if video == None: + video = SubElement(sources, "videolibrary") + # add the settings + SubElement(video, "importwatchedstate").text = "true" + SubElement(video, "importresumepoint").text = "true" + tree.write(settingsFile) + #return bool that reboot is needed and manual add of path to kodi + return True - def checkAuthentication(): #check authentication if addonSettings.getSetting('username') != "" and addonSettings.getSetting('ipaddress') != "":