From 3eb106493f2204aa1c97b83b0f137e9c824f9e7b Mon Sep 17 00:00:00 2001 From: vicrodh Date: Mon, 9 Mar 2026 12:07:17 -0600 Subject: [PATCH] feat: add v2_musicbrainz_get_artist_metadata command Exposes artist location, life span, and affinity seeds to the frontend. Caches results for 30 days. Reuses the existing get_artist_with_relations API call, extracting area fields that were previously ignored. --- src-tauri/src/commands_v2.rs | 36 ++++++++++++++++++++++++++++++++++++ src-tauri/src/lib.rs | 1 + 2 files changed, 37 insertions(+) diff --git a/src-tauri/src/commands_v2.rs b/src-tauri/src/commands_v2.rs index 812368ed1..112b321b7 100644 --- a/src-tauri/src/commands_v2.rs +++ b/src-tauri/src/commands_v2.rs @@ -8761,6 +8761,42 @@ pub async fn v2_musicbrainz_get_artist_relationships( Ok(result) } +/// Get artist metadata (location, genres, life span) from MusicBrainz (V2) +/// +/// Returns location data (city/country), formatted date, and affinity seeds. +/// Used by the ArtistNetwork sidebar and scene discovery feature. +#[tauri::command] +pub async fn v2_musicbrainz_get_artist_metadata( + mbid: String, + state: State<'_, MusicBrainzSharedState>, +) -> Result { + // Check cache first + { + let cache_opt = state.cache.lock().await; + if let Some(cache) = cache_opt.as_ref() { + if let Some(cached) = cache.get_artist_metadata(&mbid)? { + return Ok(cached); + } + } + } + + // Fetch from MB API (reuses the same endpoint as relationships) + let artist = state.client.get_artist_with_relations(&mbid).await?; + + // Extract metadata using the location discovery module + let metadata = crate::musicbrainz::location_discovery::extract_metadata(&artist); + + // Cache result + { + let cache_opt = state.cache.lock().await; + if let Some(cache) = cache_opt.as_ref() { + let _ = cache.set_artist_metadata(&mbid, &metadata); + } + } + + Ok(metadata) +} + // --- Last.fm V2 --- /// Get Last.fm auth token and URL (V2) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 97a94526d..7ad02919b 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1540,6 +1540,7 @@ pub fn run() { commands_v2::v2_remote_metadata_search, commands_v2::v2_remote_metadata_get_album, commands_v2::v2_musicbrainz_get_artist_relationships, + commands_v2::v2_musicbrainz_get_artist_metadata, commands_v2::v2_get_discovery_artists, commands_v2::v2_dismiss_discovery_artist, commands_v2::v2_lastfm_get_auth_url,