From e5497c749459fd1bad37df456297d0eff10a279e Mon Sep 17 00:00:00 2001 From: Johnny Robeson Date: Mon, 25 Jul 2016 03:26:29 -0400 Subject: [PATCH] use stringed template vars on PY3 in convert plugin We decode them with `surrogateescape`, so we avoid decoding errors --- beetsplug/convert.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 4e3556684..e48b455f5 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -22,6 +22,7 @@ import threading import subprocess import tempfile import shlex +import six from string import Template from beets import ui, util, plugins, config @@ -183,6 +184,11 @@ class ConvertPlugin(BeetsPlugin): self._log.info(u'Encoding {0}', util.displayable_path(source)) # Substitute $source and $dest in the argument list. + if not six.PY2: + command = command.decode(ui._arg_encoding(), 'surrogateescape') + source = source.decode(ui._arg_encoding(), 'surrogateescape') + dest = dest.decode(ui._arg_encoding(), 'surrogateescape') + args = shlex.split(command) for i, arg in enumerate(args): args[i] = Template(arg).safe_substitute({