mental32 / spotify.py

🌐 API wrapper for Spotify 🎶
https://spotifypy.readthedocs.io/en/latest/
MIT License
150 stars 38 forks source link

Impossible to play list of tracks #36

Closed winston-yallow closed 4 years ago

winston-yallow commented 4 years ago

This adresses a few issues with the current method to play tracks/contexts. It works when given a context but fails when given tracks.

When trying to play a list of tracks with player.play(track01, track02, device=device_id) the error TypeError: list() takes at most 1 argument (2 given) is raised. This happens in the HTTPClient method play_playback(). The list constructor should be used with only one argument, the iterable.

In the same method: The initialisation of can_set_context tries to access payload["context_uri"] even if this does not exist.

When trying to play a single track with player.play(track, device=device_id) the track will be interpreted as a context. It is not possible to play a single track. (This is especially weird when passing the result of a track search into the play function: It fails only for searches with only one search result and works for other results.)

An optional argument treat_as_tracks would be nice: If set to true it will interpret all *uris as track uris. This way it is possible to pass only one track in cases where you know that it will be a track. This is also backwards compatible as the new argument is optional, the default is the old behaviour.

I have fixed all of the above in my fork and will create a PR, however I am not sure if my fixes are the best way to do this.

mental32 commented 4 years ago

I've just commented on #37 but I should point out here, in reply to your backwards compatibility comment, spotify.py uses semantic versioning and is currently on major version zero (0.x.y), backwards compatibility isn't a consideration until major version one as it's not officially stable.

winston-yallow commented 4 years ago

Ah I missed that, I will not worry about backwards compatibility then. I'll update the PR according to the suggestion