Merge pull request #754 from trygveaa/feature/mpd-browse-albums

mpd: Support albums in browse
This commit is contained in:
Thomas Adamcik 2014-06-21 12:11:55 +02:00
commit b81a9569c8
2 changed files with 6 additions and 2 deletions

View File

@ -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(

View File

@ -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')