Closed Marterido closed 4 months ago
I don't know about chromecast but I'm using it to stream spotify to Yamaha MusicCast devices. You can check which devices are available with the following code:
from pprint import pprint
import spotipy
from spotipy.oauth2 import SpotifyOAuth
scope = "user-read-playback-state,user-modify-playback-state"
sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(scope=scope))
print(sp.me())
def show_devices():
# Shows playing devices
res = sp.devices()
pprint(res)
for d in res["devices"]:
print(f"{d['name']}: {d['id']}")
return res["devices"][0]["id"]
if __name__ == '__main__':
d_id = show_devices()
sp.start_playback(
device_id=d_id,
uris=["spotify:track:2R6UrJ8uWbSIiHWmvRQvN8"])
EDIT: Added the start_playback command with which the streaming to a device can actually be started.
Closing as the issue seems to be resolved.
I'm currently making a voice assistant in python to control different things inside my house including music. But I wondered if it's possible to stream my Spotify to the chromecast or another device using Spotipy?