Save Plex playlist details on initialization
This commit is contained in:
parent
376338a9b0
commit
e637f36a21
2 changed files with 14 additions and 4 deletions
|
@ -459,7 +459,8 @@ def update_playlist_from_PMS(playlist, playlist_id=None, xml=None):
|
|||
|
||||
def init_plex_playlist(playlist, plex_id):
|
||||
"""
|
||||
Initializes a new playlist on the PMS side
|
||||
Initializes a new playlist on the PMS side. Returns True if it worked,
|
||||
False otherwise. Will set playlist.id and playlist.plex_updatedat
|
||||
"""
|
||||
LOG.debug('Initializing the playlist with Plex id %s on the Plex side: %s',
|
||||
plex_id, playlist)
|
||||
|
@ -473,8 +474,16 @@ def init_plex_playlist(playlist, plex_id):
|
|||
xml = DU().downloadUrl(url='{server}/playlists',
|
||||
action_type='POST',
|
||||
parameters=params)
|
||||
get_playlist_details_from_xml(playlist, xml)
|
||||
LOG.debug('Initialized the playlist on the Plex side: %s', playlist)
|
||||
try:
|
||||
xml[0].attrib
|
||||
except (TypeError, IndexError, AttributeError):
|
||||
LOG.error('Could not initialize playlist on Plex side with plex id %s',
|
||||
plex_id)
|
||||
return False
|
||||
api = API(xml[0])
|
||||
playlist.id = api.plex_id()
|
||||
playlist.plex_updatedat = api.updated_at()
|
||||
return True
|
||||
|
||||
|
||||
def init_plex_playqueue(playlist, plex_id=None, kodi_item=None):
|
||||
|
|
|
@ -54,7 +54,8 @@ def create_plex_playlist(playlist=None, path=None):
|
|||
raise PL.PlaylistError
|
||||
for pos, plex_id in enumerate(plex_ids):
|
||||
if pos == 0:
|
||||
PL.init_plex_playlist(playlist, plex_id)
|
||||
if not PL.init_plex_playlist(playlist, plex_id):
|
||||
return
|
||||
else:
|
||||
PL.add_item_to_PMS_playlist(playlist, pos, plex_id=plex_id)
|
||||
update_plex_table(playlist, update_kodi_hash=True)
|
||||
|
|
Loading…
Reference in a new issue