- Click here and register for a spotify developer account, if you already don't have one.
- In the developer's dashboard, choose CREATE A CLIENT ID. In the pop-up window provide the requested details.
- Set the Redirect URIs to http://localhost:8888
- Click on the new app created and copy the CLIENT ID and CLIENT SECRET. Paste it in the config.yaml file in the indicated space.
- Access spotify from here and copy the username and enter it in the config.yaml
- Go to the projects page on Google Cloud Console-> https://console.cloud.google.com/project and sign in using your google account.
- Create a new project and give it a name.
- On the left top corner, click on the hamburger icon or three horizontal stacked lines.
- Move your mouse pointer over API and services and choose credentials.
- Click on create credentials and select API Key and choose close. Make a note of the created API Key and enter it in the config.yaml script at the indicated location.
- From the API and services option, select library and in the search bar type youtube, select YouTube Data API v3 API and click on ENABLE.
System wide dependencies
sudo apt-get install python3 python3-dev python3-venv python3-pip python3-setuptools -y
Create a environment
python3 -m venv spotifyenv
Setup pip tools
spotifyenv/bin/python -m pip install --upgrade pip setuptools wheel
Move into the created environment
source spotifyenv/bin/activate
Install pip packages
pip3 install pafy google-api-python-client python-vlc git+https://github.com/plamere/spotipy.git pyyaml oauth2client youtube_dl
Open a terminal and run the example as follows:
Example 1-Playback by supplying playlistname as argument:
python3 -i /home/pi/Spotify-Playlist-Player/src/example-1-parseargs.py -p "Name of your playlist"
Example 2-Playback control using Pimoroni's Button-SHIM:
python3 /home/pi/Spotify-Playlist-Player/src/example-2-button-shim.py
-
For premium or paid users there are a number of programs like mopidy-spotify, spotify connect, volumio plugin, etc. For free users, there is limited scope of playing back spotify playlists such as mpsyt.
-
Spotify API currently only supports playback in a web browser, but DRM content is being blocked in the Raspberry Pi.
-
As a roundabout approach, these scripts get playlist details using Spotipy API and then fetch those tracks from YouTube.
-
This custom program has a better accuracy than spotify playlist playback using mpsyt.