Open mudssky opened 4 years ago
maybe we need a configuration to set utf-8 encode
Hi! There is little that beets can do about this itself… your system configuration has specified that you're using gbk
for argument encodings, but you are trying to use a filename that does not fit that encoding as an argument. Perhaps you want to consider changing your terminal's locale settings to a UTF-8 locale?
For example, export LC_ALL=<lang>_<country>.UTF-8
.
Even so, we should probably avoid a crash here, although I'm not entirely sure how. Maybe by just catching the error and printing a more useful message?
I received a similar error.
Running beet import
on a directory containing a file with a special/unrecognized character causes the import to fail when the convert plugin is enabled.
The error does not occur if the file is renamed to something else (like "abc.flac") before importing.
Sending event: write
zero: images: -> None
Sending event: after_write
Sending event: database_change
convert: Encoding /root/temp/112 - Soleil de Nuit (mit Pierre Maubouch).flac
Traceback (most recent call last):
File "/usr/local/bin/beet", line 11, in <module>
load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
File "/usr/local/lib/python3.7/site-packages/beets/ui/__init__.py", line 1266, in main
_raw_main(args)
File "/usr/local/lib/python3.7/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/local/lib/python3.7/site-packages/beets/ui/commands.py", line 955, in import_func
import_files(lib, paths, query)
File "/usr/local/lib/python3.7/site-packages/beets/ui/commands.py", line 925, in import_files
session.run()
File "/usr/local/lib/python3.7/site-packages/beets/importer.py", line 329, in run
pl.run_parallel(QUEUE_SIZE)
File "/usr/local/lib/python3.7/site-packages/beets/util/pipeline.py", line 445, in run_parallel
six.reraise(exc_info[0], exc_info[1], exc_info[2])
File "/usr/local/lib/python3.7/site-packages/six.py", line 703, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/beets/util/pipeline.py", line 312, in run
out = self.coro.send(msg)
File "/usr/local/lib/python3.7/site-packages/beets/util/pipeline.py", line 194, in coro
func(*(args + (task,)))
File "/usr/local/lib/python3.7/site-packages/beets/importer.py", line 1511, in plugin_stage
func(session, task)
File "/usr/local/lib/python3.7/site-packages/beets/plugins.py", line 143, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/beetsplug/convert.py", line 177, in auto_convert
self.convert_on_import(config.lib, item)
File "/usr/local/lib/python3.7/site-packages/beetsplug/convert.py", line 479, in convert_on_import
self.encode(command, item.path, dest)
File "/usr/local/lib/python3.7/site-packages/beetsplug/convert.py", line 223, in encode
encode_cmd.append(args[i].encode(util.arg_encoding()))
UnicodeEncodeError: 'utf-8' codec can't encode character '\udce9' in position 145: surrogates not allowed
An archive with the file in question inside is here
Output of locale
command is:
root@music:~ # locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_ALL=en_US.UTF-8
My configuration (output of beet config
) is:
directory: /root/music/managed
art_filename: folder
ui:
color: yes
import:
move: yes
timid: yes
languages: en
bell: yes
match:
strong_rec_thresh: 0.02
plugins: chroma convert discogs embedart ftintitle info replaygain scrub zero
chroma:
auto: yes
convert:
auto: yes
album_art_maxwidth: 800
dest: /root/music/conversions_backup
embed: no
never_convert_lossy_files: yes
format: flac
formats:
flac:
command: ffmpeg -i $source -y -vn -acodec flac -compression_level 12 $dest
extension: flac
aac:
command: ffmpeg -i $source -y -vn -acodec aac -aq 1 $dest
extension: m4a
alac:
command: ffmpeg -i $source -y -vn -acodec alac $dest
extension: m4a
mp3: ffmpeg -i $source -y -vn -aq 2 $dest
opus: ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest
ogg: ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest
wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
pretend: no
threads: 4
id3v23: inherit
max_bitrate: 500
tmpdir:
quiet: no
paths: {}
no_convert: ''
copy_album_art: no
embedart:
auto: no
maxwidth: 0
compare_threshold: 0
ifempty: no
remove_art_file: no
ftintitle:
auto: yes
format: (feat. {0})
drop: no
replaygain:
auto: yes
backend: gstreamer
overwrite: yes
noclip: yes
targetlevel: 89
r128: [Opus]
scrub:
auto: yes
zero:
auto: yes
fields: images
keep_fields: []
update_database: no
discogs:
apikey: REDACTED
apisecret: REDACTED
tokenfile: discogs_token.json
source_weight: 0.5
user_token: REDACTED
U+DCE9
isn't a valid UTF-8 character, so I don't think there's much we can really do here - the filename needs amending manually to remove this character.
Hi is there any solution to this? I am also having the same problem when importing a file with unicode characters.
O:\Test\りりあ。\import test>beet import "01 - 貴方の側に。.flac"
error: no such file or directory: 01 - ??????.flac
And when running this command to import all files in the directory, I get this error:
O:\Test\りりあ。\import test>beet import .
O:\Test\りりあ。\import test (1 items)
Tagging:
りりあ。 - 貴方の側に。
URL:
https://musicbrainz.org/release/2c62c778-211d-478f-b674-efd5701939b1
(Similarity: 100.0%) (Digital Media, 2023, JP, TOY’S FACTORY, TFDS-00923)
convert: Encoding O:\Lidarr Test\りりあ。\import test\01 - 貴方の側に。.flac
Traceback (most recent call last):
File "C:\Users\User\AppData\Roaming\Python\Python38\Scripts\beet-script.py", line 11, in <module>
load_entry_point('beets==1.6.0', 'console_scripts', 'beet')()
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\ui\__init__.py", line 1285, in main
_raw_main(args)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\ui\__init__.py", line 1272, in _raw_main subcommand.func(lib, suboptions, subargs)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\ui\commands.py", line 973, in import_func
import_files(lib, paths, query)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\ui\commands.py", line 943, in import_files
session.run()
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\importer.py", line 340, in run
pl.run_parallel(QUEUE_SIZE)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\util\pipeline.py", line 446, in run_parallel
raise exc_info[1].with_traceback(exc_info[2])
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\util\pipeline.py", line 311, in run
out = self.coro.send(msg)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\util\pipeline.py", line 193, in coro
func(*(args + (task,)))
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\importer.py", line 1535, in plugin_stage func(session, task)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\plugins.py", line 145, in wrapper
return func(*args, **kwargs)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beetsplug\convert.py", line 183, in auto_convert
par_map(lambda item: self.convert_on_import(config.lib, item),
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beets\util\__init__.py", line 1061, in par_map pool.map(transform, items)
File "c:\program files\python38\lib\multiprocessing\pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "c:\program files\python38\lib\multiprocessing\pool.py", line 771, in get
raise self._value
File "c:\program files\python38\lib\multiprocessing\pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "c:\program files\python38\lib\multiprocessing\pool.py", line 48, in mapstar
return list(map(*args))
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beetsplug\convert.py", line 183, in <lambda>
par_map(lambda item: self.convert_on_import(config.lib, item),
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beetsplug\convert.py", line 513, in convert_on_import
self.encode(command, item.path, dest)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\beetsplug\convert.py", line 216, in encode
encode_cmd.append(args[i].encode(util.arg_encoding())) # encode_cmd.append(args[i].encode(util.arg_encoding()))
File "c:\program files\python38\lib\encodings\cp1252.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 15-18: character maps to <undefined>
Problem
This is the filename
beet ls title:マジヤバもーそうLOVE
-f '$path'when use query to specific this file to convert ,cause error:
UnicodeEncodeError: 'gbk' codec can't encode character '\u2665' in position 39: illegal multibyte sequence
My system language is Chinese, it seems like the convert plugin encode the command string to gbkenter the unicode string in ipython i figured out '\u2665' =
♥
but the unicode character♥
can't be find in gbk ,i think it's no need to encode gbk on my system,so i edit the py file to return utf-8 directly, then it work properly
C:\users\caichengtao05\appdata\local\programs\python\python37-32\lib\site-packages\beets\util\__init__.py
line 321convert succeed:
Running this command in verbose (
-vv
) mode:Led to this problem:
Here's a link to the music files that trigger the bug (if relevant):
Setup
beet config
) is: