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', 'album': 'music',
'song': 'music', 'song': 'music',
'track': 'music', 'track': 'music',
'clip': 'clip' 'clip': 'clip',
'photo': 'photo'
} }
typus = types[typus] typus = types[typus]
if utils.window('remapSMB') == 'true': if utils.window('remapSMB') == 'true':

View file

@ -1348,16 +1348,16 @@ def RunLibScan(mode):
utils.window('plex_runLibScan', value='full') 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 viewid: PMS name of the library
mediatype: mediatype, e.g. 'movies', 'tvshows', 'photos' mediatype: mediatype, 'photos'
nodetype: e.g. 'ondeck' 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( xml = PlexFunctions.GetPlexOnDeck(
viewid, viewid,
containerSize=int(utils.settings('limitindex'))) 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) utils.logMsg(title, "Cannot get view for section %s" % viewid, -1)
return return
viewname = xml.attrib.get('librarySectionTitle') if not folderid:
xbmcplugin.setPluginCategory(int(sys.argv[1]), viewname) # 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 # set the correct params for the content type
if mediatype.lower() == "homevideos, tvshows": if mediatype.lower() == "homevideos, tvshows":
@ -1387,11 +1406,11 @@ def BrowsePlexContent(viewid, mediatype="", nodetype=""):
# folderId # folderId
li.setProperty('IsFolder', 'true') li.setProperty('IsFolder', 'true')
li.setProperty('IsPlayable', 'false') 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(sys.argv[0]),
utils.tryDecode(viewname), utils.tryDecode(viewid),
utils.tryDecode(type), utils.tryDecode(mediatype),
utils.tryDecode(item.get("Id"))) utils.tryDecode(API.getKey()))
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True)
else: else:
# playable item, set plugin path and mediastreams # playable item, set plugin path and mediastreams

View file

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

View file

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