From 5b8a9a3fb40a2a4515a30be74d9b1312a5a0f7cd Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 21 Jun 2014 01:51:36 +0200 Subject: [PATCH 1/2] mpd: Support albums in browse Albums are also containers of tracks, similar to directories and playlists. Treat them equally when browsing. --- mopidy/mpd/dispatcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mopidy/mpd/dispatcher.py b/mopidy/mpd/dispatcher.py index 3ca255bf..b28140f2 100644 --- a/mopidy/mpd/dispatcher.py +++ b/mopidy/mpd/dispatcher.py @@ -293,7 +293,7 @@ class MpdContext(object): for part in path_parts: for ref in self.core.library.browse(uri).get(): - if (ref.type in (ref.DIRECTORY, ref.PLAYLIST) and + if (ref.type in (ref.DIRECTORY, ref.ALBUM, ref.PLAYLIST) and ref.name == part): uri = ref.uri break @@ -308,7 +308,7 @@ class MpdContext(object): base_path, future = path_and_futures.pop() for ref in future.get(): path = '/'.join([base_path, ref.name.replace('/', '')]) - if ref.type in (ref.DIRECTORY, ref.PLAYLIST): + if ref.type in (ref.DIRECTORY, ref.ALBUM, ref.PLAYLIST): yield (path, None) if recursive: path_and_futures.append( From 0b7243dce1211a3ea6d7a36168cc23837d9155f3 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sat, 21 Jun 2014 01:52:44 +0200 Subject: [PATCH 2/2] mpd: Test albums in listall(info) --- tests/mpd/protocol/test_music_db.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/mpd/protocol/test_music_db.py b/tests/mpd/protocol/test_music_db.py index d983ea69..608bbf62 100644 --- a/tests/mpd/protocol/test_music_db.py +++ b/tests/mpd/protocol/test_music_db.py @@ -128,6 +128,7 @@ class MusicDatabaseHandlerTest(protocol.BaseTestCase): self.backend.library.dummy_browse_result = { 'dummy:/': [Ref.track(uri='dummy:/a', name='a'), Ref.directory(uri='dummy:/foo', name='foo'), + Ref.album(uri='dummy:/album', name='album'), Ref.playlist(uri='dummy:/pl', name='pl')], 'dummy:/foo': [Ref.track(uri='dummy:/foo/b', name='b')]} @@ -135,6 +136,7 @@ class MusicDatabaseHandlerTest(protocol.BaseTestCase): self.assertInResponse('file: dummy:/a') self.assertInResponse('directory: /dummy/foo') + self.assertInResponse('directory: /dummy/album') self.assertInResponse('directory: /dummy/pl') self.assertInResponse('file: dummy:/foo/b') self.assertInResponse('OK') @@ -185,6 +187,7 @@ class MusicDatabaseHandlerTest(protocol.BaseTestCase): self.backend.library.dummy_browse_result = { 'dummy:/': [Ref.track(uri='dummy:/a', name='a'), Ref.directory(uri='dummy:/foo', name='foo'), + Ref.album(uri='dummy:/album', name='album'), Ref.playlist(uri='dummy:/pl', name='pl')], 'dummy:/foo': [Ref.track(uri='dummy:/foo/b', name='b')]} @@ -193,6 +196,7 @@ class MusicDatabaseHandlerTest(protocol.BaseTestCase): self.assertInResponse('file: dummy:/a') self.assertInResponse('Title: a') self.assertInResponse('directory: /dummy/foo') + self.assertInResponse('directory: /dummy/album') self.assertInResponse('directory: /dummy/pl') self.assertInResponse('file: dummy:/foo/b') self.assertInResponse('Title: b')