Create video nodes/playlist using the id
Prevent errors with special characters that have no ascii replacement
This commit is contained in:
parent
9670e87049
commit
81ea279319
3 changed files with 28 additions and 21 deletions
|
@ -392,6 +392,7 @@ class LibrarySync(threading.Thread):
|
||||||
for mediatype in mediatypes:
|
for mediatype in mediatypes:
|
||||||
|
|
||||||
nodes = [] # Prevent duplicate for nodes of the same type
|
nodes = [] # Prevent duplicate for nodes of the same type
|
||||||
|
playlists = [] # Prevent duplicate for playlists 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:
|
||||||
|
@ -422,12 +423,14 @@ 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 (foldername not in playlists and
|
||||||
utils.playlistXSP(mediatype, foldername, viewtype)
|
mediatype in ('movies', 'tvshows', 'musicvideos')):
|
||||||
|
utils.playlistXSP(mediatype, foldername, folderid, viewtype)
|
||||||
|
playlists.append(foldername)
|
||||||
# Create the video node
|
# Create the video node
|
||||||
if (foldername not in nodes and
|
if (foldername not in nodes and
|
||||||
mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')):
|
mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')):
|
||||||
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
|
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype, folderid)
|
||||||
nodes.append(foldername)
|
nodes.append(foldername)
|
||||||
totalnodes += 1
|
totalnodes += 1
|
||||||
# Add view to emby database
|
# 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
|
# The tag could be a combined view. Ensure there's no other tags
|
||||||
# with the same name before deleting playlist.
|
# with the same name before deleting playlist.
|
||||||
utils.playlistXSP(
|
utils.playlistXSP(
|
||||||
mediatype, current_viewname, current_viewtype, True)
|
mediatype, current_viewname, folderid, current_viewtype, True)
|
||||||
# Delete video node
|
# Delete video node
|
||||||
if mediatype != "musicvideos":
|
if mediatype != "musicvideos":
|
||||||
vnodes.viewNode(
|
vnodes.viewNode(
|
||||||
|
@ -462,14 +465,17 @@ class LibrarySync(threading.Thread):
|
||||||
tagname=current_viewname,
|
tagname=current_viewname,
|
||||||
mediatype=mediatype,
|
mediatype=mediatype,
|
||||||
viewtype=current_viewtype,
|
viewtype=current_viewtype,
|
||||||
|
viewid=folderid,
|
||||||
delete=True)
|
delete=True)
|
||||||
# Added new playlist
|
# Added new playlist
|
||||||
if mediatype in ('movies', 'tvshows', 'musicvideos'):
|
if (foldername not in playlists and
|
||||||
utils.playlistXSP(mediatype, foldername, viewtype)
|
mediatype in ('movies', 'tvshows', 'musicvideos')):
|
||||||
|
utils.playlistXSP(mediatype, foldername, folderid, viewtype)
|
||||||
|
playlists.append(foldername)
|
||||||
# Add new video node
|
# Add new video node
|
||||||
if (foldername not in nodes and
|
if (foldername not in nodes and
|
||||||
mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')):
|
mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')):
|
||||||
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
|
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype, folderid)
|
||||||
nodes.append(foldername)
|
nodes.append(foldername)
|
||||||
totalnodes += 1
|
totalnodes += 1
|
||||||
|
|
||||||
|
@ -481,12 +487,14 @@ class LibrarySync(threading.Thread):
|
||||||
current_tagid, tagid, item[0], current_viewtype[:-1])
|
current_tagid, tagid, item[0], current_viewtype[:-1])
|
||||||
else:
|
else:
|
||||||
# Validate the playlist exists or recreate it
|
# Validate the playlist exists or recreate it
|
||||||
if mediatype in ('movies', 'tvshows', 'musicvideos'):
|
if (foldername not in playlists and
|
||||||
utils.playlistXSP(mediatype, foldername, viewtype)
|
mediatype in ('movies', 'tvshows', 'musicvideos')):
|
||||||
|
utils.playlistXSP(mediatype, foldername, folderid, viewtype)
|
||||||
|
playlists.append(foldername)
|
||||||
# Create the video node if not already exists
|
# Create the video node if not already exists
|
||||||
if (foldername not in nodes and
|
if (foldername not in nodes and
|
||||||
mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')):
|
mediatype in ('movies', 'tvshows', 'musicvideos', 'homevideos')):
|
||||||
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype)
|
vnodes.viewNode(totalnodes, foldername, mediatype, viewtype, folderid)
|
||||||
nodes.append(foldername)
|
nodes.append(foldername)
|
||||||
totalnodes += 1
|
totalnodes += 1
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -449,17 +449,17 @@ def passwordsXML():
|
||||||
time=1000,
|
time=1000,
|
||||||
sound=False)
|
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 is in unicode - actions: add or delete
|
||||||
tagname = tagname.encode('utf-8')
|
tagname = tagname.encode('utf-8')
|
||||||
cleantagname = normalize_nodes(tagname)
|
|
||||||
path = xbmc.translatePath("special://profile/playlists/video/").decode('utf-8')
|
path = xbmc.translatePath("special://profile/playlists/video/").decode('utf-8')
|
||||||
if viewtype == "mixed":
|
if viewtype == "mixed":
|
||||||
plname = "%s - %s" % (tagname, mediatype)
|
plname = "%s - %s" % (tagname, mediatype)
|
||||||
xsppath = "%sEmby %s - %s.xsp" % (path, cleantagname, mediatype)
|
xsppath = "%sEmby %s - %s.xsp" % (path, viewid, mediatype)
|
||||||
else:
|
else:
|
||||||
plname = tagname
|
plname = tagname
|
||||||
xsppath = "%sEmby %s.xsp" % (path, cleantagname)
|
xsppath = "%sEmby %s.xsp" % (path, viewid)
|
||||||
|
|
||||||
# Create the playlist directory
|
# Create the playlist directory
|
||||||
if not xbmcvfs.exists(path):
|
if not xbmcvfs.exists(path):
|
||||||
|
|
|
@ -52,16 +52,15 @@ class VideoNodes(object):
|
||||||
|
|
||||||
return root
|
return root
|
||||||
|
|
||||||
def viewNode(self, indexnumber, tagname, mediatype, viewtype, delete=False):
|
def viewNode(self, indexnumber, tagname, mediatype, viewtype, viewid, delete=False):
|
||||||
|
|
||||||
window = utils.window
|
window = utils.window
|
||||||
kodiversion = self.kodiversion
|
kodiversion = self.kodiversion
|
||||||
|
|
||||||
cleantagname = utils.normalize_nodes(tagname.encode('utf-8'))
|
|
||||||
if viewtype == "mixed":
|
if viewtype == "mixed":
|
||||||
dirname = "%s - %s" % (cleantagname, mediatype)
|
dirname = "%s - %s" % (viewid, mediatype)
|
||||||
else:
|
else:
|
||||||
dirname = cleantagname
|
dirname = viewid
|
||||||
|
|
||||||
path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
|
path = xbmc.translatePath("special://profile/library/video/").decode('utf-8')
|
||||||
nodepath = xbmc.translatePath(
|
nodepath = xbmc.translatePath(
|
||||||
|
@ -182,7 +181,7 @@ class VideoNodes(object):
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
|
|
||||||
nodetype = nodetypes[node]
|
nodetype = nodetypes[node]
|
||||||
nodeXML = "%s%s_%s.xml" % (nodepath, cleantagname, nodetype)
|
nodeXML = "%s%s_%s.xml" % (nodepath, viewid, nodetype)
|
||||||
# Get label
|
# Get label
|
||||||
stringid = nodes[node]
|
stringid = nodes[node]
|
||||||
if node != "1":
|
if node != "1":
|
||||||
|
@ -211,7 +210,7 @@ class VideoNodes(object):
|
||||||
# Custom query
|
# Custom query
|
||||||
path = "plugin://plugin.video.emby/?id=%s&mode=inprogressepisodes&limit=25"% tagname
|
path = "plugin://plugin.video.emby/?id=%s&mode=inprogressepisodes&limit=25"% tagname
|
||||||
else:
|
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":
|
if mediatype == "photos":
|
||||||
windowpath = "ActivateWindow(Pictures,%s,return)" % path
|
windowpath = "ActivateWindow(Pictures,%s,return)" % path
|
||||||
|
@ -221,7 +220,7 @@ class VideoNodes(object):
|
||||||
if nodetype == "all":
|
if nodetype == "all":
|
||||||
|
|
||||||
if viewtype == "mixed":
|
if viewtype == "mixed":
|
||||||
templabel = dirname
|
templabel = "%s - %s" % (tagname, mediatype)
|
||||||
else:
|
else:
|
||||||
templabel = label
|
templabel = label
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue