From 83ab85599962e512cf80f554684568766a28db51 Mon Sep 17 00:00:00 2001 From: delphiactual Date: Fri, 4 Nov 2016 04:14:35 -0600 Subject: [PATCH] Nest emby video nodes logically (#55) * Nest emby video nodes logically * Node cleanup --- resources/lib/utils.py | 11 +++++++++-- resources/lib/videonodes.py | 8 ++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index c306942d..b4145e76 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -47,11 +47,11 @@ def window(property_, value=None, clear=False, window_id=10000): def settings(setting, value=None): # Get or add addon setting addon = xbmcaddon.Addon(id='plugin.video.emby') - + if value is not None: addon.setSetting(setting, value) else: # returns unicode object - return addon.getSetting(setting) + return addon.getSetting(setting) def language(string_id): # Central string retrieval - unicode @@ -572,6 +572,13 @@ def deleteNodes(): # Clean up video nodes import shutil + path = xbmc.translatePath("special://profile/library/video/emby/").decode('utf-8') + if (xbmcvfs.exists(path)): + try: + shutil.rmtree(path) + except: + log.warn("Failed to delete directory: %s" % path) + # Old cleanup code kept for cleanup of old style nodes path = xbmc.translatePath("special://profile/library/video/").decode('utf-8') dirs, files = xbmcvfs.listdir(path) for dir in dirs: diff --git a/resources/lib/videonodes.py b/resources/lib/videonodes.py index 3a9a4640..02f2f17e 100644 --- a/resources/lib/videonodes.py +++ b/resources/lib/videonodes.py @@ -58,7 +58,7 @@ class VideoNodes(object): path = xbmc.translatePath("special://profile/library/video/").decode('utf-8') nodepath = xbmc.translatePath( - "special://profile/library/video/Emby - %s/" % dirname).decode('utf-8') + "special://profile/library/video/emby/%s/" % dirname).decode('utf-8') # Verify the video directory if not xbmcvfs.exists(path): @@ -86,7 +86,7 @@ class VideoNodes(object): # Create index entry nodeXML = "%sindex.xml" % nodepath # Set windows property - path = "library://video/Emby - %s/" % dirname + path = "library://video/emby/%s/" % dirname for i in range(1, indexnumber): # Verify to make sure we don't create duplicates if window('Emby.nodes.%s.index' % i) == path: @@ -178,7 +178,7 @@ class VideoNodes(object): for node in nodes: nodetype = nodetypes[node] - nodeXML = "%s%s_%s.xml" % (nodepath, viewid, nodetype) + nodeXML = "%s%s.xml" % (nodepath, nodetype) # Get label stringid = nodes[node] if node != "1": @@ -207,7 +207,7 @@ class VideoNodes(object): # Custom query path = "plugin://plugin.video.emby/?id=%s&mode=inprogressepisodes&limit=25"% tagname else: - path = "library://video/Emby - %s/%s_%s.xml" % (dirname, viewid, nodetype) + path = "library://video/emby/%s/%s.xml" % (viewid, nodetype) if mediatype == "photos": windowpath = "ActivateWindow(Pictures,%s,return)" % path