Mopidy-headless coding

for adding remote control I installed the extension mopidy-headless 0.30. However this is quite old and does not work with latest mopidy. In module frontend.py in the function change_playlist (also set_playlist) the line:
self.core.tracklist.add(uri=self.playlists[self.selected_playlist].uri)
throws an error.
The function tracklist.add expects a list of uris with parameter uris= (not uri) and self.playlists[self.selected_playlist].uri just delivers the uri of the playlist.
So I first called track_list = self.core.playlists.get_items(self.playlists[self.selected_playlist].uri).get() to get a list of all tracks and then build a list of uris with a for loop:

        track_uris = []
        for track in track_list:                                                                        
           track_uris.append(track.uri)

This can be used in tracklist.add
self.core.tracklist.add(uris=track_uris) and it works perfectly as it should.
I am a beginner with mopidy and python and I have the feeling that there is a better way to do this (without the iteration trough the tracks list).
What would be the way, how mopidy experts do this fix ?

I’m not sure what is going on there but the 0.3 release on PyPi is actually a fork of the original and is missing a load of fixes including the one you need: Bugfix playing of playlists · qurben/mopidy-headless@09f6d39 · GitHub

The project seems a little messed up, maybe we should remove it from our list.

What you have is fine but if you look at the original fix, you tdon’t need to call get_items:

track_uris = [track.uri for track in self.playlists[self.selected_playlist].tracks]

Thanks, I knew it could be coded better.
However, the line throws an error “tracks is no member…”
But I found the original and changed it to:

        tracks = self.core.playlists.get_items(self.playlists[self.selected_playlist].uri).get()
        track_uris = [track.uri for track in tracks]

which is nicer than what I had but still needs the get_items. Also it seems there are a lot of useless .get() in the 0.30 code (e.g. behind .play()).
So I share your thoughts about removing the 0.30 and make the original available on PyPi.
The github link to the fix delivers confusing infos. It shows the line, you sent me, and it also shows a line in
reload_playlists(self)
for playlist in self.core.playlists.playlists.get():
This seems not to be correct - the repeated .playlists makes no sense for me and it also throws even more strange errors . I had the idea that this may deliver a different format for the list of playlists which works with the code

track_uris = [track.uri for track in self.playlists[self.selected_playlist].tracks]

Thanks,
Gregor

Sorry, I only had a very quick look. I don’t have the bandwidth right now.