beets
beets copied to clipboard
merging albums with --set fields overwrites whole album
Problem
when importing a track with:
- for instance --set=title=whatever
- then making so we hit the "this album is already in the library" dialog and choosing merge
the --set=title=whatever flag ends up affecting all existing tracks in the album as well.
fairly long, self-contained MWE:
#!/usr/bin/env bash
set -eux
basedir=$(mktemp -d)
# create a standalone config
cat > $basedir/conf.yaml <<EOF
plugins: edit
library: $basedir/library.beets-db
directory: $basedir/
import:
duplicate_keys:
album: "albumartist album"
edit:
itemfields: "track title artist album albumartist"
EOF
# minimal wav file, exact contents unimportant
python3 -c 'import sys; sys.stdout.buffer.write(b"RIFF%\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00)#\x00\x00)#\x00\x00\x01\x00\x08\x00data\x01\x00\x00\x00\x00")' > $basedir/src.wav
# set the "file editor" to a script that sets the "album" and "albumartist" fields
export EDITOR="sed -E -i 's/album:.*\$/album: album/;s/albumartist:.*\$/albumartist: artist/'"
# import 'full album'
# eDit, Accept
beet -c $basedir/conf.yaml imp --set=title=title1 $basedir/src.wav <<EOF
d
a
EOF
# import the new file
# eDit, Accept, Merge albums, Use album as-is
beet -c $basedir/conf.yaml imp --set=title=title2 $basedir/src.wav <<EOF
d
a
m
u
EOF
beet -c $basedir/conf.yaml ls
#this yelds two tracks with "title2" as their title
Setup
- OS: Nixos 23.11
- Python version: 3.11.6
- beets version: 1.6.0
- Turning off plugins made problem go away (yes/no): untested, the MWE uses only the edit plugin
Isn't that the expected behavior? When you merge, the new tracks and the old tracks are combined into one album and the set title will affect all the tracks in the new album object.
If that's the intended behavior, it's really surprising. I thought it would make more sense for "beet imp --set=field=value" to only affect the tracks that are actually imported to the library.
Yes, that would work if you were not merging albums. When you merge, the merged album is used to the set
operation.