mental32 / Spotify.py
Licence: mit
🌐 API wrapper for Spotify 🎶
Stars: ✭ 131
Programming Languages
Projects that are alternatives of or similar to Spotify.py
Datastore
🐹 Bloat free and flexible interface for data store and database access.
Stars: ✭ 99 (-24.43%)
Mutual labels: async, asynchronous
Kitchen Async
A Promise library for ClojureScript, or a poor man's core.async
Stars: ✭ 128 (-2.29%)
Mutual labels: async, asynchronous
Spartan
An Elegant Spotify Web API Library Written in Swift for iOS and macOS
Stars: ✭ 100 (-23.66%)
Mutual labels: spotify-api, spotify
Spotify Web Api Js
A client-side JS wrapper for the Spotify Web API
Stars: ✭ 1,313 (+902.29%)
Mutual labels: spotify-api, spotify
Mioco
[no longer maintained] Scalable, coroutine-based, fibers/green-threads for Rust. (aka MIO COroutines).
Stars: ✭ 125 (-4.58%)
Mutual labels: async, asynchronous
Pasta For Spotify
A material design Spotify client for Android
Stars: ✭ 93 (-29.01%)
Mutual labels: spotify-api, spotify
Exportify
Export Spotify playlists using the Web API. Analyze them in the Jupyter notebook.
Stars: ✭ 80 (-38.93%)
Mutual labels: spotify-api, spotify
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (-14.5%)
Mutual labels: async, asynchronous
Ws Machine
WS-Machine is a websocket finite state machine for client websocket connections (Go)
Stars: ✭ 110 (-16.03%)
Mutual labels: async, asynchronous
Whisperify
An interactive way to learn about your favourite songs on Spotify. Quiz yourself on your favourite playlists and share quizzes with friends.
Stars: ✭ 91 (-30.53%)
Mutual labels: spotify-api, spotify
Drone
CLI utility for Drone, an Embedded Operating System.
Stars: ✭ 114 (-12.98%)
Mutual labels: async, asynchronous
Spotify Web Api Kotlin
Spotify Web API wrapper for Kotlin/JVM, Kotlin/Android, Kotlin/JS, and Kotlin/Native. Includes a Spotify Web Playback SDK wrapper for Kotlin/JS, and a spotify-auth wrapper for Kotlin/Android
Stars: ✭ 86 (-34.35%)
Mutual labels: spotify-api, spotify
Base64 Async
Non-blocking chunked Base64 encoding
Stars: ✭ 98 (-25.19%)
Mutual labels: async, asynchronous
Radon
Object oriented state management solution for front-end development.
Stars: ✭ 80 (-38.93%)
Mutual labels: async, asynchronous
Exportify
Export/Backup Spotify playlists using the Web API
Stars: ✭ 1,611 (+1129.77%)
Mutual labels: spotify-api, spotify
Spotivy
🎼 Download music videos from Spotify playlists
Stars: ✭ 64 (-51.15%)
Mutual labels: spotify-api, spotify
Vibe
Get insights into your Spotify listening history 🎶
Stars: ✭ 67 (-48.85%)
Mutual labels: spotify-api, spotify
Spotify Dart
A dart library for interfacing with the Spotify API.
Stars: ✭ 109 (-16.79%)
Mutual labels: spotify-api, spotify
Async Backplane
Simple, Erlang-inspired fault-tolerance framework for Rust Futures.
Stars: ✭ 113 (-13.74%)
Mutual labels: async, asynchronous
spotify.py
An API library for the spotify client and the Spotify Web API written in Python.
Spotify.py is an asynchronous API library for Spotify. While maintaining an
emphasis on being purely asynchronous the library provides syncronous
functionality with the spotify.sync
module.
import spotify.sync as spotify # Nothing requires async/await now!
Notice: Looking For Maintainers
The author of spotify.py considers it deprecated and is provided "as is".
(of course depending on the user it may be considered feature complete)
The author does not intend to continue working on it or providing support, it may work or may not for the purposes it was designed for.
If you encounter an issue:
- open an issue and wait for a PR to come along and fix (you may be waiting a while)
- open a PR that introduces the fix directly (the author is happy to click a button labeled "merge")
Index
Installing
To install the library simply clone it and run pip.
git clone https://github.com/mental32/spotify.py spotify_py
cd spotify_py
pip3 install -U .
or use pypi
-
pip3 install -U spotify
(latest stable) -
pip3 install -U git+https://github.com/mental32/spotify.py#egg=spotify
(nightly)
Examples
Sorting a playlist by popularity
import sys
import getpass
import spotify
async def main():
playlist_uri = input("playlist_uri: ")
client_id = input("client_id: ")
secret = getpass.getpass("application secret: ")
token = getpass.getpass("user token: ")
async with spotify.Client(client_id, secret) as client:
user = await spotify.User.from_token(client, token)
async for playlist in user:
if playlist.uri == playlist_uri:
return await playlist.sort(reverse=True, key=(lambda track: track.popularity))
print('No playlists were found!', file=sys.stderr)
if __name__ == '__main__':
client.loop.run_until_complete(main())
Required oauth scopes for methods
import spotify
from spotify.oauth import get_required_scopes
# In order to call this method sucessfully the "user-modify-playback-state" scope is required.
print(get_required_scopes(spotify.Player.play)) # => ["user-modify-playback-state"]
# Some methods have no oauth scope requirements, so `None` will be returned instead.
print(get_required_scopes(spotify.Playlist.get_tracks)) # => None
Usage with flask
import string
import random
from typing import Tuple, Dict
import flask
import spotify.sync as spotify
SPOTIFY_CLIENT = spotify.Client('SPOTIFY_CLIENT_ID', 'SPOTIFY_CLIENT_SECRET')
APP = flask.Flask(__name__)
APP.config.from_mapping({'spotify_client': SPOTIFY_CLIENT})
REDIRECT_URI: str = 'http://localhost:8888/spotify/callback'
OAUTH2_SCOPES: Tuple[str] = ('user-modify-playback-state', 'user-read-currently-playing', 'user-read-playback-state')
OAUTH2: spotify.OAuth2 = spotify.OAuth2(SPOTIFY_CLIENT.id, REDIRECT_URI, scopes=OAUTH2_SCOPES)
SPOTIFY_USERS: Dict[str, spotify.User] = {}
@APP.route('/spotify/callback')
def spotify_callback():
try:
code = flask.request.args['code']
except KeyError:
return flask.redirect('/spotify/failed')
else:
key = ''.join(random.choice(string.ascii_uppercase) for _ in range(16))
SPOTIFY_USERS[key] = spotify.User.from_code(
SPOTIFY_CLIENT,
code,
redirect_uri=REDIRECT_URI
)
flask.session['spotify_user_id'] = key
return flask.redirect('/')
@APP.route('/spotify/failed')
def spotify_failed():
flask.session.pop('spotify_user_id', None)
return 'Failed to authenticate with Spotify.'
@APP.route('/')
@APP.route('/index')
def index():
try:
return repr(SPOTIFY_USERS[flask.session['spotify_user_id']])
except KeyError:
return flask.redirect(OAUTH2.url)
if __name__ == '__main__':
APP.run('127.0.0.1', port=8888, debug=False)
Resources
For resources look at the examples
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].