Merge pull request #1704 from croneter/py3-fix-another-indexerror

Fix rare IndexError when trying to delete a playlist item
This commit is contained in:
croneter 2021-11-13 14:08:44 +01:00 committed by GitHub
commit 305eca76ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -876,12 +876,16 @@ def delete_playlist_item_from_PMS(playlist, pos):
Delete the item at position pos [int] on the Plex side and our playlists Delete the item at position pos [int] on the Plex side and our playlists
""" """
LOG.debug('Deleting position %s for %s on the Plex side', pos, playlist) LOG.debug('Deleting position %s for %s on the Plex side', pos, playlist)
try:
xml = DU().downloadUrl("{server}/%ss/%s/items/%s?repeat=%s" % xml = DU().downloadUrl("{server}/%ss/%s/items/%s?repeat=%s" %
(playlist.kind, (playlist.kind,
playlist.id, playlist.id,
playlist.items[pos].id, playlist.items[pos].id,
playlist.repeat), playlist.repeat),
action_type="DELETE") action_type="DELETE")
except IndexError:
raise PlaylistError('Position %s out of bound for %s' % (pos, playlist))
else:
del playlist.items[pos] del playlist.items[pos]
_update_playlist_version(playlist, xml) _update_playlist_version(playlist, xml)