Skip to main content

Communicate with the Spotify's web helper process to control some basic aspects of spotify

Project description

Spotify-Local: A multi-platform API to control the local Spotify Client

https://img.shields.io/pypi/v/requests-xml.svg?maxAge=2592000 https://img.shields.io/pypi/l/requests-xml.svg?maxAge=2592000

Spotify-Local library is designed to make controlling the Spotify client on your local machine possible! This is a wrapper for the web helper process which exposes a simple api. Spotify-Local is inspired by SpotifyAPI-NET. This library allows you to perform simple actions quickly, or listen to events and register callbacks when a song changes, or the pause button is pushed.

When using this library you automatically get:

  • The ability to play/pause the current song

  • The ability to change tracks

  • You can register callbacks and listen for events when the state of Spotify changes

  • A nice context manager api using with

Installation

$ pipenv install spotify-local-control

Only Python 3.3+ is supported.

Tutorial & Usage

Connect to the Spotify Client (Spotify must be open to do this):

>>> from spotify_local import SpotifyLocal

>>> with SpotifyLocal() as s:
        pass

Pause the Spotify Client:

>>> with SpotifyLocal() as s:
        s.pause()

Grab the current state of the Spotify client, including now playing information:

>>> with SpotifyLocal() as s:
        print(s.get_current_status())

Play a playlist, song, album, artist, etc using a Spotify uri link:

>>> with SpotifyLocal() as s:
        s.playURI('spotify:track:0thLhIqWsqqycEqFONOyhu')

Register a callback and listen for events:

>>> from spotify_local import SpotifyLocal
>>> s = SpotifyLocal()
>>> @s.on('track_change')
>>> def test(event):
...     print(event)
>>> s.listen(blocking=False)
>>> print("Do more stuff because that runs in the background")

License

MIT

TODO

  • Create an async verion of the spotify controller class

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spotify-local-0.3.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

spotify_local-0.3.0-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file spotify-local-0.3.0.tar.gz.

File metadata

File hashes

Hashes for spotify-local-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f06103e1600b582dc9103f17728f3f39f98dc0f6f87538f06141a229f531904c
MD5 9fc4226bc7cbf81fa16b298b80860271
BLAKE2b-256 39226d331975a86c5ffd76d9e52601b5df18d45ae3b1551f40103f6fdf3f059f

See more details on using hashes here.

File details

Details for the file spotify_local-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for spotify_local-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f84f9b5f22ccbeb3b1ff522830659a8fabc79e6cce54901320f360e42aacee2a
MD5 ed913bfa4d9978843e1a27a7b4d2379c
BLAKE2b-256 8df4e6ce50f15736b7e30ec5c71e1cb564fe0bf1464bce8a6f37b152651bb45c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page