Add Plex ID to photo ListItems

This commit is contained in:
tomkat83 2017-03-26 14:09:43 +02:00
parent 4de4959c53
commit 2a5cf9d798
2 changed files with 13 additions and 15 deletions

View file

@ -1210,7 +1210,8 @@ class API():
def get_picture_path(self): 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() extension = self.item[0][0].attrib['key'][self.item[0][0].attrib['key'].rfind('.'):].lower()
if (window('plex_force_transcode_pix') == 'true' or if (window('plex_force_transcode_pix') == 'true' or
@ -1224,19 +1225,12 @@ class API():
1920, 1920,
1080) 1080)
else: else:
# Don't transcode
if window('useDirectPaths') == 'true':
# Addon Mode. Just give the path of the file to Kodi
path = self.addPlexCredentialsToUrl( path = self.addPlexCredentialsToUrl(
'%s%s' % (window('pms_server'), '%s%s' % (window('pms_server'),
self.item[0][0].attrib['key'])) self.item[0][0].attrib['key']))
else: # Attach Plex id to url to let it be picked up by our playqueue agent
# Native direct paths # later
path = self.validatePlayurl( return tryEncode('%s&plex_id=%s' % (path, self.getRatingKey()))
self.getFilePath(forceFirstMediaStream=True),
'photo')
path = tryEncode(path)
return path
def getTVShowPath(self): def getTVShowPath(self):
""" """

View file

@ -1,9 +1,10 @@
import logging import logging
from urllib import quote from urllib import quote
from urlparse import parse_qsl, urlsplit
import plexdb_functions as plexdb import plexdb_functions as plexdb
from downloadutils import DownloadUtils as DU from downloadutils import DownloadUtils as DU
from utils import JSONRPC, tryEncode, tryDecode from utils import JSONRPC, tryEncode
from PlexAPI import API from PlexAPI import API
############################################################################### ###############################################################################
@ -111,6 +112,9 @@ def playlist_item_from_kodi(kodi_item):
except TypeError: except TypeError:
pass pass
item.file = kodi_item.get('file') 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') item.kodi_type = kodi_item.get('type')
if item.plex_id is None: if item.plex_id is None:
item.uri = 'library://whatever/item/%s' % quote(item.file, safe='') item.uri = 'library://whatever/item/%s' % quote(item.file, safe='')