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 details)

Uploaded Source

File details

Details for the file pyspotify_helper-0.0.1.tar.gz.

File metadata

File hashes

Hashes for pyspotify_helper-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cb244ed21973c966fbe3e9a0400271ce20445890b798f8acdb5915f1298a531e
MD5 7009ae287e74dd35cffad66110b798cb
BLAKE2b-256 0040aa19aa935c9f65ca02610d7cfad6961e13fb04ed5857f6394f4c0d2742fd

See more details on using hashes here.

Supported by

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