fetchart: correctly handle path encoding

* Ensure that `config.as_str_seq()` returns a list of unicode objects.
* Map these to bytestring paths so we can compare them to other paths.

Fixes #887
This commit is contained in:
Thomas Scholtes 2014-09-12 11:07:43 +02:00
parent 0bb6348df3
commit 89c82dc63d
3 changed files with 15 additions and 9 deletions

View file

@ -1077,16 +1077,21 @@ class StrSeq(Template):
return value.split()
else:
return [value]
else:
try:
value = list(value)
except TypeError:
self.fail('must be a whitespace-separated string or a list',
view, True)
if all(isinstance(x, BASESTRING) for x in value):
return value
try:
value = list(value)
except TypeError:
self.fail('must be a whitespace-separated string or a list',
view, True)
def convert(x):
if isinstance(x, unicode):
return x
elif isinstance(x, BASESTRING):
return x.decode('utf8', 'ignore')
else:
self.fail('must be a list of strings', view, True)
return map(convert, value)
class Filename(Template):

View file

@ -234,6 +234,7 @@ def art_for_album(album, paths, maxwidth=None, local_only=False):
# Local art.
cover_names = config['fetchart']['cover_names'].as_str_seq()
cover_names = map(util.bytestring_path, cover_names)
cautious = config['fetchart']['cautious'].get(bool)
if paths:
for path in paths:

View file

@ -253,7 +253,7 @@ class TestHelper(object):
values['title'] = values['title'].format(item_count)
item = Item(**values)
item.add(self.lib)
if not 'path' in values_:
if 'path' not in values_:
item['path'] = item.destination()
item.store()
return item