mirror of
https://github.com/beetbox/beets.git
synced 2026-02-22 07:14:24 +01:00
Attempt to fix duplicates #2873
This commit is contained in:
parent
5b6dff34a1
commit
923e3bacd6
1 changed files with 18 additions and 2 deletions
|
|
@ -17,14 +17,17 @@
|
|||
"""
|
||||
from __future__ import division, absolute_import, print_function
|
||||
|
||||
import platform
|
||||
import shlex
|
||||
import six
|
||||
|
||||
from beets import util
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.ui import decargs, print_, Subcommand, UserError
|
||||
from beets.util import command_output, displayable_path, subprocess, \
|
||||
bytestring_path, MoveOperation
|
||||
from beets.library import Item, Album
|
||||
import six
|
||||
|
||||
|
||||
PLUGIN = 'duplicates'
|
||||
|
||||
|
|
@ -197,7 +200,20 @@ class DuplicatesPlugin(BeetsPlugin):
|
|||
output as flexattr on a key that is the name of the program, and
|
||||
return the key, checksum tuple.
|
||||
"""
|
||||
args = [p.format(file=item.path) for p in shlex.split(prog)]
|
||||
# On Python 3, we need to construct the command to invoke as a
|
||||
# Unicode string. On Unix, this is a little unfortunate---the OS is
|
||||
# expecting bytes---so we use surrogate escaping and decode with the
|
||||
# argument encoding, which is the same encoding that will then be
|
||||
# *reversed* to recover the same bytes before invoking the OS. On
|
||||
# Windows, we want to preserve the Unicode filename "as is."
|
||||
if not six.PY2:
|
||||
if platform.system() == 'Windows':
|
||||
args = [p.format(file=item.path.decode(util._fsencoding()))
|
||||
for p in shlex.split(prog)]
|
||||
else:
|
||||
args = [p.format(file=item.path.decode(util.arg_encoding(),
|
||||
'surrogateescape')) for p in shlex.split(prog)]
|
||||
|
||||
key = args[0]
|
||||
checksum = getattr(item, key, False)
|
||||
if not checksum:
|
||||
|
|
|
|||
Loading…
Reference in a new issue