From 7c414d4abc7a4478ccaddc092e1039c779de6e79 Mon Sep 17 00:00:00 2001 From: Lasse Bigum Date: Thu, 31 Oct 2013 20:15:13 +0100 Subject: [PATCH] Support 'list albumartist' --- mopidy/frontends/mpd/protocol/music_db.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mopidy/frontends/mpd/protocol/music_db.py b/mopidy/frontends/mpd/protocol/music_db.py index 6dd43d68..1c737520 100644 --- a/mopidy/frontends/mpd/protocol/music_db.py +++ b/mopidy/frontends/mpd/protocol/music_db.py @@ -127,7 +127,7 @@ def findadd(context, mpd_query): @handle_request( - r'^list "?(?P([Aa]rtist|[Aa]lbum|[Dd]ate|[Gg]enre))"?' + r'^list "?(?P([Aa]rtist|[Aa]lbumartist|[Aa]lbum|[Dd]ate|[Gg]enre))"?' r'( (?P.*))?$') def list_(context, field, mpd_query=None): """ @@ -136,7 +136,7 @@ def list_(context, field, mpd_query=None): ``list {TYPE} [ARTIST]`` Lists all tags of the specified type. ``TYPE`` should be ``album``, - ``artist``, ``date``, or ``genre``. + ``artist``, ``albumartist``, ``date``, or ``genre``. ``ARTIST`` is an optional parameter when type is ``album``, ``date``, or ``genre``. This filters the result list by an artist. @@ -218,6 +218,8 @@ def list_(context, field, mpd_query=None): return if field == 'artist': return _list_artist(context, query) + if field == 'albumartist': + return _list_albumartist(context, query) elif field == 'album': return _list_album(context, query) elif field == 'date': @@ -236,6 +238,18 @@ def _list_artist(context, query): return artists +def _list_albumartist(context, query): + import logging + logger = logging.getLogger('mopidy.backends.local') + albumartists = set() + results = context.core.library.find_exact(**query).get() + for track in _get_tracks(results): + for artist in track.album.artists: + if artist.name: + albumartists.add(('AlbumArtist', artist.name)) + return albumartists + + def _list_album(context, query): albums = set() results = context.core.library.find_exact(**query).get()