Merge branch 'feature/list_albumartist' into develop
This commit is contained in:
commit
463978e246
@ -127,8 +127,8 @@ def findadd(context, mpd_query):
|
||||
|
||||
|
||||
@handle_request(
|
||||
r'^list "?(?P<field>([Aa]rtist|[Aa]lbum|[Dd]ate|[Gg]enre))"?'
|
||||
r'( (?P<mpd_query>.*))?$')
|
||||
r'^list "?(?P<field>([Aa]rtist|[Aa]lbumartist|[Aa]lbum|[Dd]ate|'
|
||||
r'[Gg]enre))"?( (?P<mpd_query>.*))?$')
|
||||
def list_(context, field, mpd_query=None):
|
||||
"""
|
||||
*musicpd.org, music database section:*
|
||||
@ -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,17 @@ def _list_artist(context, query):
|
||||
return artists
|
||||
|
||||
|
||||
def _list_albumartist(context, query):
|
||||
albumartists = set()
|
||||
results = context.core.library.find_exact(**query).get()
|
||||
for track in _get_tracks(results):
|
||||
if track.album:
|
||||
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()
|
||||
|
||||
@ -108,6 +108,9 @@ class LocalLibraryProviderTest(unittest.TestCase):
|
||||
result = self.library.find_exact(artist=['unknown artist'])
|
||||
self.assertEqual(list(result[0].tracks), [])
|
||||
|
||||
result = self.library.find_exact(albumartist=['unknown albumartist'])
|
||||
self.assertEqual(list(result[0].tracks), [])
|
||||
|
||||
result = self.library.find_exact(album=['unknown artist'])
|
||||
self.assertEqual(list(result[0].tracks), [])
|
||||
|
||||
@ -225,6 +228,9 @@ class LocalLibraryProviderTest(unittest.TestCase):
|
||||
test = lambda: self.library.find_exact(artist=[''])
|
||||
self.assertRaises(LookupError, test)
|
||||
|
||||
test = lambda: self.library.find_exact(albumartist=[''])
|
||||
self.assertRaises(LookupError, test)
|
||||
|
||||
test = lambda: self.library.find_exact(track=[''])
|
||||
self.assertRaises(LookupError, test)
|
||||
|
||||
@ -247,6 +253,9 @@ class LocalLibraryProviderTest(unittest.TestCase):
|
||||
result = self.library.search(artist=['unknown artist'])
|
||||
self.assertEqual(list(result[0].tracks), [])
|
||||
|
||||
result = self.library.search(albumartist=['unknown albumartist'])
|
||||
self.assertEqual(list(result[0].tracks), [])
|
||||
|
||||
result = self.library.search(album=['unknown artist'])
|
||||
self.assertEqual(list(result[0].tracks), [])
|
||||
|
||||
@ -358,6 +367,9 @@ class LocalLibraryProviderTest(unittest.TestCase):
|
||||
test = lambda: self.library.search(artist=[''])
|
||||
self.assertRaises(LookupError, test)
|
||||
|
||||
test = lambda: self.library.search(albumartist=[''])
|
||||
self.assertRaises(LookupError, test)
|
||||
|
||||
test = lambda: self.library.search(track=[''])
|
||||
self.assertRaises(LookupError, test)
|
||||
|
||||
|
||||
@ -398,6 +398,66 @@ class MusicDatabaseListTest(protocol.BaseTestCase):
|
||||
self.assertNotInResponse('Artist: ')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
### Albumartist
|
||||
|
||||
def test_list_albumartist_with_quotes(self):
|
||||
self.sendRequest('list "albumartist"')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_without_quotes(self):
|
||||
self.sendRequest('list albumartist')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_without_quotes_and_capitalized(self):
|
||||
self.sendRequest('list Albumartist')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_with_query_of_one_token(self):
|
||||
self.sendRequest('list "albumartist" "anartist"')
|
||||
self.assertEqualResponse(
|
||||
'ACK [2@0] {list} should be "Album" for 3 arguments')
|
||||
|
||||
def test_list_albumartist_with_unknown_field_in_query_returns_ack(self):
|
||||
self.sendRequest('list "albumartist" "foo" "bar"')
|
||||
self.assertEqualResponse('ACK [2@0] {list} not able to parse args')
|
||||
|
||||
def test_list_albumartist_by_artist(self):
|
||||
self.sendRequest('list "albumartist" "artist" "anartist"')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_by_album(self):
|
||||
self.sendRequest('list "albumartist" "album" "analbum"')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_by_full_date(self):
|
||||
self.sendRequest('list "albumartist" "date" "2001-01-01"')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_by_year(self):
|
||||
self.sendRequest('list "albumartist" "date" "2001"')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_by_genre(self):
|
||||
self.sendRequest('list "albumartist" "genre" "agenre"')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_by_artist_and_album(self):
|
||||
self.sendRequest(
|
||||
'list "albumartist" "artist" "anartist" "album" "analbum"')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_without_filter_value(self):
|
||||
self.sendRequest('list "albumartist" "artist" ""')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
def test_list_albumartist_should_not_return_artists_without_names(self):
|
||||
self.backend.library.dummy_find_exact_result = SearchResult(
|
||||
tracks=[Track(album=Album(artists=[Artist(name='')]))])
|
||||
|
||||
self.sendRequest('list "albumartist"')
|
||||
self.assertNotInResponse('Artist: ')
|
||||
self.assertInResponse('OK')
|
||||
|
||||
### Album
|
||||
|
||||
def test_list_album_with_quotes(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user