Open Mabenan opened 2 years ago
The way you would need to implement this is by having something that, when turned on, automatically fetched X number of tracks from somewhere (eg. a recommendation API) on a timer. Implementing this from within Mopidy is complicated for (at least) a couple of reasons.
First, there's no real kind of scheduled events system. I've dreamt for a long time of integrating APScheduler, ideally backed by some kind of database for persistence. This would also allow things like alarm clocks to be implemented.
Second, Mopidy's architecture makes it very difficult for extensions to talk to each other. Yes, there's a Spotify backend with a library provider, and it exists at runtime. Unfortunately there's no proper way to access it, so that I can avoid duplicating a bunch of code in another extension to power this functionality. Essentially, there's no service layer. There's just frontends and backends, with no capability for shared functionality at runtime that operates within the actor framework.
If you're interested, I've written a bit more on this subject in an issue in the main Mopidy repo:
https://github.com/mopidy/mopidy/issues/1992
Ultimately, you may find that implementing something like this will be significantly easier to do outside of Mopidy. You could write a script that queries the Spotify API yourself, retrieves a list of URIs, and pass them to Mopidy using its own API.
I dont think we need a timer for this. I think it would be enough to determine the next tracks when the tracklist has come to the last or the last 2 tracks.
So the sxample of behaviour would be:
User adds tracks to a tracklist lets say 5 tracks. The music is playing and when the playing reach the last track. The new feauture will automatically add 5 or so tracks to the tracklist.
Im not familiar with the life cycles in mopidy but when it is possible to listen on the track changes of the playback we could implement something that checks on each track change if we reached the end of the tracklist and add the next track.
Of course this feature would come with limitations: The random funktion would not work as it means the tracklist would falsly reach the end of the tracklist.
Someone could add this as a feature. Spotify artist radio is like this, in theory librespot should support it, if it still exists...? But We would need something that waited for the end of track event and then fetched a load more tracks to play if it was the last one. I'm not sure if we already have everything available to do that already but someone who is interested could investigate.
Also, I'm going to rename this because I consider "autoplay" functionality to play something automatically on startup. This isn't that feature.
I known that this is a a complex one as it isnt solved with a simple api call neither by spotify nor by mopidy. But i would really like to have it. So this is will be more of a discussion thread how it should behave and how we can integrate it.
The talk is about the spotify (or any other big music streaming service) auto play. Which is basicaly a never ending queue of tracks based on the tracks already listen to in the session.
Spotify has a recommandation api which we can maybe use to find next tracks