Plex photos

This commit is contained in:
tomkat83 2016-06-12 17:22:22 +02:00
parent 9a5533337f
commit 6689b265f2
6 changed files with 100 additions and 56 deletions

View file

@ -390,6 +390,8 @@
<string id="39042">Replace Plex MUSIC with:</string>
<string id="39043">Go a step further and completely replace all original Plex library paths (/volume1/media) with custom SMB paths (smb://NAS/MyStuff)?</string>
<string id="39044">Please enter your custom smb paths in the settings under "Sync Options" and then restart Kodi</string>
<string id="39045">Original Plex PHOTO path to replace:</string>
<string id="39046">Replace Plex PHOTO with:</string>
<string id="39045">Appearance Tweaks</string>
<string id="39046">TV Shows</string>

View file

@ -329,6 +329,8 @@
<string id="39042">Plex MUSIK Pfade ersetzen durch:</string>
<string id="39043">Sollen sogar sämtliche Plex Pfade wie /volume1/Hans/medien durch benutzerdefinierte smb Pfade wie smb://NAS/Filme ersetzt werden?</string>
<string id="39044">Bitte geben Sie Ihre benutzerdefinierten SMB Pfade nun in den Einstellungen unter Sync Optionen ein. Starten Sie dann Kodi neu.</string>
<string id="39045">Ursprünglicher Plex Pfad für PHOTOS:</string>
<string id="39046">Plex PHOTO Pfade ersetzen durch:</string>
<string id="39045">Erscheinung</string>
<string id="39046">TV Serien</string>

View file

@ -2289,6 +2289,16 @@ class API():
self.logMsg('Found external subs: %s' % externalsubs)
return externalsubs
def GetFileSize(self):
"""
Returns the item's filesize in bytes or 0 (int) if unsuccessful
"""
try:
ans = int(self.item[0][0].attrib['size'])
except:
ans = 0
return ans
def CreateListItemFromPlexItem(self, listItem=None,
appendShowTitle=False, appendSxxExx=False):
"""
@ -2301,35 +2311,43 @@ class API():
Returns XBMC listitem for this PMS library item
"""
people = self.getPeople()
userdata = self.getUserData()
title, sorttitle = self.getTitle()
typus = self.getType()
if listItem is None:
listItem = xbmcgui.ListItem(title)
listItem.setProperty('IsPlayable', 'true')
metadata = {
'genre': self.joinList(self.getGenres()),
'year': self.getYear(),
'rating': self.getAudienceRating(),
'playcount': userdata['PlayCount'],
'cast': people['Cast'],
'director': self.joinList(people.get('Director')),
'plot': self.getPlot(),
'sorttitle': sorttitle,
'duration': userdata['Runtime'],
'studio': self.joinList(self.getStudios()),
'tagline': self.getTagline(),
'writer': self.joinList(people.get('Writer')),
'premiered': self.getPremiereDate(),
'dateadded': self.getDateCreated(),
'lastplayed': userdata['LastPlayedDate'],
'mpaa': self.getMpaa(),
'aired': self.getPremiereDate()
}
if typus != 'photo':
# Video items, e.g. movies and episodes or clips
people = self.getPeople()
userdata = self.getUserData()
metadata = {
'genre': self.joinList(self.getGenres()),
'year': self.getYear(),
'rating': self.getAudienceRating(),
'playcount': userdata['PlayCount'],
'cast': people['Cast'],
'director': self.joinList(people.get('Director')),
'plot': self.getPlot(),
'sorttitle': sorttitle,
'duration': userdata['Runtime'],
'studio': self.joinList(self.getStudios()),
'tagline': self.getTagline(),
'writer': self.joinList(people.get('Writer')),
'premiered': self.getPremiereDate(),
'dateadded': self.getDateCreated(),
'lastplayed': userdata['LastPlayedDate'],
'mpaa': self.getMpaa(),
'aired': self.getPremiereDate()
}
listItem.setProperty('resumetime', str(userdata['Resume']))
listItem.setProperty('totaltime', str(userdata['Runtime']))
else:
# E.g. photo
metadata = {'size': self.GetFileSize()}
if self.getType() == "episode":
if typus == "episode":
# Only for tv shows
key, show, season, episode = self.getEpisodeDetails()
season = -1 if season is None else int(season)
@ -2345,13 +2363,14 @@ class API():
listItem.setIconImage('DefaultTVShows.png')
if appendShowTitle is True:
title = show + ' - ' + title
elif self.getType() == "movie":
elif typus == "movie":
listItem.setIconImage('DefaultMovies.png')
elif typus == "photo":
listItem.setIconImage('DefaultPicture.png')
else:
# E.g. clips, trailers, ...
listItem.setIconImage('DefaultVideo.png')
listItem.setProperty('resumetime', str(userdata['Resume']))
listItem.setProperty('totaltime', str(userdata['Runtime']))
plexId = self.getRatingKey()
listItem.setProperty('plexid', plexId)
with embydb.GetEmbyDB() as emby_db:
@ -2363,7 +2382,10 @@ class API():
# Expensive operation
metadata['title'] = title
listItem.setLabel(title)
listItem.setInfo('video', infoLabels=metadata)
if typus != 'photo':
listItem.setInfo('video', infoLabels=metadata)
else:
listItem.setInfo('pictures', infoLabels=metadata)
return listItem
def AddStreamInfo(self, listItem):

View file

@ -192,8 +192,16 @@ def doPlayback(itemid, dbid):
if xml in (None, 401):
return xbmcplugin.setResolvedUrl(
int(sys.argv[1]), False, xbmcgui.ListItem())
# Everything OK
return pbutils.PlaybackUtils(xml).play(itemid, dbid)
if xml[0].attrib.get('type') == 'photo':
# Photo
API = PlexAPI.API(xml[0])
listitem = API.CreateListItemFromPlexItem()
API.AddStreamInfo(listitem)
pbutils.PlaybackUtils(xml[0]).setArtwork(listitem)
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
else:
# Video
return pbutils.PlaybackUtils(xml).play(itemid, dbid)
# utils.logMsg(title, "doPlayback called with itemid=%s, dbid=%s"
# % (itemid, dbid), 1)
@ -1356,17 +1364,11 @@ def BrowsePlexContent(viewid, mediatype="", folderid=""):
mediatype: mediatype, 'photos'
nodetype: e.g. 'ondeck' (TBD!!)
"""
utils.logMsg(title, "BrowsePlexContent called with viewid: %s, mediatype: %s, folderid: %s" % (viewid, mediatype, folderid), 1)
if folderid == 'ondeck':
xml = PlexFunctions.GetPlexOnDeck(
viewid,
containerSize=int(utils.settings('limitindex')))
if not xml:
utils.logMsg(title, "Cannot get view for section %s" % viewid, -1)
return
utils.logMsg(title, "BrowsePlexContent called with viewid: %s, mediatype: "
"%s, folderid: %s" % (viewid, mediatype, folderid), 2)
if not folderid:
# Top-level navigation, so get the content of this section
# Get all sections
xml = PlexFunctions.GetPlexSectionResults(
viewid,
@ -1375,28 +1377,26 @@ def BrowsePlexContent(viewid, mediatype="", folderid=""):
xml.attrib
except AttributeError:
utils.logMsg(title, "Error download section %s" % viewid, -1)
return
return xbmcplugin.endOfDirectory(int(sys.argv[1]), False)
else:
# folderid was passed so we can directly access the folder
xml = downloadutils.DownloadUtils().downloadUrl(
"{server}%s" % folderid)
try:
xml.attrib
except AttributeError:
utils.logMsg(title, "Error download %s" % folderid, -1)
return
utils.logMsg(title, "Error downloading %s" % folderid, -1)
return xbmcplugin.endOfDirectory(int(sys.argv[1]), False)
# Set the folder's name
xbmcplugin.setPluginCategory(int(sys.argv[1]),
xml.attrib.get('librarySectionTitle'))
# set the correct params for the content type
if mediatype.lower() == "homevideos, tvshows":
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
itemtype = "Video,Folder,PhotoAlbum"
elif mediatype.lower() == "photos":
xbmcplugin.setContent(int(sys.argv[1]), 'files')
itemtype = "Photo,PhotoAlbum,Folder"
else:
itemtype = ""
# process the listing
for item in xml:
@ -1408,20 +1408,32 @@ def BrowsePlexContent(viewid, mediatype="", folderid=""):
li.setProperty('IsFolder', 'true')
li.setProperty('IsPlayable', 'false')
path = "%s?id=%s&mode=browseplex&type=%s&folderid=%s" \
% (utils.tryDecode(sys.argv[0]),
utils.tryDecode(viewid),
utils.tryDecode(mediatype),
utils.tryDecode(API.getKey()))
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True)
% (sys.argv[0], viewid, mediatype, API.getKey())
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
url=path,
listitem=li,
isFolder=True)
else:
# playable item, set plugin path and mediastreams
path = "%s?id=%s&mode=play" % (sys.argv[0], API.getRatingKey())
li.setProperty("path", path)
API.AddStreamInfo(li)
if item.attrib.get('type') == 'photo':
# pictures
if utils.settings('useDirectPaths') == '0':
# Addon paths
path = '%s%s' % (utils.window('pms_server'),
item[0][0].attrib['key'])
path = API.addPlexCredentialsToUrl(path)
else:
# Direct paths
path = item[0][0].attrib['file']
li.setProperty('picturepath', path)
else:
# videos
path = "%s?id=%s&mode=play" % (sys.argv[0], API.getRatingKey())
li.setProperty("path", path)
API.AddStreamInfo(li)
pbutils.PlaybackUtils(item).setArtwork(li)
xbmcplugin.addDirectoryItem(
handle=int(sys.argv[1]),
url=li.getProperty("path"),
url=path,
listitem=li)
if filter == "recent":
@ -1432,7 +1444,10 @@ def BrowsePlexContent(viewid, mediatype="", folderid=""):
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_RATING)
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_RUNTIME)
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
xbmcplugin.endOfDirectory(
handle=int(sys.argv[1]),
cacheToDisc=True if utils.settings('enableTextureCache') == 'true'
else False)
def getOnDeck(viewid, mediatype, tagname, limit):

View file

@ -76,6 +76,8 @@
<setting id="remapSMBtvNew" type="text" label="39040" default="smb://" visible="eq(-4,true)"/> <!-- Replace Plex TV SHOWS with: -->
<setting id="remapSMBmusicOrg" type="text" label="39041" default="" visible="eq(-5,true)"/> <!-- Original Plex MUSIC path to replace: -->
<setting id="remapSMBmusicNew" type="text" label="39042" default="smb://" visible="eq(-6,true)"/> <!-- Replace Plex MUSIC with: -->
<setting id="remapSMBphotoOrg" type="text" label="39045" default="" visible="eq(-7,true)"/> <!-- Original Plex MUSIC path to replace: -->
<setting id="remapSMBphotoNew" type="text" label="39046" default="smb://" visible="eq(-8,true)"/> <!-- Replace Plex MUSIC with: -->
</category>
<category label="30516"><!-- Playback -->

View file

@ -96,7 +96,8 @@ class Service():
"plex_authenticated", "PlexUserImage", "useDirectPaths",
"replaceSMB", "remapSMB", "remapSMBmovieOrg", "remapSMBtvOrg",
"remapSMBmusicOrg", "remapSMBmovieNew", "remapSMBtvNew",
"remapSMBmusicNew", "suspend_LibraryThread", "plex_terminateNow",
"remapSMBmusicNew", "remapSMBphotoOrg", "remapSMBphotoNew",
"suspend_LibraryThread", "plex_terminateNow",
"kodiplextimeoffset", "countError", "countUnauthorized"
]
for prop in properties: