From 1388f4b27b15cc26f8c81a9862007cdea6b1268a Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Fri, 19 Feb 2016 18:06:36 -0600 Subject: [PATCH] Fix views duplicate at the root --- resources/lib/entrypoint.py | 5 ----- resources/lib/librarysync.py | 30 ++++++++++++++++++------------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 5fb846eb..c30a2384 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -60,7 +60,6 @@ def doMainListing(): xbmcplugin.setContent(int(sys.argv[1]), 'files') # Get emby nodes from the window props embyprops = utils.window('Emby.nodes.total') - nodes = [] if embyprops: totalnodes = int(embyprops) for i in range(totalnodes): @@ -69,10 +68,6 @@ def doMainListing(): path = utils.window('Emby.nodes.%s.content' % i) label = utils.window('Emby.nodes.%s.title' % i) type = utils.window('Emby.nodes.%s.type' % i) - if label not in nodes: - nodes.append(label) - else: # Avoid duplicates - continue #because we do not use seperate entrypoints for each content type, we need to figure out which items to show in each listing. #for now we just only show picture nodes in the picture library video nodes in the video library and all nodes in any other window if path and xbmc.getCondVisibility("Window.IsActive(Pictures)") and type == "photos": diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index a2b65167..9af778c8 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -388,6 +388,7 @@ class LibrarySync(threading.Thread): mediatypes = ['movies', 'tvshows', 'musicvideos', 'homevideos', 'music', 'photos'] for mediatype in mediatypes: + nodes = [] # Prevent duplicate for nodes of the same type # Get media folders from server folders = self.emby.getViews(mediatype, root=True) for folder in folders: @@ -418,11 +419,13 @@ class LibrarySync(threading.Thread): self.logMsg("Creating viewid: %s in Emby database." % folderid, 1) tagid = kodi_db.createTag(foldername) # Create playlist for the video library - if mediatype in ['movies', 'tvshows', 'musicvideos']: + if mediatype in ('movies', 'tvshows', 'musicvideos'): utils.playlistXSP(mediatype, foldername, viewtype) # Create the video node - if mediatype in ['movies', 'tvshows', 'musicvideos', 'homevideos']: + if (foldername not in nodes and + mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')): vnodes.viewNode(totalnodes, foldername, mediatype, viewtype) + nodes.append(foldername) totalnodes += 1 # Add view to emby database emby_db.addView(folderid, foldername, viewtype, tagid) @@ -458,11 +461,13 @@ class LibrarySync(threading.Thread): viewtype=current_viewtype, delete=True) # Added new playlist - if mediatype in ['movies', 'tvshows', 'musicvideos']: + if mediatype in ('movies', 'tvshows', 'musicvideos'): utils.playlistXSP(mediatype, foldername, viewtype) # Add new video node - if mediatype != "musicvideos": + if (foldername not in nodes and + mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')): vnodes.viewNode(totalnodes, foldername, mediatype, viewtype) + nodes.append(foldername) totalnodes += 1 # Update items with new tag @@ -472,14 +477,15 @@ class LibrarySync(threading.Thread): kodi_db.updateTag( current_tagid, tagid, item[0], current_viewtype[:-1]) else: - if mediatype != "music": - # Validate the playlist exists or recreate it - if mediatype in ['movies', 'tvshows', 'musicvideos']: - utils.playlistXSP(mediatype, foldername, viewtype) - # Create the video node if not already exists - if mediatype != "musicvideos": - vnodes.viewNode(totalnodes, foldername, mediatype, viewtype) - totalnodes += 1 + # Validate the playlist exists or recreate it + if mediatype in ('movies', 'tvshows', 'musicvideos'): + utils.playlistXSP(mediatype, foldername, viewtype) + # Create the video node if not already exists + if (foldername not in nodes and + mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')): + vnodes.viewNode(totalnodes, foldername, mediatype, viewtype) + nodes.append(foldername) + totalnodes += 1 else: # Add video nodes listings vnodes.singleNode(totalnodes, "Favorite movies", "movies", "favourites")