Plex Companion: add itemType to playstate
This commit is contained in:
parent
bd6dca7342
commit
543253e10e
3 changed files with 22 additions and 13 deletions
|
@ -75,6 +75,7 @@ class Playqueue_Object(Playlist_Object_Baseclase):
|
|||
class Playlist_Item(object):
|
||||
ID = None # Plex playlist/playqueue id, e.g. playQueueItemID
|
||||
plex_id = None # Plex unique item id, "ratingKey"
|
||||
plex_type = None # Plex type, e.g. 'movie', 'clip'
|
||||
plex_UUID = None # Plex librarySectionUUID
|
||||
kodi_id = None # Kodi unique kodi id (unique only within type!)
|
||||
kodi_type = None # Kodi type: 'movie'
|
||||
|
@ -102,20 +103,22 @@ def playlist_item_from_kodi(kodi_item):
|
|||
"""
|
||||
item = Playlist_Item()
|
||||
item.kodi_id = kodi_item.get('id')
|
||||
item.kodi_type = kodi_item.get('type')
|
||||
if item.kodi_id:
|
||||
with plexdb.Get_Plex_DB() as plex_db:
|
||||
plex_dbitem = plex_db.getItem_byKodiId(kodi_item['id'],
|
||||
kodi_item['type'])
|
||||
try:
|
||||
item.plex_id = plex_dbitem[0]
|
||||
item.plex_type = plex_dbitem[2]
|
||||
item.plex_UUID = plex_dbitem[0] # we dont need the uuid yet :-)
|
||||
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 and item.file is not None:
|
||||
query = dict(parse_qsl(urlsplit(item.file).query))
|
||||
item.plex_id = query.get('plex_id')
|
||||
item.plex_type = query.get('itemType')
|
||||
if item.plex_id is None:
|
||||
item.uri = 'library://whatever/item/%s' % quote(item.file, safe='')
|
||||
else:
|
||||
|
@ -137,6 +140,7 @@ def playlist_item_from_plex(plex_id):
|
|||
with plexdb.Get_Plex_DB() as plex_db:
|
||||
plex_dbitem = plex_db.getItem_byId(plex_id)
|
||||
try:
|
||||
item.plex_type = plex_dbitem[5]
|
||||
item.kodi_id = plex_dbitem[0]
|
||||
item.kodi_type = plex_dbitem[4]
|
||||
except:
|
||||
|
@ -155,6 +159,7 @@ def playlist_item_from_xml(playlist, xml_video_element):
|
|||
item = Playlist_Item()
|
||||
api = API(xml_video_element)
|
||||
item.plex_id = api.getRatingKey()
|
||||
item.plex_type = api.getType()
|
||||
item.ID = xml_video_element.attrib['%sItemID' % playlist.kind]
|
||||
item.guid = xml_video_element.attrib.get('guid')
|
||||
if item.guid is not None:
|
||||
|
|
|
@ -122,7 +122,9 @@ class SubscriptionManager:
|
|||
ret += ' shuffle="%s"' % info['shuffle']
|
||||
ret += ' mute="%s"' % self.mute
|
||||
ret += ' repeat="%s"' % info['repeat']
|
||||
ret += ' itemType="%s"' % info['itemType']
|
||||
# Might need an update in the future
|
||||
if ptype == 'video':
|
||||
ret += ' subtitleStreamID="-1"'
|
||||
ret += ' audioStreamID="-1"'
|
||||
|
||||
|
@ -244,10 +246,11 @@ class SubscriptionManager:
|
|||
{"playerid": playerid,
|
||||
"properties": ["position"]})['position']
|
||||
try:
|
||||
info['playQueueItemID'] = playqueue.items[pos].ID
|
||||
info['guid'] = playqueue.items[pos].guid
|
||||
info['playQueueID'] = playqueue.ID
|
||||
info['playQueueVersion'] = playqueue.version
|
||||
info['playQueueItemID'] = playqueue.items[pos].ID or 'null'
|
||||
info['guid'] = playqueue.items[pos].guid or 'null'
|
||||
info['playQueueID'] = playqueue.ID or 'null'
|
||||
info['playQueueVersion'] = playqueue.version or 'null'
|
||||
info['itemType'] = playqueue.items[pos].plex_type or 'null'
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
|
|
|
@ -258,10 +258,11 @@ class Plex_DB_Functions():
|
|||
|
||||
def getItem_byKodiId(self, kodi_id, kodi_type):
|
||||
"""
|
||||
Returns the tuple (plex_id, parent_id) for kodi_id and kodi_type
|
||||
Returns the tuple (plex_id, parent_id, plex_type) for kodi_id and
|
||||
kodi_type
|
||||
"""
|
||||
query = '''
|
||||
SELECT plex_id, parent_id
|
||||
SELECT plex_id, parent_id, plex_type
|
||||
FROM plex
|
||||
WHERE kodi_id = ?
|
||||
AND kodi_type = ?
|
||||
|
|
Loading…
Reference in a new issue