This commit is contained in:
croneter 2019-05-25 13:12:29 +02:00
parent 9d79f78190
commit f7237d7033
2 changed files with 13 additions and 26 deletions

View file

@ -250,24 +250,6 @@ class KodiMonitor(xbmc.Monitor):
plex_type = db_item['plex_type']
return plex_id, plex_type
@staticmethod
def _add_remaining_items_to_playlist(playqueue):
"""
Adds all but the very first item of the Kodi playlist to the Plex
playqueue
"""
items = js.playlist_get_items(playqueue.playlistid)
if not items:
LOG.error('Could not retrieve Kodi playlist items')
return
# Remove first item
items.pop(0)
try:
for i, item in enumerate(items):
PL.add_item_to_plex_playqueue(playqueue, i + 1, kodi_item=item)
except PL.PlaylistError:
LOG.info('Could not build Plex playlist for: %s', items)
def _json_item(self, playerid):
"""
Uses JSON RPC to get the playing item's info and returns the tuple
@ -320,15 +302,15 @@ class KodiMonitor(xbmc.Monitor):
position = info['position'] if info['position'] != -1 else 0
kodi_playlist = js.playlist_get_items(self.playerid)
LOG.debug('Current Kodi playlist: %s', kodi_playlist)
kodi_item = PL.playlist_item_from_kodi(kodi_playlist[position])
playlistitem = PL.PlaylistItem(kodi_item=kodi_playlist[position])
if isinstance(self.playqueue.items[0], PL.PlaylistItemDummy):
# This dummy item will be deleted by webservice soon - it won't
# play
LOG.debug('Dummy item detected')
position = 1
elif kodi_item != self.playqueue.items[position]:
elif playlistitem != self.playqueue.items[position]:
LOG.debug('Different playqueue items: %s vs. %s ',
kodi_item, self.playqueue.items[position])
playlistitem, self.playqueue.items[position])
raise MonitorError()
# Return the PKC playqueue item - contains more info
return self.playqueue.items[position]

View file

@ -582,7 +582,7 @@ class PlaylistItem(object):
- OR: have the same file
"""
def __init__(self, plex_id=None, plex_type=None, xml_video_element=None,
kodi_id=None, kodi_type=None, grab_xml=False,
kodi_id=None, kodi_type=None, kodi_item=None, grab_xml=False,
lookup_kodi=True):
"""
Pass grab_xml=True in order to get Plex metadata from the PMS while
@ -595,9 +595,14 @@ class PlaylistItem(object):
self.plex_id = plex_id
self.plex_type = plex_type
self.plex_uuid = None
self.kodi_id = kodi_id
self.kodi_type = kodi_type
self.file = None
if kodi_item:
self.kodi_id = kodi_item['id']
self.kodi_type = kodi_item['type']
self.file = kodi_item.get('file')
else:
self.kodi_id = kodi_id
self.kodi_type = kodi_type
self.file = None
self.uri = None
self.guid = None
self.xml = None
@ -619,7 +624,7 @@ class PlaylistItem(object):
xml_video_element = None
if xml_video_element is not None:
self.from_xml(xml_video_element)
if (lookup_kodi and (kodi_id is None or kodi_type is None) and
if (lookup_kodi and (self.kodi_id is None or self.kodi_type is None) and
self.plex_type != v.PLEX_TYPE_CLIP):
with PlexDB(lock=False) as plexdb:
db_item = plexdb.item_by_id(self.plex_id, self.plex_type)