Closed iangu48 closed 4 years ago
That's a bit of a dead field that went left over, I'll remove it in the next major bump. at the moment get your tracks from Playlist.get_all_tracks() or get_tracks() instead.
@iangu48 Let me know if you have any more issues or questions, I'm going to keep this thread open for a couple days :D
Thanks for the clarification
How would I remove a specific track in a playlist?
playlist.remove_tracks(track)
removes all occurrences of the track in the playlist
I'm been trying playlist.remove_tracks({track.uri: [index]})
, but I can't get it to work either.
spotify.errors.HTTPException: Bad Request (status code: 400): JSON body contains an invalid track uri: {'spotify:track:2YorpKjHKhDBD0QOuucIrA': [1]}
Here's my code
def removeTrack():
try:
print(flask.session['party'])
ownerId = parties[flask.session['party']]
party = listeningSessions[ownerId]
print(party)
except KeyError:
return "no session currently found"
else:
currentUser = SPOTIFY_USERS[flask.session['spotify_user_id']]
track = SPOTIFY_CLIENT.get_track(flask.request.args['track'])
party.playlist.remove_tracks({track.uri: [int(flask.request.args['trackIndex'])]})
return flask.redirect(flask.url_for('.queue'))
That's a good point, I forgot to add support for that.
I'm going to release a new minor in the next hour or so addressing this. The api would look like this:
playlist.remove_tracks(track_a, track_b, (track_c, [0, 3]))
where all occurrences of tracks A and B get uniformly removed and only Cs at index's 0 and 3 get removed.
Looking forward to that, thanks again for your help :)
@iangu48 Sorry took longer than expected to get around to it!
It's in as of 0.9.0 and I'm happy to publish to pypi tomorrow or whenever you confirm the changes are working.
Changes seem to be working. Thanks for your work!
No problem :D
I'm new to this so forgive me in advance
I'm following the Flask example, and whenever I try to access the
tracks
attribute of Playlist, it gives meNone
. I'm also not able to use theremove()
method of Playlist, and it throws meValueError: list.remove(x): x not in list
sincetracks
isNone