mirror of
https://github.com/beetbox/beets.git
synced 2025-12-29 20:12:33 +01:00
Extraction of cover art of albums with non ascii characters lead to a crash.
This commit is contained in:
parent
13e47472ac
commit
eafdd9e379
3 changed files with 20 additions and 3 deletions
|
|
@ -107,7 +107,8 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
u"for -n")
|
||||
return
|
||||
for album in lib.albums(decargs(args)):
|
||||
artpath = normpath(os.path.join(album.path, filename))
|
||||
albumpath = album.path.decode('utf-8')
|
||||
artpath = normpath(os.path.join(albumpath, filename))
|
||||
artpath = self.extract_first(artpath, album.items())
|
||||
if artpath and opts.associate:
|
||||
album.set_art(artpath)
|
||||
|
|
@ -265,7 +266,7 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
self._log.warning(u'Unknown image type in {0}.',
|
||||
displayable_path(item.path))
|
||||
return
|
||||
outpath += '.' + ext
|
||||
outpath = outpath.decode('utf-8') + '.' + ext
|
||||
|
||||
self._log.info(u'Extracting album art from: {0} to: {1}',
|
||||
item, displayable_path(outpath))
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ Fixes:
|
|||
Unicode filenames. :bug:`1297`
|
||||
* :doc:`/plugins/discogs`: Handle and log more kinds of communication
|
||||
errors. :bug:`1299` :bug:`1305`
|
||||
* :doc:`/plugins/embedart`: Fix a crash that occured when the album path
|
||||
contains non ascii characters.
|
||||
|
||||
For developers:
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from __future__ import (division, absolute_import, print_function,
|
|||
unicode_literals)
|
||||
|
||||
import os.path
|
||||
import shutil
|
||||
from mock import Mock, patch
|
||||
|
||||
from test import _common
|
||||
|
|
@ -41,7 +42,7 @@ def require_artresizer_compare(test):
|
|||
return wrapper
|
||||
|
||||
|
||||
class EmbedartCliTest(unittest.TestCase, TestHelper):
|
||||
class EmbedartCliTest(_common.TestCase, TestHelper):
|
||||
|
||||
small_artpath = os.path.join(_common.RSRC, 'image-2x3.jpg')
|
||||
abbey_artpath = os.path.join(_common.RSRC, 'abbey.jpg')
|
||||
|
|
@ -114,6 +115,19 @@ class EmbedartCliTest(unittest.TestCase, TestHelper):
|
|||
'Image written is not {0}'.format(
|
||||
self.abbey_similarpath))
|
||||
|
||||
def test_non_ascii_album_path(self):
|
||||
import_dir = os.path.join(self.temp_dir, 'testsrcdir\xe4')
|
||||
resource_path = os.path.join(_common.RSRC, 'image.mp3')
|
||||
album = self.add_album_fixture()
|
||||
trackpath = album.items()[0].path
|
||||
albumpath = album.path
|
||||
shutil.copy(resource_path, trackpath.decode('utf-8'))
|
||||
|
||||
self.run_command('extractart', '-n', 'extracted')
|
||||
|
||||
self.assertExists(os.path.join(albumpath.decode('utf-8'),
|
||||
'extracted.png'))
|
||||
|
||||
|
||||
class EmbedartTest(unittest.TestCase):
|
||||
@patch('beetsplug.embedart.subprocess')
|
||||
|
|
|
|||
Loading…
Reference in a new issue