Implement _current_playlist_playlistid when songid argument is given
This commit is contained in:
parent
2dea0820b2
commit
e3b407c709
@ -373,7 +373,7 @@ class MpdHandler(object):
|
||||
"""
|
||||
raise MpdNotImplemented # TODO
|
||||
|
||||
@handle_pattern(r'^playlistid( "(?P<songid>\S+)")*$')
|
||||
@handle_pattern(r'^playlistid( "(?P<songid>\d+)")*$')
|
||||
def _current_playlist_playlistid(self, songid=None):
|
||||
"""
|
||||
*musicpd.org, current playlist section:*
|
||||
@ -383,8 +383,15 @@ class MpdHandler(object):
|
||||
Displays a list of songs in the playlist. ``SONGID`` is optional
|
||||
and specifies a single song to display info for.
|
||||
"""
|
||||
# TODO Limit selection to songid
|
||||
return self.backend.current_playlist.playlist.mpd_format()
|
||||
if songid is not None:
|
||||
try:
|
||||
songid = int(songid)
|
||||
track = self.backend.current_playlist.get_by_id(songid)
|
||||
return track.mpd_format()
|
||||
except KeyError, e:
|
||||
raise MpdAckError(e)
|
||||
else:
|
||||
return self.backend.current_playlist.playlist.mpd_format()
|
||||
|
||||
@handle_pattern(r'^playlistinfo$')
|
||||
@handle_pattern(r'^playlistinfo "(?P<songpos>\d+)"$')
|
||||
|
||||
@ -653,13 +653,31 @@ class CurrentPlaylistHandlerTest(unittest.TestCase):
|
||||
self.assert_(u'ACK Not implemented' in result)
|
||||
|
||||
def test_playlistid_without_songid(self):
|
||||
self.b.current_playlist.load(Playlist(
|
||||
tracks=[Track(name='a', id=33), Track(name='b', id=38)]))
|
||||
result = self.h.handle_request(u'playlistid')
|
||||
self.assert_(u'Title: a' in result)
|
||||
self.assert_(u'Id: 33' in result)
|
||||
self.assert_(u'Title: b' in result)
|
||||
self.assert_(u'Id: 38' in result)
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_playlistid_with_songid(self):
|
||||
result = self.h.handle_request(u'playlistid "10"')
|
||||
self.b.current_playlist.load(Playlist(
|
||||
tracks=[Track(name='a', id=33), Track(name='b', id=38)]))
|
||||
result = self.h.handle_request(u'playlistid "38"')
|
||||
self.assert_(u'Title: a' not in result)
|
||||
self.assert_(u'Id: 33' not in result)
|
||||
self.assert_(u'Title: b' in result)
|
||||
self.assert_(u'Id: 38' in result)
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_playlistid_with_not_existing_songid_fails(self):
|
||||
self.b.current_playlist.load(Playlist(
|
||||
tracks=[Track(name='a', id=33), Track(name='b', id=38)]))
|
||||
result = self.h.handle_request(u'playlistid "25"')
|
||||
self.assert_(u'ACK Track with ID "25" not found' in result)
|
||||
|
||||
def test_playlistinfo_without_songpos_or_range(self):
|
||||
result = self.h.handle_request(u'playlistinfo')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user