Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement 'autoplay' functionality #294

Closed
mordax7 opened this issue Mar 2, 2019 · 14 comments · Fixed by #394
Closed

Implement 'autoplay' functionality #294

mordax7 opened this issue Mar 2, 2019 · 14 comments · Fixed by #394

Comments

@mordax7
Copy link

mordax7 commented Mar 2, 2019

Sometimes if I let Spotify run for a long time period I come to the end of my playlist, especially if it's really short. Therefore I have in my Spotify Desktop Client the option enabled to play similar songs on the end of the playlist.
screenshot-20190302150052-931x113

I noticed this was not working when using librespot, would it be possible to implement this?

Regards.

@devgianlu
Copy link
Member

This doesn't seem to be communicated to the player, so it'll have to be an option inside librespot. I suppose you need to turn off repeat in order for this to work. Right?

@mordax7
Copy link
Author

mordax7 commented Mar 2, 2019

Exactly, repeat has to be disabled this to work.

@devgianlu
Copy link
Member

Stole the idea and implemented it in librespot-java!

@sashahilton00
Copy link
Member

@devgianlu was there any reverse engineering required, or are you just pulling the queue again once the local queue ends?

@devgianlu
Copy link
Member

devgianlu commented Mar 11, 2019

I am using the hm://radio-apollo/v3/stations/ endpoint to create a station for the given context and they I play it normally.

@ashthespy
Copy link
Member

FWIW: There is an endpoint for this, didn't look into it in detail though.
hm://autoplay-enabled/query

@devgianlu
Copy link
Member

@ashthespy Is there anything more to it? Doing GET hm://autoplay-enabled/query returns 400.

@ashthespy
Copy link
Member

@devgianlu Sorry, no I didn't have time to dump more packets and investigate. But it seems to follow the format of hm://autoplay-enabled/query?uri=spotify%3Auser%3A where the uri is of the current playlist.

@sashahilton00
Copy link
Member

@devgianlu @ashthespy it's pretty simple. You just send a request to the autoplay endpoint as follows:

hm://autoplay-enabled/query?uri=spotify:user:sashahilton00:playlist:5fFTfhV...jqkezuVT

You'll then get a response, which is just a URI to a station for that playlist:

spotify:station:user:sashahilton00:playlist:5fFTfhV...jqkezuVT

Use the normal endpoint to get the JSON payload for the station:

hm://radio-apollo/v3/stations/spotify:station:user:sashahilton00:playlist:5fFTfhV...jqkezuVT

Then you'll get a JSON payload, which can then just be played like a station normally is. Makes sense that it's a toggle in the client, since the only thing it does is wait for the queue to empty, then makes the above requests and starts playing the radio for the given playlist.

@devgianlu
Copy link
Member

My implementation is obsolete then. What if autoplay is disabled? Does it still make the request?

@sashahilton00
Copy link
Member

Haven't checked, but given it's a client toggle, I imagine if it's disabled it doesn't, and just stops playing once playlist/album is finished

@devgianlu
Copy link
Member

Anyone tested this? I keep getting 204.

@ashthespy
Copy link
Member

I have the same as @sashahilton00 - the endpoint responds with the station uri in plain old bytes.

@OrestTa
Copy link

OrestTa commented Oct 19, 2019

Any status updates on this one? (Such a feature would be amazing indeed!)

One possible workaround is of course to use something like shairport ( https://github.com/mikebrady/shairport-sync ) as, this way, the stream is managed by the user device (phone) and autoplay just works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants