Mopidy-Local and `max-age` query parameter

I recently learned about directories configuration key for Mopidy-Local: One can customize the top level directories in the library exposed by Mopidy-Local, great!

Playing with that I am not sure I understand how max-age works: The URI associated to the Last Week’s Updates directory is local:directory?max-age=604800. When requesting core.library.browse with that URI, one get directories containing tracks.

I was expecting that requesting the URI local:directory?type=album&max-age=604800 would return albums, but it’s not the case, directories are returned. Is this a bug? Or using both type and max-age is not supported?

Would it make sense to change that behavior?

I’d be interested in implementing this, because I mainly maintain my local library using albums and I’d prefer to see albums than directories of tracks when it makes sense. Tell me if it’s worth the trouble.

Is this a bug? Or using both type and max-age is not supported?

AFAICT, it’s not a bug, but a limitation of current implementation.

Enabling verbose logging I see that the expected SQL select against album table is performed:

janv. 26 09:13:07 argos mopidy[7594]: DEBUG    [HttpServer] mopidy.http.handlers Received RPC message from ::1: b'{\n  "jsonrpc": "2.0",\n  "id": 1,\n  "method": "core.library.browse",\n  "params": {"uri": "local:directory?type=album&max-age=100000"}\n}\n'
janv. 26 09:13:07 argos mopidy[7594]: DEBUG    [LocalBackend-8] mopidy_local.schema SQLite browse query ['100000']:
janv. 26 09:13:07 argos mopidy[7594]:     SELECT 'album' AS type, uri AS uri, name AS name
janv. 26 09:13:07 argos mopidy[7594]:       FROM album
janv. 26 09:13:07 argos mopidy[7594]:      WHERE EXISTS (
janv. 26 09:13:07 argos mopidy[7594]:             SELECT *
janv. 26 09:13:07 argos mopidy[7594]:               FROM track
janv. 26 09:13:07 argos mopidy[7594]:              WHERE album = album.uri
janv. 26 09:13:07 argos mopidy[7594]:                AND last_modified >= (strftime('%s', 'now') - ?) * 1000
janv. 26 09:13:07 argos mopidy[7594]:         )
janv. 26 09:13:07 argos mopidy[7594]:      ORDER BY type, name COLLATE NOCASE

but LocalLibraryProvider._browse_directory() implementation build references to directories even when the matched results are albums: https://github.com/mopidy/mopidy-local/blob/master/mopidy_local/library.py#L174

        for ref in schema.browse(
            self._connect(), type, order, role=roles, **query
        ):  # noqa
            if ref.type == Ref.TRACK or (not query and not role):
                refs.append(ref)
            elif ref.type == Ref.ALBUM:
                refs.append(
                    Ref.directory(

Not clear why…

…and the returned resources are references to directories, not albums, with (strange?) URIs containing the max-age parameter:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "__model__": "Ref",
      "uri": "local:directory?max-age=100000&type=track&album=local:album:md5:561ebf4a3367cb89f30cd17461fb10b3",
      "name": "The Dark Side of the Moon",
      "type": "directory"
    }
  ]
}

which is not homogeneous with results of querying the more URI local:directory?type=album (where references to albums are returned):

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": [
    {
      "__model__": "Ref",
      "uri": "local:album:md5:edbdf98220f9fc7c284011adf7f043a0",
      "name": "\"Charlie\"",
      "type": "album"
    },

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