spotify.py is an asynchronous API wrapper for Spotify written in Python.
Project description
spotify.py
An API library for the spotify client and the Spotify Web API written in Python.
Spotify.py is an, primarily, asyncronous library (everything down to the HTTP client is asyncio friendly).
Sync' support
The library also supports syncronous usage with spotify.sync
import spotify.sync as spotify # Nothing requires async/await now!
example
- Sorting a playlist by popularity
import spotify
playlist_uri = # Playlist uri here
client_id = # App client id here
secret = # App secret here
token = # User token here
client = spotify.Client(client_id, secret)
async def main():
user = await spotify.User.from_token(client, token)
playlist = next(filter((lambda playlist: playlist.uri == playlist_uri), await user.get_playlists()))
tracks = await playlist.get_all_tracks()
sorted_tracks = sorted(tracks, reverse=True, key=(lambda track: track.popularity))
await user.replace_tracks(playlist, sorted_tracks)
if __name__ == '__main__':
client.loop.run_until_complete(main())
Installing
To install the library simply clone it and run setup.py
git clone https://github.com/mental32/spotify.py
python3 setup.py install
or use pypi
pip3 install spotify
(latest stable)pip3 install -U git+https://github.com/mental32/spotify.py
(nightly)
Resources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spotify-0.4.8.tar.gz
(24.4 kB
view hashes)