0

I have a simple python code that connects to my Spotify-Account and selected device and plays the song I want.

In Thonny it works without any problems, but whenever I try to run it in the terminal I get many questions whether allowing cookies or not, like:

  • accounts.spotify.com cookie: _asdfasdfasdf Allow? (Y/N/Always/neVer)

Although I allow every single cookie I get to a part I don't get any further:

enter image description here

I also get there whenever I answer with Always.

As I want to run the script every time the raspberry start, I need to fix this issue. Can you help me out?

Thank you in advance!

Code: (Source: https://github.com/talaexe/Spotify-RFID-Record-Player/tree/main)

import spotipy
from spotipy.oauth2 import SpotifyOAuth


device_id= ""
client_id= ""
client_secret= ""

# Spotify Authentication
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=client_id,
                                               client_secret=client_secret,
                                               redirect_uri="http://localhost:8080",
                                               scope="user-read-playback-state,user-modify-playback-state"))


# Transfer playback to the Raspberry Pi if music is playing on a different device
sp.transfer_playback(device_id=device_id, force_play=False)

# Play the spotify track at URI with ID 45vW6Apg3QwawKzBi03rgD (you can swap this for a diff song ID below)
sp.start_playback(device_id=device_id, context_uri='spotify:album:0JGOiO34nwfUdDrD612dOp')

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.