beetbox / beets

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

convert plugin: Error copying files in paths with square brackets #3040

Closed Vexatos closed 6 years ago

Vexatos commented 6 years ago

Problem

If the path to a music file contains square brackets [x] and they are not being converted during beet convert (in this case because they are lossy mp3 files and should therefore just be copied), the following error will occur.

$ beet -vv convert -d Converted
user configuration: /home/user/.config/beets/config.yaml
data directory: /home/user/.config/beets
plugin paths: 
Sending event: pluginload
inline: adding item field multidisc
library database: /media/media/Music/beets.db
library directory: /media/media/Music
Sending event: library_opened
Testartist - Testalbum - Testsong
Convert? (Y/n) 
convert: Copying /media/media/Music/Compilations/Testalbum 1/01 Testartist - Testsong.mp3
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.6/site-packages/beets/util/__init__.py", line 456, in copy
    shutil.copyfile(path, dest)
  File "/usr/lib/python3.6/shutil.py", line 120, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: b'/media/media/Music/Compilations/Testalbum 1/01 Testartist - Testsong.mp3'

Error: No such file or directory while copying /media/media/Music/Compilations/Testalbum 1/01 Testartist - Testsong.mp3 to /media/media/Converted/Compilations/Testalbum [1]/01 Testartist - Testsong.mp3

Any music file with square brackets in its path should allow reproducing this. In the example above, the correct path is Testalbum [1] but beets appears to want to use Testalbum 1, stripping the brackets. The target directory appears to be correct.

Setup

My configuration (output of beet config) is:

directory: /media/media/Music
library: /media/media/Music/beets.db

plugins: lastgenre chroma fromfilename web duplicates replaygain smartplaylist scrub inline mbsync convert edit

paths:
    default: $albumartist/%if{$original_year,$original_year }$album%aunique{}/%if{$multidisc,Disc $disc/}%if{$track,$track }$artist - $album - $title
    singleton: $artist/%if{$original_year,$original_year }$artist - $title
    comp: Compilations/$album%aunique{}/%if{$track,$track }$artist - $title
item_fields:
    multidisc: 1 if disctotal > 1 else 0

import:
    timid: yes
    languages: en
timid: yes
acoustid:
    apikey: REDACTED
replaygain:
    backend: bs1770gain
    overwrite: no
    auto: yes
    targetlevel: 89
    r128: [Opus]
    chunk_at: 5000
    method: replaygain
smartplaylist:
    playlist_dir: /media/media/Music/Playlists/
    playlists: [{name: all.m3u, query: ''}]
    relative_to:
    auto: yes
convert:
    never_convert_lossy_files: yes
    copy_album_art: yes
    format: opus
    formats:
        ogg:
            command: ffmpeg -i $source -y -acodec libopus -vn $dest
        mka:
            command: ffmpeg -i $source -y -acodec libopus -vn $dest
        opus:
            command: opusenc $source $dest
            extension: ogg
        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
        flac: ffmpeg -i $source -y -vn -acodec flac $dest
        mp3: ffmpeg -i $source -y -vn -aq 2 $dest
        wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
    dest:
    pretend: no
    threads: 8
    max_bitrate: 500
    auto: no
    tmpdir:
    quiet: no
    embed: yes

    paths: {}
    no_convert: ''
    album_art_maxwidth: 0
duplicates:
    album: no
    checksum: ''
    copy: ''
    count: no
    delete: no
    format: ''
    full: no
    keys: []
    merge: no
    move: ''
    path: no
    tiebreak: {}
    strict: no
    tag: ''
scrub:
    auto: yes
pathfields: {}
album_fields: {}
edit:
    albumfields: album albumartist
    itemfields: track title artist album
    ignore_fields: id path
chroma:
    auto: yes
lastgenre:
    whitelist: yes
    min_weight: 10
    count: 1
    fallback:
    canonical: no
    source: album
    force: yes
    auto: yes
    separator: ', '
    prefer_specific: no
web:
    host: 127.0.0.1
    port: 8337
    cors: ''
    cors_supports_credentials: no
    reverse_proxy: no
    include_paths: no
sampsyo commented 6 years ago

Hmm; that's odd. Can you please show the output of beet ls -p to indicate what path beets is tracking?

Vexatos commented 6 years ago

Interesting.

$ beet ls -p
/media/media/Music/Compilations/Testalbum 1/01 Testartist - Testsong.mp3
sampsyo commented 6 years ago

Looks like this isn't a convert problem then. Do you know how you added this file to your library?

Vexatos commented 6 years ago

I am using a library from someone else for this, apparently it was a duplicate during import, and beets appended the [number] to the end to disambiguate. This happened in 2015 so it might actually be a legacy problem.

sampsyo commented 6 years ago

Alright! If the problem with importing files like this recurs, please reopen this issue.