diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 2cc362e4a..f131bd9d5 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -31,6 +31,7 @@ from beets import util from beets import config from beets.util.artresizer import ArtResizer from beets.util import confit +from beets.util import syspath, bytestring_path try: import itunes @@ -599,15 +600,16 @@ class FileSystem(LocalArtSource): cautious = extra['cautious'] for path in paths: - if not os.path.isdir(path): + if not os.path.isdir(syspath(path)): continue # Find all files that look like images in the directory. images = [] - for fn in os.listdir(path): + for fn in os.listdir(syspath(path)): + fn = bytestring_path(fn) for ext in IMAGE_EXTENSIONS: if fn.lower().endswith(b'.' + ext.encode('utf8')) and \ - os.path.isfile(os.path.join(path, fn)): + os.path.isfile(syspath(os.path.join(path, fn))): images.append(fn) # Look for "preferred" filenames. diff --git a/docs/changelog.rst b/docs/changelog.rst index 2596a8ba5..1069552c0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -12,6 +12,8 @@ Some fixes for Windows: addition to forward slashes). This only applies on Windows. * :doc:`/plugins/embedart`: Image similarity comparison with ImageMagick should now work on Windows. +* :doc:`/plugins/fetchart`: The plugin should work more reliably with + non-ASCII paths. Fixes: diff --git a/test/helper.py b/test/helper.py index 197a85d78..3196e265e 100644 --- a/test/helper.py +++ b/test/helper.py @@ -454,9 +454,9 @@ class TestHelper(object): parent = os.path.dirname(path) if not os.path.isdir(parent): - os.makedirs(parent) + os.makedirs(util.syspath(parent)) - with open(path, 'a+') as f: + with open(util.syspath(path), 'a+') as f: f.write(content) return path diff --git a/test/test_fetchart.py b/test/test_fetchart.py index db3fef8ec..52e7758b8 100644 --- a/test/test_fetchart.py +++ b/test/test_fetchart.py @@ -18,6 +18,7 @@ from __future__ import division, absolute_import, print_function import os from test._common import unittest from test.helper import TestHelper +from beets import util class FetchartCliTest(unittest.TestCase, TestHelper): @@ -41,7 +42,7 @@ class FetchartCliTest(unittest.TestCase, TestHelper): self.album.load() self.assertEqual(self.album['artpath'], cover_path) - with open(cover_path, 'r') as f: + with open(util.syspath(cover_path), 'r') as f: self.assertEqual(f.read(), 'IMAGE') def test_filesystem_does_not_pick_up_folder(self):