From 2a5cf9d798899c5b1e5a4601913180c3f0715c81 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 26 Mar 2017 14:09:43 +0200 Subject: [PATCH] Add Plex ID to photo ListItems --- resources/lib/PlexAPI.py | 22 ++++++++-------------- resources/lib/playlist_func.py | 6 +++++- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 9f69b026..a324f2e2 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -1210,7 +1210,8 @@ class API(): def get_picture_path(self): """ - Returns the item's picture path (transcode, if necessary) as string + Returns the item's picture path (transcode, if necessary) as string. + Will always use addon paths, never direct paths """ extension = self.item[0][0].attrib['key'][self.item[0][0].attrib['key'].rfind('.'):].lower() if (window('plex_force_transcode_pix') == 'true' or @@ -1224,19 +1225,12 @@ class API(): 1920, 1080) else: - # Don't transcode - if window('useDirectPaths') == 'true': - # Addon Mode. Just give the path of the file to Kodi - path = self.addPlexCredentialsToUrl( - '%s%s' % (window('pms_server'), - self.item[0][0].attrib['key'])) - else: - # Native direct paths - path = self.validatePlayurl( - self.getFilePath(forceFirstMediaStream=True), - 'photo') - path = tryEncode(path) - return path + path = self.addPlexCredentialsToUrl( + '%s%s' % (window('pms_server'), + self.item[0][0].attrib['key'])) + # Attach Plex id to url to let it be picked up by our playqueue agent + # later + return tryEncode('%s&plex_id=%s' % (path, self.getRatingKey())) def getTVShowPath(self): """ diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index ee336a73..5fb9289c 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -1,9 +1,10 @@ import logging from urllib import quote +from urlparse import parse_qsl, urlsplit import plexdb_functions as plexdb from downloadutils import DownloadUtils as DU -from utils import JSONRPC, tryEncode, tryDecode +from utils import JSONRPC, tryEncode from PlexAPI import API ############################################################################### @@ -111,6 +112,9 @@ def playlist_item_from_kodi(kodi_item): except TypeError: pass item.file = kodi_item.get('file') + if item.file is not None and item.plex_id is None: + item.plex_id = dict( + parse_qsl(urlsplit(item.file).query)).get('plex_id') item.kodi_type = kodi_item.get('type') if item.plex_id is None: item.uri = 'library://whatever/item/%s' % quote(item.file, safe='')