From 882844bc776e7cdaa8f190714744afaccf38c1a9 Mon Sep 17 00:00:00 2001 From: Bruno Cauet Date: Thu, 9 Apr 2015 18:02:06 +0200 Subject: [PATCH] Echonest conversion command: only use byte strings Temp file name was unicode, so if other parts of the command were utf8-encoded non-ascii strings the command would fail (in beets.util.command_output()). Requesting a temp file with a byte string path fixes the issue. Fix #1407. --- beetsplug/echonest.py | 2 +- test/test_echonest.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/beetsplug/echonest.py b/beetsplug/echonest.py index f04cbf9bb..2c8a35c69 100644 --- a/beetsplug/echonest.py +++ b/beetsplug/echonest.py @@ -289,7 +289,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin): pending. This is stolen from Jakob Schnitzers convert plugin. """ - fd, dest = tempfile.mkstemp(u'.ogg') + fd, dest = tempfile.mkstemp(b'.ogg') os.close(fd) self._log.info(u'encoding {0} to {1}', diff --git a/test/test_echonest.py b/test/test_echonest.py index 6a1929b6f..1289decd2 100644 --- a/test/test_echonest.py +++ b/test/test_echonest.py @@ -109,6 +109,12 @@ class EchonestCliTest(unittest.TestCase, TestHelper): self.assertNotEqual(item.path, echonest_track.call_args[1]['filename']) + @patch('pyechonest.song.search') + @patch('beetsplug.echonest.CONVERT_COMMAND', 'cp $source $dest') + def test_analyze_convert2(self, echonest_search): + self.add_item(format='FLAC', path=b'm\xc3\xacn.flac') + self.run_command('echonest') + @patch('pyechonest.song.profile') @patch('pyechonest.song.search') @patch('pyechonest.track.track_from_filename')