fixed up the featured artist thing
CI / check (push) Failing after 1m9s
CI / docker (push) Has been skipped

This commit is contained in:
Connor Johnstone
2026-03-24 11:38:08 -04:00
parent 314400bde5
commit 026d1f446b
10 changed files with 28 additions and 17 deletions
+1
View File
@@ -475,6 +475,7 @@ impl MetadataFetcher for LocalMusicBrainzFetcher {
secondary_types, secondary_types,
first_release_date: row.get(4)?, first_release_date: row.get(4)?,
first_release_mbid: row.get(5)?, first_release_mbid: row.get(5)?,
featured: false, // Local DB only stores primary-credit releases
}) })
}) })
.map_err(|e| DataError::Other(e.to_string()))? .map_err(|e| DataError::Other(e.to_string()))?
+9 -2
View File
@@ -345,7 +345,7 @@ impl MetadataFetcher for MusicBrainzFetcher {
) -> DataResult<Vec<ReleaseGroupEntry>> { ) -> DataResult<Vec<ReleaseGroupEntry>> {
// Fetch album, single, and EP release groups // Fetch album, single, and EP release groups
let url = format!( let url = format!(
"{BASE_URL}/release-group?artist={artist_mbid}&type=album|single|ep&fmt=json&limit=100" "{BASE_URL}/release-group?artist={artist_mbid}&type=album|single|ep&inc=artist-credits&fmt=json&limit=100"
); );
let resp: MbReleaseGroupResponse = self.get_json(&url).await?; let resp: MbReleaseGroupResponse = self.get_json(&url).await?;
@@ -353,7 +353,10 @@ impl MetadataFetcher for MusicBrainzFetcher {
.release_groups .release_groups
.unwrap_or_default() .unwrap_or_default()
.into_iter() .into_iter()
.map(|rg| ReleaseGroupEntry { .map(|rg| {
let primary = extract_artist_credit(&rg.artist_credit);
let featured = primary.1.as_deref() != Some(artist_mbid);
ReleaseGroupEntry {
mbid: rg.id, mbid: rg.id,
title: rg.title, title: rg.title,
primary_type: rg.primary_type, primary_type: rg.primary_type,
@@ -362,6 +365,8 @@ impl MetadataFetcher for MusicBrainzFetcher {
first_release_mbid: rg first_release_mbid: rg
.releases .releases
.and_then(|r| r.into_iter().next().map(|rel| rel.id)), .and_then(|r| r.into_iter().next().map(|rel| rel.id)),
featured,
}
}) })
.collect()) .collect())
} }
@@ -538,6 +543,8 @@ struct MbReleaseGroup {
#[serde(rename = "first-release-date")] #[serde(rename = "first-release-date")]
first_release_date: Option<String>, first_release_date: Option<String>,
releases: Option<Vec<MbReleaseGroupRelease>>, releases: Option<Vec<MbReleaseGroupRelease>>,
#[serde(rename = "artist-credit")]
artist_credit: Option<Vec<MbArtistCredit>>,
} }
#[derive(Deserialize)] #[derive(Deserialize)]
+3
View File
@@ -96,6 +96,9 @@ pub struct ReleaseGroupEntry {
pub first_release_date: Option<String>, pub first_release_date: Option<String>,
/// MBID of the first release in this group (for fetching tracks). /// MBID of the first release in this group (for fetching tracks).
pub first_release_mbid: Option<String>, pub first_release_mbid: Option<String>,
/// True if the queried artist is not the primary credit on this release group.
#[serde(default)]
pub featured: bool,
} }
/// A track within a release. /// A track within a release.