Skip to content

Commit 0820969

Browse files
committed
fix: prefer regular album editions over special/deluxe editions
1 parent 2fe7424 commit 0820969

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

lib/src/musicbrainz/compilation_provider.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,24 @@ pub fn is_compilation_release(release: &Release, release_group: Option<&ReleaseG
138138
}
139139
}
140140

141+
/// Check if a release title indicates a special edition (deluxe, remaster, etc.)
142+
fn is_special_edition(title: &str) -> bool {
143+
let lower = title.to_lowercase();
144+
lower.contains("deluxe")
145+
|| lower.contains("remaster")
146+
|| lower.contains("special")
147+
|| lower.contains("anniversary")
148+
|| lower.contains("expanded")
149+
|| lower.contains("collector")
150+
|| lower.contains("limited")
151+
|| lower.contains("super")
152+
|| lower.contains("bonus")
153+
}
154+
141155
/// Default release comparison function
142156
/// Prefers: Official > None > Promotion > Bootleg > PseudoRelease
143-
/// Then: Non-compilations over compilations, then Studio Albums > EPs > Singles > Broadcast > Unknown
157+
/// Then: Non-compilations over compilations, then regular editions over special editions,
158+
/// then Studio Albums > EPs > Singles > Broadcast > Unknown
144159
/// For same quality and status, prefers earlier releases
145160
pub fn default_release_comparer(
146161
a: &Release,
@@ -164,6 +179,16 @@ pub fn default_release_comparer(
164179
_ => {} // Both are compilations or both are non-compilations, continue comparing
165180
}
166181

182+
// Check if either is a special edition (prefer regular editions)
183+
let a_is_special = is_special_edition(&a.title);
184+
let b_is_special = is_special_edition(&b.title);
185+
186+
match (a_is_special, b_is_special) {
187+
(true, false) => return Ordering::Greater, // b is better (regular edition)
188+
(false, true) => return Ordering::Less, // a is better (regular edition)
189+
_ => {} // Both are special or both are regular, continue comparing
190+
}
191+
167192
// Check for significant date gaps between singles and albums
168193
let date_comparison = MusicBrainzClient::compare_release_dates(a, b);
169194
if let Some(gap_preference) = check_date_gap_preference(a, a_group, b, b_group) {

0 commit comments

Comments
 (0)