beetbox / beets

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

Fetchart failing from filename encoding issues #5211

Open TheMarstonConnell opened 2 months ago

TheMarstonConnell commented 2 months ago

Running beet fetchart -q gave me this output. It's clear the ' in the album name is causing issues due to some encoding stuff.

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/beets/util/__init__.py", line 496, in move
    os.replace(path, dest)
FileNotFoundError: [Errno 2] No such file or directory: b'/tmp/tmpcpc4ja_m.jpg' -> b'/mnt/import/lidarr/Lana Del Rey/Lana Del Rey/Did you know that there\xe2\x80\x99s a tunnel under Ocean Blvd (2023)/cover.jpg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/beets/util/__init__.py", line 503, in move
    shutil.copyfile(path, tmp)
  File "/usr/lib/python3.11/shutil.py", line 258, in copyfile
    with open(dst, 'wb') as fdst:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/import/lidarr/Lana Del Rey/Lana Del Rey/Did you know that there’s a tunnel under Ocean Blvd (2023)/.cover.jpgttx0xc_c.beets'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/beets/util/__init__.py", line 508, in move
    raise FilesystemError(exc, 'move', (path, dest),
beets.util.FilesystemError: No such file or directory while moving /tmp/tmpcpc4ja_m.jpg to /mnt/import/lidarr/Lana Del Rey/Lana Del Rey/Did you know that there’s a tunnel under Ocean Blvd (2023)/cover.jpg

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/beets/ui/__init__.py", line 1285, in main
    _raw_main(args)
  File "/usr/lib/python3.11/site-packages/beets/ui/__init__.py", line 1272, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.11/site-packages/beetsplug/fetchart.py", line 1083, in func
    self.batch_fetch_art(lib, lib.albums(ui.decargs(args)), opts.force,
  File "/usr/lib/python3.11/site-packages/beetsplug/fetchart.py", line 1145, in batch_fetch_art
    self._set_art(album, candidate)
  File "/usr/lib/python3.11/site-packages/beetsplug/fetchart.py", line 1048, in _set_art
    album.set_art(candidate.path, delete)
  File "/usr/lib/python3.11/site-packages/beets/library.py", line 1317, in set_art
    util.move(path, artdest)
  File "/usr/lib/python3.11/site-packages/beets/util/__init__.py", line 512, in move
    os.remove(tmp)
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/import/lidarr/Lana Del Rey/Lana Del Rey/Did you know that there’s a tunnel under Ocean Blvd (2023)/.cover.jpgttx0xc_c.beets'
/ # beet fetchart -q
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/beets/util/__init__.py", line 496, in move
    os.replace(path, dest)
FileNotFoundError: [Errno 2] No such file or directory: b'/tmp/tmpgzsgna_3.jpg' -> b'/mnt/import/lidarr/Lana Del Rey/Lana Del Rey/Did you know that there\xe2\x80\x99s a tunnel under Ocean Blvd (2023)/cover.jpg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/beets/util/__init__.py", line 503, in move
    shutil.copyfile(path, tmp)
  File "/usr/lib/python3.11/shutil.py", line 258, in copyfile
    with open(dst, 'wb') as fdst:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/import/lidarr/Lana Del Rey/Lana Del Rey/Did you know that there’s a tunnel under Ocean Blvd (2023)/.cover.jpgkimvg4mk.beets'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/beets/util/__init__.py", line 508, in move
    raise FilesystemError(exc, 'move', (path, dest),
beets.util.FilesystemError: No such file or directory while moving /tmp/tmpgzsgna_3.jpg to /mnt/import/lidarr/Lana Del Rey/Lana Del Rey/Did you know that there’s a tunnel under Ocean Blvd (2023)/cover.jpg

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.11/site-packages/beets/ui/__init__.py", line 1285, in main
    _raw_main(args)
  File "/usr/lib/python3.11/site-packages/beets/ui/__init__.py", line 1272, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.11/site-packages/beetsplug/fetchart.py", line 1083, in func
    self.batch_fetch_art(lib, lib.albums(ui.decargs(args)), opts.force,
  File "/usr/lib/python3.11/site-packages/beetsplug/fetchart.py", line 1145, in batch_fetch_art
    self._set_art(album, candidate)
  File "/usr/lib/python3.11/site-packages/beetsplug/fetchart.py", line 1048, in _set_art
    album.set_art(candidate.path, delete)
  File "/usr/lib/python3.11/site-packages/beets/library.py", line 1317, in set_art
    util.move(path, artdest)
  File "/usr/lib/python3.11/site-packages/beets/util/__init__.py", line 512, in move
    os.remove(tmp)
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/import/lidarr/Lana Del Rey/Lana Del Rey/Did you know that there’s a tunnel under Ocean Blvd (2023)/.cover.jpgkimvg4mk.beets'

Setup

My configuration (output of beet config) is:

directory: /mnt/content
library: /home/beets.db

plugins: fetchart embedart lastgenre
fetchart:
    cautious: yes
    cover_names: front back
    sources: filesystem coverart itunes amazon albumart wikipedia
    auto: yes
    minwidth: 0
    maxwidth: 0
    quality: 0
    max_filesize: 0
    enforce_ratio: no
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
    lastfm_key: REDACTED
    store_source: no
    high_resolution: no
    deinterlace: no
    cover_format:
lastgenre:
    count: 5
    whitelist: yes
    min_weight: 10
    fallback:
    canonical: no
    source: album
    force: yes
    auto: yes
    separator: ', '
    prefer_specific: no
    title_case: yes

import:
    none_rec_action: skip

match:
    strong_rec_thresh: 0.2
    medium_rec_thresh: 0.0
    rec_gap_thresh: 0.8
embedart:
    maxwidth: 0
    auto: yes
    compare_threshold: 0
    ifempty: no
    remove_art_file: no
    quality: 0
wisp3rwind commented 2 months ago

Setup

* OS: docker alpine

* Python version: Python 3.11.9

* beets version: 1.6.0

While you seem to be running a development version already: Please update to the latest source, the code path that is causing the error has not been in beets since 2022 (see https://github.com/beetbox/beets/pull/4209). Does the error still occur then?

RiccardoUva commented 1 month ago

same here, on windows it only works when you have your library and the imported file on the c drive

guerda commented 1 week ago

I have the same problem with importing an album into the library with the fetchart plugin enabled. It first says

could not get filesize: [Errno 2] No such file or directory: b'/media/audio/Deichkind/Noch f\xc3\xbcnf Minuten Mutti/01 Introduction d\xe2\x80\x99Allemagne.mp3'

Then it fails on the next step

beets version: 2.0