Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merging albums with --set fields overwrites whole album #5077

Open
niacdoial opened this issue Jan 11, 2024 · 3 comments
Open

merging albums with --set fields overwrites whole album #5077

niacdoial opened this issue Jan 11, 2024 · 3 comments

Comments

@niacdoial
Copy link

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
@arsaboo
Copy link
Contributor

arsaboo commented Jan 11, 2024

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.

@niacdoial
Copy link
Author

niacdoial commented Jan 11, 2024 via email

@arsaboo
Copy link
Contributor

arsaboo commented Jan 12, 2024

Yes, that would work if you were not merging albums. When you merge, the merged album is used to the set operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants