beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.74k stars 1.82k forks source link

Import fails with UnicodeEncodeError when convert plugin in use and filename contains unrecognized character #3572

Closed ghost closed 4 years ago

ghost commented 4 years ago

Problem

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

Setup

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
sampsyo commented 4 years ago

Hi! This looks like the same error as #3572. Could you please continue the discussion there?

ghost commented 4 years ago

Hi there, I assume you meant to reference #3526 - I will comment there, thank you