pkkid / python-plexapi

Python bindings for the Plex API.
BSD 3-Clause "New" or "Revised" License
1.13k stars 196 forks source link

Playlist API is broken for Tidal songs #1062

Open chrisknepper opened 1 year ago

chrisknepper commented 1 year ago

Describe the Bug

If you have a Plex playlist mixed with regular songs and Tidal songs and you attempt to add/move/update/remove the Tidal song, an exception is thrown. This is because the methods all rely on ratingKey which is always nan for Tidal songs, at least when they are in Plex playlists. In particular the moveItem and removeItems methods call _getPlaylistItemID which loops through the playlist and compares the ratingKey which will of course fail for nan values.

This worked in a previous version of the library because _getPlaylistItemID did not exist and the move/update/delete methods simply assumed the existence of playlistItemID.

A workaround if playlistItemID can be safely assumed to exist is to copy the underlying API calls and run them.

Code Snippets

for playlistItem in playlist.items():
    print('playlist item ratingKey', playlistItem.ratingKey) # Will be nan for Tidal songs

Expected Behavior

No response

Additional Context

A Tidal song can be added to a normal Plex (not Tidal) playlist by finding a Tidal song within the Plex UI, adding it to a playlist, and taking care to select a Plex playlist and not a Tidal playlist.

Compare

https://github.com/pkkid/python-plexapi/blob/3d3f9da5012428f5d703cf9f8e95f6aa10673ea6/plexapi/playlist.py#L254

to

https://github.com/pkkid/python-plexapi/blame/445897798831955ced99d3de1f7a806e5ee33549/plexapi/playlist.py#L219

Appears to have been broken via

https://github.com/pkkid/python-plexapi/commit/38114b62ba8bc488a18673173248bb32b9cb7dc2

Operating System and Version

macOS 13.0.1

Plex Media Server Version

1.29.2.6364

Python Version

3.10.8

PlexAPI Version

4.13.1

ig12 commented 2 weeks ago

With the announcement that Plex will no longer support Tidal this is more urgent now then ever (or less) but I'd like to export my playlists that are mixed between local and tidal songs.

JonnyWong16 commented 2 weeks ago

The issue is only with removing or moving Tidal tracks in a playlist. There should be nothing preventing you from just listing Tidal tracks in a playlist.