sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.71k stars 194 forks source link

'remove_playlist_items()' does not work nor does it produce an error when 'videoId' and 'setVideoId' == None #88

Closed trekk9 closed 3 years ago

trekk9 commented 3 years ago

https://github.com/sigma67/ytmusicapi/blob/bdbaada36ab339024ed583e66d1071f3796dd3eb/ytmusicapi/mixins/playlists.py#L244

My local solution is to add a continue to my iteration when removing tracks from a playlist where 'videoId' and 'setVideoId' == None.

Example:

if (tracks[x]['videoId'] == None) or (tracks[x]['setVideoId'] == None):
    continue

Here is a sample album with a couple of tracks that were removed.

https://music.youtube.com/playlist?list=OLAK5uy_m9fhpjoINvcfPzPibD7EMBXxpG_8txoGM

sigma67 commented 3 years ago

I'd say this is working as intended, but I think we can do better than that. My proposed solution would be to remove all items from the list which are missing either videoId or setVideoId, before sending the request. This would replace the following lines:

https://github.com/sigma67/ytmusicapi/blob/bdbaada36ab339024ed583e66d1071f3796dd3eb/ytmusicapi/mixins/playlists.py#L254-L256

Would this fix your issue?