Create tracklist after local browse

Hi,
i’m doing a python script to browse my local media.
After i do Mopidy.library.browse() i get a list of Ref objects.
Then i ask for the URL of the Ref i need, but if i do Mopidy.tracklist.add(url) i always get an empty list.
How can i get the list of tracks after i browse?
Thanks

Since the arguments to TracklistController.add are all optional, if you don’t specify which one you want then python uses the definition order to decide, in this case that’s the tracks argument, which isn’t what you want. You probably meant Mopidy.tracklist.add(uri=your_track_ref.uri).

By using LibraryController.lookup(uris=your_list_of_uris). TracklistController.add does a lookup as part of adding uris to the tracklist (as per the documentation) but that’s more of a by-product. If you just want to get Tracks from Refs, rather than add stuff to the tracklist, then use LibraryController.lookup.

I wanted to add tracks in tracklist to playing them. Isn’t this mandatory?

Yes it is, but that’s not what you asked. Just ignore the 2nd half of my answer and you should be good.

The uri field of Refs i get is “local:directory?type=album” wich don’t seems to be a correct format.
If i pass this uri to Mopidy.Tracklist.add(uri=uri)
and then i ask Mopidy.Tracklist.get_tracks() i get a None list.
Why? Thanks

You should have seen an error in your logs along the lines of “Invalid lookup URI”.

From mopidy.core — Core API — Mopidy 1.1.2-2-g1c19dd5d documentation

The Ref objects representing directories have backend specific URIs. These are opaque values, so no one but the backend that created them should try and derive any meaning from them. The only valid exception to this is checking the scheme, as it is used to route browse requests to the correct backend.

Basically you cannot do a lookup on a directory ref. You need to browse the directory ref(s) until you get down to some track refs. Those can then be added to the tracklist.