How to run specific Spotify Playlist; TuneIn Station; other backend with Python Frontend

Hi there,

does anyone know what the right way of issuing a specific playlist or station from a specific backend is?

I’m working on my own mopidy frontend extension with which I want to control the mopidy playback with specific envents. With the activation of an button I want to play a specific Spotify playlist. Another button should start playing a specific TuneIn station. In the mopidy docu I found core.playback.play(), so I came up with:

self.core.playback.play("tunein:station:s258486")

or

self.core.playback.play("spotify:user:1114154769:playlist:6IJSWYZtiR0vXWNEEKqEVK6")

… from the inside of my frontend.py module, which does not work like expected. Any suggestions?

Is Mopidy capable of figuring out which backend to use to play the provided url? Or how do I switch between my installed backends? Would be great if anyone could point me in the right direction :slight_smile:

cheers

The documentation states the parameters that function takes, and it’s not a uri.

You need to add tracks to the tracklist first (you can use your uri(s) there) which will give you TlTracks that can then pass to play().

thanks for your fast reply! I tried:

self.spotify_track_list = self.core.tracklist.add(uri="spotify:user:spotify:playlist:37i9dQZF1DX0jgyAiPl8Af")
self.core.playback.play(self.spotify_track_list)

which results in:

mopidy_spotify.lookup - INFO - Failed to lookup "spotify:user:spotify:playlist:37i9dQZF1DX0jgyAiPl8Af": Operation did not complete in 10.000s

another Spotify playlist failed with:

mopidy_spotify.lookup - INFO - Failed to lookup "spotify: user:1114154769: playlist:6IJSWYZtiR0vXWNEEKqEVK6": Failed to get link from Spotify URI: u'spotify: user:1114154769: playlist:6IJSWYZtiR0vXWNEEKqEVK6'

What do I do wrong?

Special Spotify playlists (owned by the user ‘spotify’ are broken, it’s an ongoing issue. Playlists owned by other users should work.

But that only explains the first example. The second example should be OK, are you sure that’s a valid uri, why does it contain spaces?

alright. The logging output was formatted to have spaces, the original uri didn’t have any. I took another playlist of mine. With this implementation I do not get any errors:

self.spotify_track_list =\
    self.core.tracklist.add(uri="spotify:user:fogmusic:playlist:0aB6AZn6sqvAmgulaKyVzP")
self.tunein_track_list =\
    self.core.tracklist.add(uri="tunein:station:s258486")

self.core.playback.play(self.spotify_track_list)
self.core.playback.play(self.tunein_track_list)

But still the playback does not start. Verbose (Debug) Mode also does not say anything, when I ussie the play() command. Anything else I need to configure before play()?

Play takes a single TlTrack argument or a single tlid or nothing. It doesn’t take a list of TlTracks.

On top of that, since you are dealing with actor proxies, these methods return futures. You need to call .get() on these futures in order to resolve them and get the actual return data. I strongly suggest you take a look at the mpd frontend code to see this is action. I think this’ll become clearer then.