Change way item is added to Plex playqueue by using PMS machine identifier
This commit is contained in:
parent
9139669f44
commit
0d7a1b3a9f
3 changed files with 14 additions and 29 deletions
|
@ -234,14 +234,9 @@ def _playback_init(plex_id, plex_type, playqueue, pos):
|
||||||
playqueue.clear()
|
playqueue.clear()
|
||||||
if plex_type != v.PLEX_TYPE_CLIP:
|
if plex_type != v.PLEX_TYPE_CLIP:
|
||||||
# Post to the PMS to create a playqueue - in any case due to Companion
|
# Post to the PMS to create a playqueue - in any case due to Companion
|
||||||
section_uuid = xml.attrib.get('librarySectionUUID')
|
xml = PF.init_plex_playqueue(plex_id, plex_type, trailers=trailers)
|
||||||
xml = PF.init_plex_playqueue(plex_id,
|
|
||||||
section_uuid,
|
|
||||||
mediatype=plex_type,
|
|
||||||
trailers=trailers)
|
|
||||||
if xml is None:
|
if xml is None:
|
||||||
LOG.error('Could not get a playqueue xml for plex id %s, UUID %s',
|
LOG.error('Could not get a playqueue xml for plex id %s', plex_id)
|
||||||
plex_id, section_uuid)
|
|
||||||
# "Play error"
|
# "Play error"
|
||||||
utils.dialog('notification',
|
utils.dialog('notification',
|
||||||
utils.lang(29999),
|
utils.lang(29999),
|
||||||
|
|
|
@ -137,11 +137,10 @@ class Playlist_Item(object):
|
||||||
id = None [int] Plex playlist/playqueue id, e.g. playQueueItemID
|
id = None [int] Plex playlist/playqueue id, e.g. playQueueItemID
|
||||||
plex_id = None [int] Plex unique item id, "ratingKey"
|
plex_id = None [int] Plex unique item id, "ratingKey"
|
||||||
plex_type = None [str] Plex type, e.g. 'movie', 'clip'
|
plex_type = None [str] Plex type, e.g. 'movie', 'clip'
|
||||||
plex_uuid = None [str] Plex librarySectionUUID
|
|
||||||
kodi_id = None [int] Kodi unique kodi id (unique only within type!)
|
kodi_id = None [int] Kodi unique kodi id (unique only within type!)
|
||||||
kodi_type = None [str] Kodi type: 'movie'
|
kodi_type = None [str] Kodi type: 'movie'
|
||||||
file = None [str] Path to the item's file. STRING!!
|
file = None [str] Path to the item's file. STRING!!
|
||||||
uri = None [str] Weird Plex uri path involving plex_uuid. STRING!
|
uri = None [str] PMS path to item; will be auto-set with plex_id
|
||||||
guid = None [str] Weird Plex guid
|
guid = None [str] Weird Plex guid
|
||||||
xml = None [etree] XML from PMS, 1 lvl below <MediaContainer>
|
xml = None [etree] XML from PMS, 1 lvl below <MediaContainer>
|
||||||
playmethod = None [str] either 'DirectPlay', 'DirectStream', 'Transcode'
|
playmethod = None [str] either 'DirectPlay', 'DirectStream', 'Transcode'
|
||||||
|
@ -154,11 +153,10 @@ class Playlist_Item(object):
|
||||||
self._id = None
|
self._id = None
|
||||||
self._plex_id = None
|
self._plex_id = None
|
||||||
self.plex_type = None
|
self.plex_type = None
|
||||||
self.plex_uuid = None
|
|
||||||
self._kodi_id = None
|
self._kodi_id = None
|
||||||
self.kodi_type = None
|
self.kodi_type = None
|
||||||
self.file = None
|
self.file = None
|
||||||
self.uri = None
|
self._uri = None
|
||||||
self.guid = None
|
self.guid = None
|
||||||
self.xml = None
|
self.xml = None
|
||||||
self.playmethod = None
|
self.playmethod = None
|
||||||
|
@ -182,6 +180,12 @@ class Playlist_Item(object):
|
||||||
if not isinstance(value, int) and value is not None:
|
if not isinstance(value, int) and value is not None:
|
||||||
raise TypeError('Passed %s instead of int!' % type(value))
|
raise TypeError('Passed %s instead of int!' % type(value))
|
||||||
self._plex_id = value
|
self._plex_id = value
|
||||||
|
self._uri = ('server://%s/com.plexapp.plugins.library/library/metadata/%s' %
|
||||||
|
(app.CONN.machine_identifier, value))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def uri(self):
|
||||||
|
return self._uri
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self):
|
def id(self):
|
||||||
|
@ -238,11 +242,9 @@ class Playlist_Item(object):
|
||||||
"'id': {self.id}, "
|
"'id': {self.id}, "
|
||||||
"'plex_id': {self.plex_id}, "
|
"'plex_id': {self.plex_id}, "
|
||||||
"'plex_type': '{self.plex_type}', "
|
"'plex_type': '{self.plex_type}', "
|
||||||
"'plex_uuid': '{self.plex_uuid}', "
|
|
||||||
"'kodi_id': {self.kodi_id}, "
|
"'kodi_id': {self.kodi_id}, "
|
||||||
"'kodi_type': '{self.kodi_type}', "
|
"'kodi_type': '{self.kodi_type}', "
|
||||||
"'file': '{self.file}', "
|
"'file': '{self.file}', "
|
||||||
"'uri': '{self.uri}', "
|
|
||||||
"'guid': '{self.guid}', "
|
"'guid': '{self.guid}', "
|
||||||
"'playmethod': '{self.playmethod}', "
|
"'playmethod': '{self.playmethod}', "
|
||||||
"'playcount': {self.playcount}, "
|
"'playcount': {self.playcount}, "
|
||||||
|
@ -328,7 +330,6 @@ def playlist_item_from_kodi(kodi_item):
|
||||||
if db_item:
|
if db_item:
|
||||||
item.plex_id = db_item['plex_id']
|
item.plex_id = db_item['plex_id']
|
||||||
item.plex_type = db_item['plex_type']
|
item.plex_type = db_item['plex_type']
|
||||||
item.plex_uuid = db_item['plex_id'] # we dont need the uuid yet :-)
|
|
||||||
item.file = kodi_item.get('file')
|
item.file = kodi_item.get('file')
|
||||||
if item.plex_id is None and item.file is not None:
|
if item.plex_id is None and item.file is not None:
|
||||||
try:
|
try:
|
||||||
|
@ -338,13 +339,6 @@ def playlist_item_from_kodi(kodi_item):
|
||||||
query = dict(utils.parse_qsl(query))
|
query = dict(utils.parse_qsl(query))
|
||||||
item.plex_id = utils.cast(int, query.get('plex_id'))
|
item.plex_id = utils.cast(int, query.get('plex_id'))
|
||||||
item.plex_type = query.get('itemType')
|
item.plex_type = query.get('itemType')
|
||||||
if item.plex_id is None and item.file is not None:
|
|
||||||
item.uri = ('library://whatever/item/%s'
|
|
||||||
% utils.quote(item.file, safe=''))
|
|
||||||
else:
|
|
||||||
# TO BE VERIFIED - PLEX DOESN'T LIKE PLAYLIST ADDS IN THIS MANNER
|
|
||||||
item.uri = ('library://%s/item/library%%2Fmetadata%%2F%s' %
|
|
||||||
(item.plex_uuid, item.plex_id))
|
|
||||||
LOG.debug('Made playlist item from Kodi: %s', item)
|
LOG.debug('Made playlist item from Kodi: %s', item)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
@ -408,9 +402,6 @@ def playlist_item_from_plex(plex_id):
|
||||||
item.kodi_type = db_item['kodi_type']
|
item.kodi_type = db_item['kodi_type']
|
||||||
else:
|
else:
|
||||||
raise KeyError('Could not find plex_id %s in database' % plex_id)
|
raise KeyError('Could not find plex_id %s in database' % plex_id)
|
||||||
item.plex_uuid = plex_id
|
|
||||||
item.uri = ('library://%s/item/library%%2Fmetadata%%2F%s' %
|
|
||||||
(item.plex_uuid, plex_id))
|
|
||||||
LOG.debug('Made playlist item from plex: %s', item)
|
LOG.debug('Made playlist item from plex: %s', item)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
|
@ -820,16 +820,15 @@ def get_plex_sections():
|
||||||
return xml
|
return xml
|
||||||
|
|
||||||
|
|
||||||
def init_plex_playqueue(plex_id, librarySectionUUID, mediatype='movie',
|
def init_plex_playqueue(plex_id, plex_type, trailers=False):
|
||||||
trailers=False):
|
|
||||||
"""
|
"""
|
||||||
Returns raw API metadata XML dump for a playlist with e.g. trailers.
|
Returns raw API metadata XML dump for a playlist with e.g. trailers.
|
||||||
"""
|
"""
|
||||||
url = "{server}/playQueues"
|
url = "{server}/playQueues"
|
||||||
args = {
|
args = {
|
||||||
'type': mediatype,
|
'type': plex_type,
|
||||||
'uri': ('library://{0}/item/%2Flibrary%2Fmetadata%2F{1}'.format(
|
'uri': ('server://%s/com.plexapp.plugins.library/library/metadata/%s' %
|
||||||
librarySectionUUID, plex_id)),
|
(app.CONN.machine_identifier, plex_id)),
|
||||||
'includeChapters': '1',
|
'includeChapters': '1',
|
||||||
'shuffle': '0',
|
'shuffle': '0',
|
||||||
'repeat': '0'
|
'repeat': '0'
|
||||||
|
|
Loading…
Reference in a new issue