beetbox / beetbox/beets

traceback: failed to fetch art...putting in wrong directory...mangled file names.

Open
#5,195 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

```
$ echo "$PWD"; ls */ -d
/library/music/Cat Stevens/Cat Stevens -- On the Road to Find Out (2001)
'Cat Stevens - The Boxset 2001 Art/'
$ beet fetchart -q "$PWD"
Traceback (most recent call last):
File "/usr/share/beets/beets/util/__init__.py", line 496, in move
os.replace(path, dest)
FileNotFoundError: [Errno 2] No such file or directory: b'/tmp/tmp31c51_h5.png' -> b'/library/music/Cat Stevens/Cat Stevens -- On the Road to Find Out (2001)/The Boxset CD01 The City/Cat Stevens -- 00 - On the Road to Find Out.png'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/share/beets/beets/util/__init__.py", line 503, in move
shutil.copyfile(path, tmp)
File "/usr/lib/python3.12/shutil.py", line 262, in copyfile
with open(dst, 'wb') as fdst:
^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/library/music/Cat Stevens/Cat Stevens -- On the Road to Find Out (2001)/The Boxset CD01 The City/.Cat Stevens -- 00 - On the Road to Find Out.pngrcnq849p.beets'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/share/beets/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/tmp31c51_h5.png to /library/music/Cat Stevens/Cat Stevens -- On the Road to Find Out (2001)/The Boxset CD01 The City/Cat Stevens -- 00 - On the Road to Find Out.png

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/beet", line 33, in
sys.exit(load_entry_point('beets==1.6.0', 'console_scripts', 'beet')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/share/beets/beets/ui/__init__.py", line 1285, in main
_raw_main(args)
File "/usr/share/beets/beets/ui/__init__.py", line 1272, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/share/beets/beetsplug/fetchart.py", line 1083, in func
self.batch_fetch_art(lib, lib.albums(ui.decargs(args)), opts.force,
File "/usr/share/beets/beetsplug/fetchart.py", line 1145, in batch_fetch_art
self._set_art(album, candidate)
File "/usr/share/beets/beetsplug/fetchart.py", line 1048, in _set_art
album.set_art(candidate.path, delete)
File "/usr/share/beets/beets/library.py", line 1317, in set_art
util.move(path, artdest)
File "/usr/share/beets/beets/util/__init__.py", line 512, in move
os.remove(tmp)
FileNotFoundError: [Errno 2] No such file or directory: '/library/music/Cat Stevens/Cat Stevens -- On the Road to Find Out (2001)/The Boxset CD01 The City/.Cat Stevens -- 00 - On the Road to Find Out.pngrcnq849p.beets'
```
the root has the .flacs. the art directory that beet/fetchart is trying to save to is not an appropriate place for art to go. it looks like the file names are getting mangled by the parser, but I'm not sure.....either way, I don't know what to do about this traceback...the plugin needs to be able to handle subdirectories inside of album folders... there's no way I can go through 3800 albums looking for subdirectories and then deciding if I want to remove them... plus this breaks the beet run so it aborts whenever there's an issue which defeats the run-in-background functionality of beets.

### Problem

Running this command in verbose (`-vv`) mode:

```
$ beet -vv; beet config
user configuration: $HOME/.config/beets/config.yaml
data directory: $HOME/.config/beets
plugin paths:
Sending event: pluginload
library database: /library/music/.share/beets/beets.db
library directory: /library/music
Sending event: library_opened
---
directory: /library/music/
library: /library/music/.share/beets/beets.db
art_filename: $albumartist -- 00 - $album

import:
copy: no
write: no
move: no

plugins: mbsync fetchart
fetchart:
auto: no
cautious: yes
high_resolution: yes
google_key: REDACTED
fanarttv_key: REDACTED
lastfm_key: REDACTED
store_source: yes
cover_format: PNG
sources:
- filesystem
- coverart: release releasegroup
- itunes
- lastfm
- fanarttv
- google
- '*'
minwidth: 0
maxwidth: 0
quality: 0
max_filesize: 0
enforce_ratio: no
cover_names:
- cover
- front
- art
- album
- folder
google_engine: 001442825323518660753:hrh5ch1gjzm
deinterlace: no
```
### Setup

```
$ uname -a; python3 --version; beet --version; beet --plugins=fetchart version
Linux gigabyte 6.8.4-060804-generic #202404041833 SMP PREEMPT_DYNAMIC Thu Apr 4 18:46:22 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Python 3.12.2
beets version 1.6.0
Python version 3.12.2
plugins: fetchart, mbsync
beets version 1.6.0
Python version 3.12.2
plugins: fetchart
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with `beet fetchart -q` and the verbose configuration shown. Read `beetsplug/fetchart.py` around `batch_fetch_art` and `_set_art`, then `beets/library.py` at `set_art` and `beets/util/__init__.py` at `move`. Done means nested album directories are handled without the traceback and a fetchart run can continue after an affected album.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.