diff --git a/resources/lib/playback.py b/resources/lib/playback.py index 441d71b6..8bbc706c 100644 --- a/resources/lib/playback.py +++ b/resources/lib/playback.py @@ -234,14 +234,9 @@ def _playback_init(plex_id, plex_type, playqueue, pos): playqueue.clear() if plex_type != v.PLEX_TYPE_CLIP: # 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, - section_uuid, - mediatype=plex_type, - trailers=trailers) + xml = PF.init_plex_playqueue(plex_id, plex_type, trailers=trailers) if xml is None: - LOG.error('Could not get a playqueue xml for plex id %s, UUID %s', - plex_id, section_uuid) + LOG.error('Could not get a playqueue xml for plex id %s', plex_id) # "Play error" utils.dialog('notification', utils.lang(29999), diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index 1dd1443e..09cc596e 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -152,11 +152,10 @@ class Playlist_Item(object): id = None [int] Plex playlist/playqueue id, e.g. playQueueItemID plex_id = None [int] Plex unique item id, "ratingKey" 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_type = None [str] Kodi type: 'movie' 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 xml = None [etree] XML from PMS, 1 lvl below playmethod = None [str] either 'DirectPlay', 'DirectStream', 'Transcode' @@ -169,11 +168,10 @@ class Playlist_Item(object): self._id = None self._plex_id = None self.plex_type = None - self.plex_uuid = None self._kodi_id = None self.kodi_type = None self.file = None - self.uri = None + self._uri = None self.guid = None self.xml = None self.playmethod = None @@ -197,6 +195,12 @@ class Playlist_Item(object): if not isinstance(value, int) and value is not None: raise TypeError('Passed %s instead of int!' % type(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 def id(self): @@ -253,11 +257,9 @@ class Playlist_Item(object): "'id': {self.id}, " "'plex_id': {self.plex_id}, " "'plex_type': '{self.plex_type}', " - "'plex_uuid': '{self.plex_uuid}', " "'kodi_id': {self.kodi_id}, " "'kodi_type': '{self.kodi_type}', " "'file': '{self.file}', " - "'uri': '{self.uri}', " "'guid': '{self.guid}', " "'playmethod': '{self.playmethod}', " "'playcount': {self.playcount}, " @@ -343,7 +345,6 @@ def playlist_item_from_kodi(kodi_item): if db_item: item.plex_id = db_item['plex_id'] 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') if item.plex_id is None and item.file is not None: try: @@ -353,13 +354,6 @@ def playlist_item_from_kodi(kodi_item): query = dict(utils.parse_qsl(query)) item.plex_id = utils.cast(int, query.get('plex_id')) 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) return item @@ -423,9 +417,6 @@ def playlist_item_from_plex(plex_id): item.kodi_type = db_item['kodi_type'] else: 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) return item diff --git a/resources/lib/plex_functions.py b/resources/lib/plex_functions.py index 1b7e8fbc..a89fbf16 100644 --- a/resources/lib/plex_functions.py +++ b/resources/lib/plex_functions.py @@ -820,16 +820,15 @@ def get_plex_sections(): return xml -def init_plex_playqueue(plex_id, librarySectionUUID, mediatype='movie', - trailers=False): +def init_plex_playqueue(plex_id, plex_type, trailers=False): """ Returns raw API metadata XML dump for a playlist with e.g. trailers. """ url = "{server}/playQueues" args = { - 'type': mediatype, - 'uri': ('library://{0}/item/%2Flibrary%2Fmetadata%2F{1}'.format( - librarySectionUUID, plex_id)), + 'type': plex_type, + 'uri': ('server://%s/com.plexapp.plugins.library/library/metadata/%s' % + (app.CONN.machine_identifier, plex_id)), 'includeChapters': '1', 'shuffle': '0', 'repeat': '0'