mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #1147] How do I start playback on the command line/headless? #675
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#675
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @adamf on GitHub (Jul 17, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1147
I'm trying to use spotipy to play music from the command line, but I don't think I understand the devices concept or how to activate a device. All the devices I see when enumerating
sp.devices()are not active. How do I activate the device I want?I think I understand that if I have spotify playing somewhere else on the same network I can transfer to the local audio output device and have that become active, but what do I do if I don't have spotify playing somewhere else?
@dieser-niko commented on GitHub (Jul 17, 2024):
In order to activate them, just use sp.start_playback/sp.transfer_playback with the parameter
device_idwith the device ID from thesp.devices()list.@adamf commented on GitHub (Jul 17, 2024):
Another wrinkle: How do I make the local audio interface available as a device if it is not in the devices list?
@dieser-niko commented on GitHub (Jul 18, 2024):
Well, that's not possible with the Spotify API. But you can find other ways to play Spotify on the device you want. For example, on Android, I want autoplay when I connect to a Bluetooth audio device. But since I installed the latest software update, that's no longer possible.
So I've built a little application (or so-called "Flow") using an app called Automate to create my own autoplay. It's pretty straightforward and there are definitely ways to make your Python script communicate with a flow if you need to.
Obviously my example has nothing to do with the Spotify API, but you get my point. Something like that would make it possible for the Spotify app to wake up and show up in the device list on its own.
There are also apps like Tasker. I've never tried it out, so I don't know if it would even work, but it seems to be quite popular.
On PC you just have to make sure that Spotify is open and online in order to let it show up in the devices list. If not, then it shouldn't be a big hassle to let Python open Spotify.
@dieser-niko commented on GitHub (Jul 18, 2024):
I should add that Automate is a powerful app and can really mess up your smartphone. So make sure to use it responsibly.
@adamf commented on GitHub (Jul 18, 2024):
This is on a raspberry pi, so I think the automation would probably be something like start a headless chrome instance, somehow log it into the spotify web app, then use that device. Or just buy the mp3s I want to play from the command line :)
@adamf commented on GitHub (Jul 18, 2024):
This is resolved - it's not possible to activate a new device with pure spotipy.