Create video nodes/playlist using the id

Prevent errors with special characters that have no ascii replacement
This commit is contained in:
angelblue05 2016-02-23 00:00:24 -06:00
parent 9670e87049
commit 81ea279319
3 changed files with 28 additions and 21 deletions

View file

@ -392,6 +392,7 @@ class LibrarySync(threading.Thread):
for mediatype in mediatypes:
nodes = [] # Prevent duplicate for nodes of the same type
playlists = [] # Prevent duplicate for playlists of the same type
# Get media folders from server
folders = self.emby.getViews(mediatype, root=True)
for folder in folders:
@ -422,12 +423,14 @@ 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'):
utils.playlistXSP(mediatype, foldername, viewtype)
if (foldername not in playlists and
mediatype in ('movies', 'tvshows', 'musicvideos')):
utils.playlistXSP(mediatype, foldername, folderid, viewtype)
playlists.append(foldername)
# Create the video node
if (foldername not in nodes and
mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')):
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype, folderid)
nodes.append(foldername)
totalnodes += 1
# Add view to emby database
@ -454,7 +457,7 @@ class LibrarySync(threading.Thread):
# The tag could be a combined view. Ensure there's no other tags
# with the same name before deleting playlist.
utils.playlistXSP(
mediatype, current_viewname, current_viewtype, True)
mediatype, current_viewname, folderid, current_viewtype, True)
# Delete video node
if mediatype != "musicvideos":
vnodes.viewNode(
@ -462,14 +465,17 @@ class LibrarySync(threading.Thread):
tagname=current_viewname,
mediatype=mediatype,
viewtype=current_viewtype,
viewid=folderid,
delete=True)
# Added new playlist
if mediatype in ('movies', 'tvshows', 'musicvideos'):
utils.playlistXSP(mediatype, foldername, viewtype)
if (foldername not in playlists and
mediatype in ('movies', 'tvshows', 'musicvideos')):
utils.playlistXSP(mediatype, foldername, folderid, viewtype)
playlists.append(foldername)
# Add new video node
if (foldername not in nodes and
mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')):
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype, folderid)
nodes.append(foldername)
totalnodes += 1
@ -481,12 +487,14 @@ class LibrarySync(threading.Thread):
current_tagid, tagid, item[0], current_viewtype[:-1])
else:
# Validate the playlist exists or recreate it
if mediatype in ('movies', 'tvshows', 'musicvideos'):
utils.playlistXSP(mediatype, foldername, viewtype)
if (foldername not in playlists and
mediatype in ('movies', 'tvshows', 'musicvideos')):
utils.playlistXSP(mediatype, foldername, folderid, viewtype)
playlists.append(foldername)
# 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)
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype, folderid)
nodes.append(foldername)
totalnodes += 1
else:

View file

@ -449,17 +449,17 @@ def passwordsXML():
time=1000,
sound=False)
def playlistXSP(mediatype, tagname, viewtype="", delete=False):
def playlistXSP(mediatype, tagname, viewid, viewtype="", delete=False):
# Tagname is in unicode - actions: add or delete
tagname = tagname.encode('utf-8')
cleantagname = normalize_nodes(tagname)
path = xbmc.translatePath("special://profile/playlists/video/").decode('utf-8')
if viewtype == "mixed":
plname = "%s - %s" % (tagname, mediatype)
xsppath = "%sEmby %s - %s.xsp" % (path, cleantagname, mediatype)
xsppath = "%sEmby %s - %s.xsp" % (path, viewid, mediatype)
else:
plname = tagname
xsppath = "%sEmby %s.xsp" % (path, cleantagname)
xsppath = "%sEmby %s.xsp" % (path, viewid)
# Create the playlist directory
if not xbmcvfs.exists(path):

View file

@ -52,16 +52,15 @@ class VideoNodes(object):
return root
def viewNode(self, indexnumber, tagname, mediatype, viewtype, delete=False):
def viewNode(self, indexnumber, tagname, mediatype, viewtype, viewid, delete=False):
window = utils.window
kodiversion = self.kodiversion
cleantagname = utils.normalize_nodes(tagname.encode('utf-8'))
if viewtype == "mixed":
dirname = "%s - %s" % (cleantagname, mediatype)
dirname = "%s - %s" % (viewid, mediatype)
else:
dirname = cleantagname
dirname = viewid
path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
nodepath = xbmc.translatePath(
@ -182,7 +181,7 @@ class VideoNodes(object):
for node in nodes:
nodetype = nodetypes[node]
nodeXML = "%s%s_%s.xml" % (nodepath, cleantagname, nodetype)
nodeXML = "%s%s_%s.xml" % (nodepath, viewid, nodetype)
# Get label
stringid = nodes[node]
if node != "1":
@ -211,7 +210,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, cleantagname, nodetype)
path = "library://video/Emby - %s/%s_%s.xml" % (dirname, viewid, nodetype)
if mediatype == "photos":
windowpath = "ActivateWindow(Pictures,%s,return)" % path
@ -221,7 +220,7 @@ class VideoNodes(object):
if nodetype == "all":
if viewtype == "mixed":
templabel = dirname
templabel = "%s - %s" % (tagname, mediatype)
else:
templabel = label