Skip to main content

Simplest integration of Spotify into Python

Project description

Pyspotify Utils

This repository attempts to make it as simple as possible to integrate pyspotify.

It’s currently as simple as # pip install pyspotify_helper # python >>> from pyspotify_helper import Spotify >>> spotify_pro_credentials = { “spotify_name”: “”, “spotify_password”: “” } >>> Spotify(spotify_pro_credentials).play(“Stadium Arcadium”, “albums”)

Initialization:

Sadly, that simplicity comes after some initialization.

You need a spotify_appkey.key in your project root directory. You can get this following the tutorial at http://pyspotify.mopidy.com/en/latest/quickstart/#application-keys.

Dependencies:

libspotify pyspotify

Information on installing dependencies at http://pyspotify.mopidy.com/en/latest/installation/.

Usage:

The most important method is play(name, category, shuffle=False). Name is a free-form string that will be searched on Spotify (more info at http://news.spotify.com/us/2008/01/22/searching-spotify/). Category is one of “tracks”, “artists”, or “albums”. Shuffle decides whether or not the music gets shuffled when played.

If no results are found, there will be an error. (IndexError: list index out of range)

The play() method does not block. They return immediately, while a different thread is started to play the music.

There are four methods to control playback: next_track, pause, resume, and pause_toggle.

These methods will cancel the currently playing song when called.

Spotify() returns a singleton. The credentials only need to be passed in the first time you call the function. See the “if __name__ == ‘__main__’:” section.

TODO (As in, questions for you and my future self):

How does searching work with playlists? More specifically, can I easily distinguish between owned playlists and other playlists? What about playlists with the same name?

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

pyspotify_helper-0.0.1.tar.gz (3.2 kB view hashes)

Uploaded Source

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