beetbox / beets

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

Avoid duplicates on unmatched tracks #5228

Open laker-93 opened 1 month ago

laker-93 commented 1 month ago

If importing un matched music that has no musicbrainz link 'as is' then beets will not be able to identify duplicates.

For example, if I import a track that is not on music brainz I use the following flow

  1. import album 'as is'

If I follow this process again (e.g. import a second time and follow the above steps) then I end up with a duplicate track. Even the duplicates plugin does not detect this track as a duplicate.

Is there any way to configure beets to detect such duplicates? It should realise it has the same meta data for the track in the db surely? Same tags for artist, track, album etc.

For example, first import:

root@8f870a3c9e0e:/# beet import /downloads/

/downloads (1 items)
Finding tags for album "Laker - Noise From The Ruliad".
Candidates:
1. Laker - See The Stars Laker Mix 1 (64.3%) (album, tracks) (2023, XW)
2. Laker - If everything changed I know that you still feel the same (57.1%) (album, tracks) (Digital Media, 2023, XW)
3. Laker - Never Love Again (53.4%) (album, tracks, year) (Digital Media, 2022, XW)
4. Laker - Kyoto (51.9%) (album, tracks) (2023, XW)
5. Laker - Lets Go (Percs In The Bathroom) (51.4%) (album, tracks, year) (Digital Media, 2022, XW)
# selection (default 1), Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? U

shows single track in collection:

root@8f870a3c9e0e:/# beet ls -p
/music/Laker/Noise From The Ruliad/01 - Escape.mp3

If I then import again:

root@8f870a3c9e0e:/# beet import /downloads/

/downloads (1 items)
Finding tags for album "Laker - Noise From The Ruliad".
Candidates:
1. Laker - See The Stars Laker Mix 1 (64.3%) (album, tracks) (2023, XW)
2. Laker - If everything changed I know that you still feel the same (57.1%) (album, tracks) (Digital Media, 2023, XW)
3. Laker - Never Love Again (53.4%) (album, tracks, year) (Digital Media, 2022, XW)
4. Laker - Kyoto (51.9%) (album, tracks) (2023, XW)
5. Laker - Lets Go (Percs In The Bathroom) (51.4%) (album, tracks, year) (Digital Media, 2022, XW)
# selection (default 1), Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? U

/downloads
/music/Laker/Noise From The Ruliad/01 - Escape.mp3 (2 items)
Finding tags for album "Laker - Noise From The Ruliad".
Candidates:
1. Laker - See The Stars Laker Mix 1 (60.3%) (album, tracks, unmatched tracks) (2023, XW)
2. Laker - If everything changed I know that you still feel the same (53.5%) (album, tracks, unmatched tracks) (Digital Media, 2023, XW)
3. Laker - Louboutins Balmain Freestyle (51.1%) (album, tracks, unmatched tracks) (2023, XW)
4. Laker - Lets Go (Percs In The Bathroom) (48.2%) (album, tracks, unmatched tracks, ...) (Digital Media, 2022, XW)
5. Laker - JUST*F0R&FUN::) (46.7%) (album, tracks, unmatched tracks, ...) (2022, XW)
# selection (default 1), Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort? U

I then end up with a duplicate:

root@8f870a3c9e0e:/# beet ls -p
/music/Laker/Noise From The Ruliad/01 - Escape.1.mp3
/music/Laker/Noise From The Ruliad/01 - Escape.mp3

Clearly beets knows this is a duplicate somewhere as it has had to add the ‘.1’ extension to the track. Is there a config option to tell beets to merge the duplicate instead? I have the duplicate merge action set in my config. Perhaps this doesn’t work with tracks that aren’t matched against musicbrainz?

The issue is similar to this: https://discourse.beets.io/t/deleting-duplicate-songs-on-import/1224 however I'm looking for a solution that works for tracks that don't match against an entry in musicbrainz.

jackwilsdon commented 1 month ago

The duplicates plugin allows you to configure which keys to use when detecting duplicates. By default it's mb_trackid and mb_albumid, which won't be set for tracks which were not tagged by MusicBrainz. You could try changing this to title and album which would only match duplicates with the same title and album:

duplicates:
  keys:
    - title
    - album
laker-93 commented 1 month ago

Thank for the information @jackwilsdon. Do you know if it' possible to specify multiple keys? E.g. use mb_trackid and mb_albumid but if not set use title and album?