Fix views duplicate at the root

This commit is contained in:
angelblue05 2016-02-19 18:06:36 -06:00
parent 2f3d9c4a60
commit 1388f4b27b
2 changed files with 18 additions and 17 deletions

View file

@ -60,7 +60,6 @@ def doMainListing():
xbmcplugin.setContent(int(sys.argv[1]), 'files') xbmcplugin.setContent(int(sys.argv[1]), 'files')
# Get emby nodes from the window props # Get emby nodes from the window props
embyprops = utils.window('Emby.nodes.total') embyprops = utils.window('Emby.nodes.total')
nodes = []
if embyprops: if embyprops:
totalnodes = int(embyprops) totalnodes = int(embyprops)
for i in range(totalnodes): for i in range(totalnodes):
@ -69,10 +68,6 @@ def doMainListing():
path = utils.window('Emby.nodes.%s.content' % i) path = utils.window('Emby.nodes.%s.content' % i)
label = utils.window('Emby.nodes.%s.title' % i) label = utils.window('Emby.nodes.%s.title' % i)
type = utils.window('Emby.nodes.%s.type' % 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. #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 #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": if path and xbmc.getCondVisibility("Window.IsActive(Pictures)") and type == "photos":

View file

@ -388,6 +388,7 @@ class LibrarySync(threading.Thread):
mediatypes = ['movies', 'tvshows', 'musicvideos', 'homevideos', 'music', 'photos'] mediatypes = ['movies', 'tvshows', 'musicvideos', 'homevideos', 'music', 'photos']
for mediatype in mediatypes: for mediatype in mediatypes:
nodes = [] # Prevent duplicate for nodes of the same type
# Get media folders from server # Get media folders from server
folders = self.emby.getViews(mediatype, root=True) folders = self.emby.getViews(mediatype, root=True)
for folder in folders: for folder in folders:
@ -418,11 +419,13 @@ class LibrarySync(threading.Thread):
self.logMsg("Creating viewid: %s in Emby database." % folderid, 1) self.logMsg("Creating viewid: %s in Emby database." % folderid, 1)
tagid = kodi_db.createTag(foldername) tagid = kodi_db.createTag(foldername)
# Create playlist for the video library # Create playlist for the video library
if mediatype in ['movies', 'tvshows', 'musicvideos']: if mediatype in ('movies', 'tvshows', 'musicvideos'):
utils.playlistXSP(mediatype, foldername, viewtype) utils.playlistXSP(mediatype, foldername, viewtype)
# Create the video node # 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) vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
nodes.append(foldername)
totalnodes += 1 totalnodes += 1
# Add view to emby database # Add view to emby database
emby_db.addView(folderid, foldername, viewtype, tagid) emby_db.addView(folderid, foldername, viewtype, tagid)
@ -458,11 +461,13 @@ class LibrarySync(threading.Thread):
viewtype=current_viewtype, viewtype=current_viewtype,
delete=True) delete=True)
# Added new playlist # Added new playlist
if mediatype in ['movies', 'tvshows', 'musicvideos']: if mediatype in ('movies', 'tvshows', 'musicvideos'):
utils.playlistXSP(mediatype, foldername, viewtype) utils.playlistXSP(mediatype, foldername, viewtype)
# Add new video node # 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) vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
nodes.append(foldername)
totalnodes += 1 totalnodes += 1
# Update items with new tag # Update items with new tag
@ -472,13 +477,14 @@ class LibrarySync(threading.Thread):
kodi_db.updateTag( kodi_db.updateTag(
current_tagid, tagid, item[0], current_viewtype[:-1]) current_tagid, tagid, item[0], current_viewtype[:-1])
else: else:
if mediatype != "music":
# Validate the playlist exists or recreate it # Validate the playlist exists or recreate it
if mediatype in ['movies', 'tvshows', 'musicvideos']: if mediatype in ('movies', 'tvshows', 'musicvideos'):
utils.playlistXSP(mediatype, foldername, viewtype) utils.playlistXSP(mediatype, foldername, viewtype)
# Create the video node if not already exists # Create the video node if not already exists
if mediatype != "musicvideos": if (foldername not in nodes and
mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')):
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype) vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
nodes.append(foldername)
totalnodes += 1 totalnodes += 1
else: else:
# Add video nodes listings # Add video nodes listings