From 89c82dc63d24fc08b8db668761243981f1f1d7a4 Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Fri, 12 Sep 2014 11:07:43 +0200 Subject: [PATCH] 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 --- beets/util/confit.py | 21 +++++++++++++-------- beetsplug/fetchart.py | 1 + test/helper.py | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/beets/util/confit.py b/beets/util/confit.py index e5e48ec4a..c9051de53 100644 --- a/beets/util/confit.py +++ b/beets/util/confit.py @@ -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): diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 632982edc..1474a7b09 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -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: diff --git a/test/helper.py b/test/helper.py index bfc433528..0688708fd 100644 --- a/test/helper.py +++ b/test/helper.py @@ -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