removed secondary artists
CI / check (push) Successful in 1m9s
CI / docker (push) Successful in 1m44s

This commit is contained in:
Connor Johnstone
2026-03-23 17:11:38 -04:00
parent 3708829c3b
commit 1861f086fa
5 changed files with 2 additions and 35 deletions
-29
View File
@@ -251,7 +251,6 @@ impl MetadataFetcher for MusicBrainzFetcher {
let r: MbRecordingDetail = self.get_json(&url).await?;
let (artist_name, artist_mbid) = extract_artist_credit(&r.artist_credit);
let secondary_artists = extract_secondary_artists(&r.artist_credit);
Ok(RecordingDetails {
mbid: r.id,
title: r.title,
@@ -275,7 +274,6 @@ impl MetadataFetcher for MusicBrainzFetcher {
.into_iter()
.map(|g| g.name)
.collect(),
secondary_artists,
})
}
@@ -388,32 +386,6 @@ fn extract_artist_credit(credits: &Option<Vec<MbArtistCredit>>) -> (String, Opti
}
}
/// Extract non-featuring secondary artists from MusicBrainz artist credits.
/// Returns (name, mbid) pairs for collaborators that aren't "featuring" credits.
fn extract_secondary_artists(credits: &Option<Vec<MbArtistCredit>>) -> Vec<(String, String)> {
let Some(credits) = credits else {
return vec![];
};
if credits.len() <= 1 {
return vec![];
}
// Walk credits after the first. Stop at any "feat"/"ft." joinphrase
// from the PREVIOUS credit (since joinphrase is on the credit BEFORE the next artist).
let mut result = Vec::new();
for i in 0..credits.len() - 1 {
let jp = credits[i].joinphrase.as_deref().unwrap_or("");
let lower = jp.to_lowercase();
if lower.contains("feat") || lower.contains("ft.") {
break;
}
// The next credit is a non-featuring collaborator
let next = &credits[i + 1];
result.push((next.artist.name.clone(), next.artist.id.clone()));
}
result
}
// --- MusicBrainz API response types ---
#[derive(Deserialize)]
@@ -513,7 +485,6 @@ struct MbRecordingDetail {
#[derive(Deserialize)]
struct MbArtistCredit {
artist: MbArtist,
joinphrase: Option<String>,
}
#[derive(Deserialize)]