Groundworks for Plex photos

This commit is contained in:
tomkat83 2016-06-04 18:48:22 +02:00
parent 031a36a0a6
commit 5d8b423bd6
4 changed files with 50 additions and 28 deletions

View file

@ -2352,7 +2352,8 @@ class API():
'album': 'music',
'song': 'music',
'track': 'music',
'clip': 'clip'
'clip': 'clip',
'photo': 'photo'
}
typus = types[typus]
if utils.window('remapSMB') == 'true':

View file

@ -1348,16 +1348,16 @@ def RunLibScan(mode):
utils.window('plex_runLibScan', value='full')
def BrowsePlexContent(viewid, mediatype="", nodetype=""):
def BrowsePlexContent(viewid, mediatype="", folderid=""):
"""
Plex:
Browse Plex Photos:
viewid: PMS name of the library
mediatype: mediatype, e.g. 'movies', 'tvshows', 'photos'
nodetype: e.g. 'ondeck'
mediatype: mediatype, 'photos'
nodetype: e.g. 'ondeck' (TBD!!)
"""
utils.logMsg(title, "BrowsePlexContent called with viewid: %s, mediatype: %s, nodetype: %s" % (viewid, mediatype, nodetype), 1)
utils.logMsg(title, "BrowsePlexContent called with viewid: %s, mediatype: %s, folderid: %s" % (viewid, mediatype, folderid), 1)
if nodetype == 'ondeck':
if folderid == 'ondeck':
xml = PlexFunctions.GetPlexOnDeck(
viewid,
containerSize=int(utils.settings('limitindex')))
@ -1365,8 +1365,27 @@ def BrowsePlexContent(viewid, mediatype="", nodetype=""):
utils.logMsg(title, "Cannot get view for section %s" % viewid, -1)
return
viewname = xml.attrib.get('librarySectionTitle')
xbmcplugin.setPluginCategory(int(sys.argv[1]), viewname)
if not folderid:
# Get all sections
xml = PlexFunctions.GetPlexSectionResults(
viewid,
containerSize=int(utils.settings('limitindex')))
try:
xml.attrib
except AttributeError:
utils.logMsg(title, "Error download section %s" % viewid, -1)
return
else:
xml = downloadutils.DownloadUtils().downloadUrl(
"{server}%s" % folderid)
try:
xml.attrib
except AttributeError:
utils.logMsg(title, "Error download %s" % folderid, -1)
return
xbmcplugin.setPluginCategory(int(sys.argv[1]),
xml.attrib.get('librarySectionTitle'))
# set the correct params for the content type
if mediatype.lower() == "homevideos, tvshows":
@ -1387,11 +1406,11 @@ def BrowsePlexContent(viewid, mediatype="", nodetype=""):
# folderId
li.setProperty('IsFolder', 'true')
li.setProperty('IsPlayable', 'false')
path = "%s?id=%s&mode=browsecontent&type=%s&folderid=%s" \
path = "%s?id=%s&mode=browseplex&type=%s&folderid=%s" \
% (utils.tryDecode(sys.argv[0]),
utils.tryDecode(viewname),
utils.tryDecode(type),
utils.tryDecode(item.get("Id")))
utils.tryDecode(viewid),
utils.tryDecode(mediatype),
utils.tryDecode(API.getKey()))
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True)
else:
# playable item, set plugin path and mediastreams

View file

@ -533,7 +533,7 @@ class LibrarySync(Thread):
folder = folderItem.attrib
mediatype = folder['type']
# Only process supported formats
if mediatype not in ('movie', 'show', 'artist'):
if mediatype not in ('movie', 'show', 'artist', 'photo'):
return totalnodes
# Prevent duplicate for nodes of the same type
@ -680,18 +680,20 @@ class LibrarySync(Thread):
self.nodes = {
'movie': [],
'show': [],
'artist': []
'artist': [],
'photo': []
}
self.playlists = {
'movie': [],
'show': [],
'artist': []
'artist': [],
'photo': []
}
self.sorted_views = []
for view in sections:
itemType = view.attrib['type']
if itemType in ('movie', 'show'): # and NOT artist for now
if itemType in ('movie', 'show', 'photo'): # NOT artist for now
self.sorted_views.append(view.attrib['title'])
self.logMsg('Sorted views: %s' % self.sorted_views, 1)

View file

@ -77,7 +77,7 @@ class VideoNodes(object):
"special://profile/library/video")))
# Create the node directory
if mediatype != "photo":
if mediatype != "photos":
if utils.IfExists(nodepath) is False:
# folder does not exist yet
self.logMsg('Creating folder %s' % nodepath, 1)
@ -101,13 +101,13 @@ class VideoNodes(object):
if window('Plex.nodes.%s.index' % i) == path:
return
if mediatype == "photo":
if mediatype == "photos":
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=getsubfolders" % indexnumber
window('Plex.nodes.%s.index' % indexnumber, value=path)
# Root
if not mediatype == "photo":
if not mediatype == "photos":
if viewtype == "mixed":
specialtag = "%s-%s" % (tagname, mediatype)
root = self.commonRoot(order=0, label=specialtag, tagname=tagname, roottype=0)
@ -217,14 +217,14 @@ class VideoNodes(object):
label = stringid
# Set window properties
if (mediatype == "homevideos" or mediatype == "photo") and nodetype == "all":
if (mediatype == "homevideos" or mediatype == "photos") and nodetype == "all":
# Custom query
path = ("plugin://plugin.video.plexkodiconnect/?id=%s&mode=browsecontent&type=%s"
% (tagname, mediatype))
elif (mediatype == "homevideos" or mediatype == "photo"):
path = ("plugin://plugin.video.plexkodiconnect/?id=%s&mode=browseplex&type=%s"
% (viewid, mediatype))
elif (mediatype == "homevideos" or mediatype == "photos"):
# Custom query
path = ("plugin://plugin.video.plexkodiconnect/?id=%s&mode=browsecontent&type=%s&folderid=%s"
% (tagname, mediatype, nodetype))
path = ("plugin://plugin.video.plexkodiconnect/?id=%s&mode=browseplex&type=%s&folderid=%s"
% (viewid, mediatype, nodetype))
elif nodetype == "nextepisodes":
# Custom query
path = "plugin://plugin.video.plexkodiconnect/?id=%s&mode=nextup&limit=%s" % (tagname, limit)
@ -247,7 +247,7 @@ class VideoNodes(object):
else:
path = "library://video/Plex-%s/%s_%s.xml" % (dirname, viewid, nodetype)
if mediatype == "photo":
if mediatype == "photos":
windowpath = "ActivateWindow(Pictures,%s,return)" % path
else:
windowpath = "ActivateWindow(Video,%s,return)" % path
@ -270,7 +270,7 @@ class VideoNodes(object):
window('%s.path' % embynode, value=windowpath)
window('%s.content' % embynode, value=path)
if mediatype == "photo":
if mediatype == "photos":
# For photos, we do not create a node in videos but we do want the window props
# to be created.
# To do: add our photos nodes to kodi picture sources somehow