Add support for 'playlistfind filename ...'
This commit is contained in:
parent
26bc1dc435
commit
bf05602318
@ -371,6 +371,7 @@ class MpdFrontend(object):
|
||||
"""
|
||||
return self._current_playlist_playlistinfo()
|
||||
|
||||
@handle_pattern(r'^playlistfind (?P<tag>[^"]+) "(?P<needle>[^"]+)"$')
|
||||
@handle_pattern(r'^playlistfind "(?P<tag>[^"]+)" "(?P<needle>[^"]+)"$')
|
||||
def _current_playlist_playlistfind(self, tag, needle):
|
||||
"""
|
||||
@ -379,7 +380,17 @@ class MpdFrontend(object):
|
||||
``playlistfind {TAG} {NEEDLE}``
|
||||
|
||||
Finds songs in the current playlist with strict matching.
|
||||
|
||||
*GMPC:*
|
||||
|
||||
- does not add quotes around the tag.
|
||||
"""
|
||||
if tag == 'filename':
|
||||
try:
|
||||
track = self.backend.current_playlist.get_by_uri(needle)
|
||||
return track.mpd_format()
|
||||
except KeyError:
|
||||
return None
|
||||
raise MpdNotImplemented # TODO
|
||||
|
||||
@handle_pattern(r'^playlistid( "(?P<songid>\d+)")*$')
|
||||
|
||||
@ -652,6 +652,21 @@ class CurrentPlaylistHandlerTest(unittest.TestCase):
|
||||
result = self.h.handle_request(u'playlistfind "tag" "needle"')
|
||||
self.assert_(u'ACK Not implemented' in result)
|
||||
|
||||
def test_playlistfind_by_filename(self):
|
||||
result = self.h.handle_request(u'playlistfind "filename" "file:///dev/null"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_playlistfind_by_filename_without_quotes(self):
|
||||
result = self.h.handle_request(u'playlistfind filename "file:///dev/null"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_playlistfind_by_filename_in_current_playlist(self):
|
||||
self.b.current_playlist.playlist = Playlist(tracks=[
|
||||
Track(uri='file:///exists')])
|
||||
result = self.h.handle_request(u'playlistfind filename "file:///exists"')
|
||||
self.assert_(u'file: file:///exists' in result)
|
||||
self.assert_(u'OK' 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)]))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user