Don't let librarysync crash if Plex playlist deletion doesnt work

This commit is contained in:
Croneter 2018-05-02 18:05:27 +02:00
parent 3016c9747f
commit 81b1d18192

View file

@ -284,24 +284,25 @@ def process_websocket(plex_id, updated_at, state):
""" """
create = False create = False
playlist = playlist_object_from_db(plex_id=plex_id) playlist = playlist_object_from_db(plex_id=plex_id)
if playlist and state == 9: try:
LOG.debug('Plex deletion of playlist detected: %s', playlist) if playlist and state == 9:
delete_kodi_playlist(playlist) LOG.debug('Plex deletion of playlist detected: %s', playlist)
elif playlist and playlist.plex_updatedat == updated_at: delete_kodi_playlist(playlist)
LOG.debug('Playlist with id %s already synced: %s', plex_id, playlist) elif playlist and playlist.plex_updatedat == updated_at:
elif playlist: LOG.debug('Playlist with id %s already synced: %s',
LOG.debug('Change of Plex playlist detected: %s', playlist) plex_id, playlist)
delete_kodi_playlist(playlist) elif playlist:
create = True LOG.debug('Change of Plex playlist detected: %s', playlist)
elif not playlist and not state == 9: delete_kodi_playlist(playlist)
LOG.debug('Creation of new Plex playlist detected: %s', plex_id) create = True
create = True elif not playlist and not state == 9:
# To the actual work LOG.debug('Creation of new Plex playlist detected: %s', plex_id)
if create: create = True
try: # To the actual work
if create:
create_kodi_playlist(plex_id=plex_id, updated_at=updated_at) create_kodi_playlist(plex_id=plex_id, updated_at=updated_at)
except PL.PlaylistError: except PL.PlaylistError:
pass pass
@LOCKER.lockthis @LOCKER.lockthis