diff --git a/docs/changes.rst b/docs/changes.rst index c7c65621..7a5d0664 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -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) diff --git a/mopidy/frontends/mpd/protocol/music_db.py b/mopidy/frontends/mpd/protocol/music_db.py index fb3a3a09..d50388f5 100644 --- a/mopidy/frontends/mpd/protocol/music_db.py +++ b/mopidy/frontends/mpd/protocol/music_db.py @@ -41,8 +41,8 @@ def count(frontend, tag, needle): return [('songs', 0), ('playtime', 0)] # TODO @handle_pattern(r'^find ' - r'(?P("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"?' - ' "[^"]+"\s?)+)$') + r'(?P("?([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("?([Aa]lbum|[Aa]rtist|[Ff]ilename|[Tt]itle|[Aa]ny)"?' - ' "[^"]+"\s?)+)$') + r'(?P("?([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() diff --git a/tests/frontends/mpd/music_db_test.py b/tests/frontends/mpd/music_db_test.py index 05b8ebd0..486eac4f 100644 --- a/tests/frontends/mpd/music_db_test.py +++ b/tests/frontends/mpd/music_db_test.py @@ -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')