Add 'date' query support to 'find' and 'search' to improve ncmpcpp media library browsing
This commit is contained in:
parent
7f86026588
commit
5e87dcbfff
@ -13,7 +13,11 @@ No description yet.
|
||||
|
||||
**Changes**
|
||||
|
||||
- No changes yet.
|
||||
- MPD frontend:
|
||||
|
||||
- Add support for "date" queries to both the ``find`` and ``search``
|
||||
commands. This makes media library browsing in ncmpcpp work, though very
|
||||
slow due to all the meta data requests to Spotify.
|
||||
|
||||
|
||||
0.3.1 (2010-01-22)
|
||||
|
||||
@ -41,8 +41,8 @@ def count(frontend, tag, needle):
|
||||
return [('songs', 0), ('playtime', 0)] # TODO
|
||||
|
||||
@handle_pattern(r'^find '
|
||||
r'(?P<mpd_query>("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"?'
|
||||
' "[^"]+"\s?)+)$')
|
||||
r'(?P<mpd_query>("?([Aa]lbum|[Aa]rtist|[Dd]ate|[Ff]ilename|'
|
||||
r'[Tt]itle|[Aa]ny)"? "[^"]+"\s?)+)$')
|
||||
def find(frontend, mpd_query):
|
||||
"""
|
||||
*musicpd.org, music database section:*
|
||||
@ -62,6 +62,10 @@ def find(frontend, mpd_query):
|
||||
|
||||
- does not add quotes around the field argument.
|
||||
- capitalizes the type argument.
|
||||
|
||||
*ncmpcpp:*
|
||||
|
||||
- also uses the search type "date".
|
||||
"""
|
||||
query = _build_query(mpd_query)
|
||||
return frontend.backend.library.find_exact(**query).mpd_format()
|
||||
@ -290,8 +294,8 @@ def rescan(frontend, uri=None):
|
||||
return update(frontend, uri, rescan_unmodified_files=True)
|
||||
|
||||
@handle_pattern(r'^search '
|
||||
r'(?P<mpd_query>("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"?'
|
||||
' "[^"]+"\s?)+)$')
|
||||
r'(?P<mpd_query>("?([Aa]lbum|[Aa]rtist|[Dd]ate|[Ff]ilename|'
|
||||
r'[Tt]itle|[Aa]ny)"? "[^"]+"\s?)+)$')
|
||||
def search(frontend, mpd_query):
|
||||
"""
|
||||
*musicpd.org, music database section:*
|
||||
@ -314,6 +318,10 @@ def search(frontend, mpd_query):
|
||||
|
||||
- does not add quotes around the field argument.
|
||||
- capitalizes the field argument.
|
||||
|
||||
*ncmpcpp:*
|
||||
|
||||
- also uses the search type "date".
|
||||
"""
|
||||
query = _build_query(mpd_query)
|
||||
return frontend.backend.library.search(**query).mpd_format()
|
||||
|
||||
@ -92,7 +92,20 @@ class MusicDatabaseFindTest(unittest.TestCase):
|
||||
result = self.h.handle_request(u'find title "what"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_find_date(self):
|
||||
result = self.h.handle_request(u'find "date" "2002-01-01"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_find_date_without_quotes(self):
|
||||
result = self.h.handle_request(u'find date "2002-01-01"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_find_date_with_capital_d_and_incomplete_date(self):
|
||||
result = self.h.handle_request(u'find Date "2005"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_find_else_should_fail(self):
|
||||
|
||||
result = self.h.handle_request(u'find "somethingelse" "what"')
|
||||
self.assertEqual(result[0], u'ACK [2@0] {find} incorrect arguments')
|
||||
|
||||
@ -338,6 +351,18 @@ class MusicDatabaseSearchTest(unittest.TestCase):
|
||||
result = self.h.handle_request(u'search any "anything"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_search_date(self):
|
||||
result = self.h.handle_request(u'search "date" "2002-01-01"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_search_date_without_quotes(self):
|
||||
result = self.h.handle_request(u'search date "2002-01-01"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_search_date_with_capital_d_and_incomplete_date(self):
|
||||
result = self.h.handle_request(u'search Date "2005"')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_search_else_should_fail(self):
|
||||
result = self.h.handle_request(u'search "sometype" "something"')
|
||||
self.assertEqual(result[0], u'ACK [2@0] {search} incorrect arguments')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user