beets
beets copied to clipboard
thumbnails: Path manipulation is broken on Python 3
Problem
Running this command in verbose (-vv) mode:
emily@renko ~> beet -vv thumbnails
user configuration: /home/emily/.config/beets/config.yaml
data directory: /home/emily/.config/beets
plugin paths:
Sending event: pluginload
inline: adding item field disc_and_track
inline: adding item field artist_and_title
inline: adding item field original_date
ImageMagick version check failed: [Errno 2] No such file or directory: 'magick': 'magick'
artresizer: method is (2, (6, 9, 10), True)
ImageMagick version check failed: [Errno 2] No such file or directory: 'magick': 'magick'
thumbnails: using IM to write metadata
thumbnails: using Python Pathlib to compute URIs
library database: /home/emily/share/beets/music.db
library directory: /home/emily/media/music
Sending event: library_opened
ImageMagick version check failed: [Errno 2] No such file or directory: 'magick': 'magick'
thumbnails: using IM to write metadata
thumbnails: using Python Pathlib to compute URIs
thumbnails: generating thumbnail for American Football - American Football
Traceback (most recent call last):
File "/nix/store/xm1ngnn0fhb95ys3nf967yl4bwcbdxk0-beets-1.4.9/bin/.beet-wrapped", line 9, in <module>
sys.exit(main())
File "/nix/store/xm1ngnn0fhb95ys3nf967yl4bwcbdxk0-beets-1.4.9/lib/python3.7/site-packages/beets/ui/__init__.py", line 1266, in main
_raw_main(args)
File "/nix/store/xm1ngnn0fhb95ys3nf967yl4bwcbdxk0-beets-1.4.9/lib/python3.7/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/nix/store/xm1ngnn0fhb95ys3nf967yl4bwcbdxk0-beets-1.4.9/lib/python3.7/site-packages/beetsplug/thumbnails.py", line 78, in process_query
self.process_album(album)
File "/nix/store/xm1ngnn0fhb95ys3nf967yl4bwcbdxk0-beets-1.4.9/lib/python3.7/site-packages/beetsplug/thumbnails.py", line 132, in process_album
wrote &= self.make_cover_thumbnail(album, 256, LARGE_DIR)
File "/nix/store/xm1ngnn0fhb95ys3nf967yl4bwcbdxk0-beets-1.4.9/lib/python3.7/site-packages/beetsplug/thumbnails.py", line 144, in make_cover_thumbnail
target = os.path.join(target_dir, self.thumbnail_file_name(album.path))
File "/nix/store/xm1ngnn0fhb95ys3nf967yl4bwcbdxk0-beets-1.4.9/lib/python3.7/site-packages/beetsplug/thumbnails.py", line 165, in thumbnail_file_name
uri = self.get_uri(path)
File "/nix/store/xm1ngnn0fhb95ys3nf967yl4bwcbdxk0-beets-1.4.9/lib/python3.7/site-packages/beetsplug/thumbnails.py", line 227, in uri
return PurePosixPath(path).as_uri()
File "/nix/store/drr8qcgiccfc5by09r5zc30flgwh1mbx-python3-3.7.5/lib/python3.7/pathlib.py", line 633, in __new__
return cls._from_parts(args)
File "/nix/store/drr8qcgiccfc5by09r5zc30flgwh1mbx-python3-3.7.5/lib/python3.7/pathlib.py", line 665, in _from_parts
drv, root, parts = self._parse_args(args)
File "/nix/store/drr8qcgiccfc5by09r5zc30flgwh1mbx-python3-3.7.5/lib/python3.7/pathlib.py", line 657, in _parse_args
% type(a))
TypeError: argument should be a str object or an os.PathLike object returning str, not <class 'bytes'>
Setup
- OS: NixOS unstable
- Python version: 3.7.5
- beets version: 1.4.9
- Turning off plugins made problem go away (yes/no): somewhat by definition, yes :)
My configuration (output of beet config) is:
directory: ~/media/music
library: ~/share/beets/music.db
plugins: inline convert play info edit fuzzy replaygain mbsync fetchart embedart thumbnails
artist_credit: yes
original_date: yes
per_disc_numbering: yes
import:
timid: yes
item_fields:
disc_and_track: f'{disc:02}-{track:02}' if disctotal > 1 else f'{track:02}'
artist_and_title: f'{artist} - {title}' if artist != albumartist else title
original_date: "'-'.join(filter(None, (original_year and f'{original_year:04}',\n original_month and f'{original_month:02}',\n original_day and f'{original_day:02}')))\n"
paths:
default: $albumartist/$original_date $album%aunique{}/$disc_and_track $artist_and_title
match:
preferred:
countries: [US, GB|UK, JP]
media: [CD, Digital Media|File]
original_year: yes
musicbrainz:
searchlimit: 8
replaygain:
backend: gstreamer
overwrite: no
auto: yes
targetlevel: 89
r128: [Opus]
play:
command: mpv --replaygain=album $args --playlist
use_folders: no
relative_to:
raw: no
warning_threshold: 100
bom: no
embedart:
maxwidth: 0
auto: yes
compare_threshold: 0
ifempty: no
remove_art_file: no
fetchart:
auto: yes
minwidth: 0
maxwidth: 0
enforce_ratio: no
cautious: no
cover_names:
- cover
- front
- art
- album
- folder
sources:
- filesystem
- coverart
- itunes
- amazon
- albumart
google_key: REDACTED
google_engine: 001442825323518660753:hrh5ch1gjzm
fanarttv_key: REDACTED
store_source: no
pathfields: {}
album_fields: {}
fuzzy:
prefix: '~'
threshold: 0.7
thumbnails:
auto: yes
force: no
dolphin: no
edit:
albumfields: album albumartist
itemfields: track title artist album
ignore_fields: id path
convert:
dest:
pretend: no
threads: 4
format: mp3
id3v23: inherit
formats:
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
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
max_bitrate: 500
auto: no
tmpdir:
quiet: no
embed: yes
paths: {}
no_convert: ''
never_convert_lossy_files: no
copy_album_art: no
album_art_maxwidth: 0
Indeed; this definitely looks like a Python 3 regression. We will need to either use our py3_path utility or find some convenient way to avoid the use of pathlib. (This is not a very compelling reason to use pathlib in the first place, IMO.)
This appears to have been fixed as of July 2020 by #3360. I suggest this issue be closed.