Extension development: how to remember track names between browse and lookup?


I’m busy creating an extension for the RadioBrowser service (http://radio-browser.info), a radio stream directory. The API docs can be found at https://nl1.api.radio-browser.info/.

I have something working for now: I implemented browse and lookup inside a LibraryProvider subclass.

In the browse method I request lists of stations through the RadioBrowser API containing the name and uuid of the station. I then return models.Ref.Track instances with the name of the station and the uri containing the uuid.

To implement the lookup I have to create models.Track instances from the uri alone so I don’t have access to the name of the track (in this case the station name). Using the RadioBrowser API I can only lookup a single station entry by uuid per request which could mean a lot of needless requests as I already retrieved that information in the browse method.

So far I came up with two possible solutions:

  • Just add the name as part of the uri in browse and extract that in lookup. This is what I currently use and works fine. It just feels very ugly adding additional metadata to the uri. It would also mean that a change in station name would invalidate the uri.
  • Add some caching mechanism mapping station uuid to metadata. This can then be filled from browse and used in lookup. Apart from the extra memory required (lists of stations can be long) how much entries would I need to keep? Especially if there are multiple clients connecting to the mopidy instance.

Any ideas what would be the most appropriate solution? Any additional ideas?


I think Mopidy-Gmusic works in a similar way to your second solution. It calls refresh() to load all the library data, then uses that for subsequent lookups.