Skip to content

Commit 0e6ba45

Browse files
authored
Fix Hybrid SACD importing (#5149)
Fixes #5148. When importing, the code that matches tracks does not consider the medium number. This causes problems on Hybrid SACDs (and other releases) where the artists, track numbers, titles, and lengths are the same on both layers. I added a distance penalty for mismatching medium numbers. Before: ``` $ beet imp . /Volumes/Music/ti/Red Garland/1958 - All Mornin' Long - 1 (6 items) Match (95.4%): The Red Garland Quintet - All Mornin' Long ≠ media, year MusicBrainz, 2xHybrid SACD (CD layer), 2013, US, Analogue Productions, CPRJ 7130 SA, mono https://musicbrainz.org/release/6a584522-58ea-470b-81fb-e60e5cd7b21e * Artist: The Red Garland Quintet * Album: All Mornin' Long * Hybrid SACD (CD layer) 1 ≠ (#2-1) All Mornin' Long (20:21) -> (#1-1) All Mornin' Long (20:21) ≠ (#2-2) They Can't Take That Away From Me (10:24) -> (#1-2) They Can't Take That Away From Me (10:27) ≠ (#2-3) Our Delight (6:23) -> (#1-3) Our Delight (6:23) * Hybrid SACD (CD layer) 2 ≠ (#1-1) All mornin' long (20:21) -> (#2-1) All Mornin' Long (20:21) ≠ (#1-2) They can't take that away from me (10:27) -> (#2-2) They Can't Take That Away From Me (10:25) ≠ (#1-3) Our delight (6:23) -> (#2-3) Our Delight (6:23) ➜ [A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums, Enter search, enter Id, aBort, eDit, edit Candidates? ``` Note that all tracks tagged with disc 1 get moved to disc 2 and vice versa. After: ``` $ beet-test imp . /Volumes/Music/ti/Red Garland/1958 - All Mornin' Long - 1 (6 items) Match (95.4%): The Red Garland Quintet - All Mornin' Long ≠ media, year MusicBrainz, 2xMedia, 2013, US, Analogue Productions, CPRJ 7130 SA, mono https://musicbrainz.org/release/6a584522-58ea-470b-81fb-e60e5cd7b21e * Artist: The Red Garland Quintet * Album: All Mornin' Long * Hybrid SACD (CD layer) 1 ≠ (#1-1) All mornin' long (20:21) -> (#1-1) All Mornin' Long (20:21) ≠ (#1-2) They can't take that away from me (10:27) -> (#1-2) They Can't Take That Away From Me (10:27) ≠ (#1-3) Our delight (6:23) -> (#1-3) Our Delight (6:23) * Hybrid SACD (SACD layer) 2 * (#2-1) All Mornin' Long (20:21) * (#2-2) They Can't Take That Away From Me (10:24) * (#2-3) Our Delight (6:23) ➜ [A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums, Enter search, enter Id, aBort, eDit, edit Candidates? ``` Yay!
2 parents ef328ed + 32e9e58 commit 0e6ba45

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

beets/autotag/match.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ def track_distance(
208208
if item.mb_trackid:
209209
dist.add_expr("track_id", item.mb_trackid != track_info.track_id)
210210

211+
# Penalize mismatching disc numbers.
212+
if track_info.medium and item.disc:
213+
dist.add_expr("medium", item.disc != track_info.medium)
214+
211215
# Plugins.
212216
dist.update(plugins.track_distance(item, track_info))
213217

beets/config_default.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ match:
207207
track_index: 1.0
208208
track_length: 2.0
209209
track_id: 5.0
210+
medium: 1.0
210211
preferred:
211212
countries: []
212213
media: []

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Bug fixes:
1717
* Check if running python from the Microsoft Store and provide feedback to install
1818
from python.org.
1919
:bug:`5467`
20+
* Fix bug where matcher doesn't consider medium number when importing. This makes
21+
it difficult to import hybrid SACDs and other releases with duplicate tracks.
22+
:bug:`5148`
2023

2124
For packagers:
2225

0 commit comments

Comments
 (0)