mpd: Ignore search/find/list with empty filter values (fixes #246)
This commit is contained in:
parent
6aa1ee7f5c
commit
78dec9717d
@ -160,6 +160,10 @@ backends:
|
||||
files (Apple lossless) because it didn't support multiple tag messages from
|
||||
GStreamer per track it scanned.
|
||||
|
||||
- :issue:`246`: The MPD command ``list album artist ""`` and similar
|
||||
``search``, ``find``, and ``list`` commands with empty filter values caused a
|
||||
:exc:`LookupError`, but should have been ignored by the MPD server.
|
||||
|
||||
|
||||
v0.8.1 (2012-10-30)
|
||||
===================
|
||||
|
||||
@ -28,6 +28,8 @@ def _build_query(mpd_query):
|
||||
field = 'uri'
|
||||
field = str(field) # Needed for kwargs keys on OS X and Windows
|
||||
what = m.groupdict()['what']
|
||||
if not what:
|
||||
raise ValueError
|
||||
if field in query:
|
||||
query[field].append(what)
|
||||
else:
|
||||
@ -76,7 +78,10 @@ def find(context, mpd_query):
|
||||
- also uses the search type "date".
|
||||
- uses "file" instead of "filename".
|
||||
"""
|
||||
query = _build_query(mpd_query)
|
||||
try:
|
||||
query = _build_query(mpd_query)
|
||||
except ValueError:
|
||||
return
|
||||
return tracks_to_mpd_format(
|
||||
context.core.library.find_exact(**query).get())
|
||||
|
||||
@ -185,7 +190,10 @@ def list_(context, field, mpd_query=None):
|
||||
- capitalizes the field argument.
|
||||
"""
|
||||
field = field.lower()
|
||||
query = _list_build_query(field, mpd_query)
|
||||
try:
|
||||
query = _list_build_query(field, mpd_query)
|
||||
except ValueError:
|
||||
return
|
||||
if field == 'artist':
|
||||
return _list_artist(context, query)
|
||||
elif field == 'album':
|
||||
@ -211,6 +219,8 @@ def _list_build_query(field, mpd_query):
|
||||
tokens = [t.decode('utf-8') for t in tokens]
|
||||
if len(tokens) == 1:
|
||||
if field == 'album':
|
||||
if not tokens[0]:
|
||||
raise ValueError
|
||||
return {'artist': [tokens[0]]}
|
||||
else:
|
||||
raise MpdArgError(
|
||||
@ -224,6 +234,8 @@ def _list_build_query(field, mpd_query):
|
||||
tokens = tokens[2:]
|
||||
if key not in ('artist', 'album', 'date', 'genre'):
|
||||
raise MpdArgError('not able to parse args', command='list')
|
||||
if not value:
|
||||
raise ValueError
|
||||
if key in query:
|
||||
query[key].append(value)
|
||||
else:
|
||||
@ -351,7 +363,10 @@ def search(context, mpd_query):
|
||||
- also uses the search type "date".
|
||||
- uses "file" instead of "filename".
|
||||
"""
|
||||
query = _build_query(mpd_query)
|
||||
try:
|
||||
query = _build_query(mpd_query)
|
||||
except ValueError:
|
||||
return
|
||||
return tracks_to_mpd_format(
|
||||
context.core.library.search(**query).get())
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user