Playlist track names with RPC method

I have a playlist of radio streams. If I query the playlist to get the track list with RPC method:

{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "core.playlists.get_items",
    "params": [
        "m3u:Radio%20List.m3u"
    ]
}

I get many radio stations without “name”, but just “uri”. But if I use the same method from my pythons script:

items = self.core.playlists.get_items(value)
tracks=[]
 try:
            for a in items.get():
                tracks.append(a.uri)
 except ValueError:
            return log.info("Invalid playlist: %s",value)
 self.core.tracklist.add(uris=tracks)

I get all the names correctly.
Where am I wrong with the RPC methos (I need to use that one)?

Your python script appears to get the items and then adds them to the tracklist. When you add them to the tracklist:

If uris is given instead of tracks, the URIs are looked up in the library and the resulting tracks are added to the tracklist.

https://docs.mopidy.com/en/latest/api/core/#mopidy.core.TracklistController.add

Doing that “lookup” will provided the full metadata.

Your two examples don’t do the same thing because the first example is incomplete.

I should add that there can be a little more to it with m3u playlists; each item can be also accompanied by some metadata, including a name. That name will also be returned by get_items but if you ever do a lookup of the uri then that name will be replaced by whatever it finds.

Yes, thanks. I am doing the lookup for each uri. The problem is that each Radio has its own way to show the name. Someone in the “artist” field, some other in the “album” and only few in the “name” field.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.