Fix bug where a new Tidal playlist was created everytime sync.py run with --uri argument

I was passing (playlist, None) in the case where the --uri argument was used,
and None means create a new playlist.

I've fixed it to look for the Tidal playlist if it exists like the other
code paths do, and only pass None when it doesn't exist.

Unfortunately this will mean that your Tidal collection might have been polluted with
duplicate playlists. I've added a delete playlist function to tidalapi_patch to help
with deleting these programmatically, which some people might find useful.

Fixes #8
This commit is contained in:
Timothy Rae
2022-02-12 14:36:49 +13:00
parent 83b692b0fd
commit 2967820650
2 changed files with 22 additions and 9 deletions

View File

@@ -70,4 +70,7 @@ def create_tidal_playlist(session, name):
result = session.request('POST','users/%s/playlists' % session.user.id ,data={'title': name})
return session.get_playlist(result.json()['uuid'])
def delete_tidal_playlist(session, playlist):
etag = session.request('GET','playlists/%s' % playlist.id).headers['ETag']
headers = {'if-none-match' : etag}
session.request('DELETE','playlists/%s' % playlist.id, headers=headers)