diff --git a/src-tauri/src/library/commands.rs b/src-tauri/src/library/commands.rs index 7bf4798a2..4d9a0ae6f 100644 --- a/src-tauri/src/library/commands.rs +++ b/src-tauri/src/library/commands.rs @@ -283,14 +283,13 @@ pub async fn library_get_albums( #[tauri::command] pub async fn library_get_album_tracks( - album: String, - artist: String, + album_group_key: String, state: State<'_, LibraryState>, ) -> Result, String> { - log::info!("Command: library_get_album_tracks {} - {}", artist, album); + log::info!("Command: library_get_album_tracks {}", album_group_key); let db = state.db.lock().await; - db.get_album_tracks(&album, &artist) + db.get_album_tracks(&album_group_key) .map_err(|e| e.to_string()) } @@ -651,7 +650,7 @@ pub async fn library_fetch_missing_artwork( let mut updated_count = 0u32; // Get all albums without artwork - let albums_without_artwork: Vec<(String, String)> = { + let albums_without_artwork: Vec<(String, String, String)> = { let db = state.db.lock().await; db.get_albums_without_artwork() .map_err(|e| e.to_string())? @@ -659,12 +658,12 @@ pub async fn library_fetch_missing_artwork( log::info!("Found {} albums without artwork", albums_without_artwork.len()); - for (artist, album) in albums_without_artwork { + for (group_key, album, artist) in albums_without_artwork { // Try to fetch from Discogs if let Some(artwork_path) = discogs.fetch_artwork(&artist, &album, &artwork_cache).await { // Update all tracks in this album with the artwork let db = state.db.lock().await; - if db.update_album_artwork(&album, &artist, &artwork_path).is_ok() { + if db.update_album_group_artwork(&group_key, &artwork_path).is_ok() { updated_count += 1; log::info!("Updated artwork for {} - {}", artist, album); } @@ -703,10 +702,17 @@ pub async fn library_fetch_album_artwork( let artwork_cache = get_artwork_cache_dir(); if let Some(artwork_path) = discogs.fetch_artwork(&artist, &album, &artwork_cache).await { - // Update all tracks in this album with the artwork let db = state.db.lock().await; - db.update_album_artwork(&album, &artist, &artwork_path) - .map_err(|e| e.to_string())?; + if let Some(group_key) = db + .find_album_group_key(&album, &artist) + .map_err(|e| e.to_string())? + { + db.update_album_group_artwork(&group_key, &artwork_path) + .map_err(|e| e.to_string())?; + } else { + db.update_album_artwork(&album, &artist, &artwork_path) + .map_err(|e| e.to_string())?; + } Ok(Some(artwork_path)) } else { Ok(None) diff --git a/src-tauri/src/library/cue_parser.rs b/src-tauri/src/library/cue_parser.rs index 467cd9826..2f789cfa6 100644 --- a/src-tauri/src/library/cue_parser.rs +++ b/src-tauri/src/library/cue_parser.rs @@ -3,7 +3,7 @@ use std::fs; use std::path::Path; -use crate::library::{AudioFormat, AudioProperties, LibraryError, LocalTrack}; +use crate::library::{AudioFormat, AudioProperties, LibraryError, LocalTrack, MetadataExtractor}; /// Parsed CUE sheet #[derive(Debug, Clone)] @@ -222,6 +222,9 @@ pub fn cue_to_tracks( .map(|d| d.as_secs() as i64) .unwrap_or(0); + let (album_group_key, album_group_title) = + MetadataExtractor::album_group_info(Path::new(&cue.audio_file), cue.title.as_deref()); + for (i, cue_track) in cue.tracks.iter().enumerate() { // Calculate end time (next track's start or audio end) let end_secs = if i + 1 < cue.tracks.len() { @@ -246,6 +249,8 @@ pub fn cue_to_tracks( .clone() .unwrap_or_else(|| "Unknown Album".to_string()), album_artist: cue.performer.clone(), + album_group_key: album_group_key.clone(), + album_group_title: album_group_title.clone(), track_number: Some(cue_track.number), disc_number: None, year: None, diff --git a/src-tauri/src/library/database.rs b/src-tauri/src/library/database.rs index 3bd4934a8..cb378b2e0 100644 --- a/src-tauri/src/library/database.rs +++ b/src-tauri/src/library/database.rs @@ -63,12 +63,15 @@ impl LibraryDatabase { artwork_path TEXT, last_modified INTEGER NOT NULL, indexed_at INTEGER NOT NULL, + album_group_key TEXT, + album_group_title TEXT, UNIQUE(file_path, cue_start_secs) ); CREATE INDEX IF NOT EXISTS idx_tracks_artist ON local_tracks(artist); CREATE INDEX IF NOT EXISTS idx_tracks_album ON local_tracks(album); CREATE INDEX IF NOT EXISTS idx_tracks_album_artist ON local_tracks(album_artist); + CREATE INDEX IF NOT EXISTS idx_tracks_album_group ON local_tracks(album_group_key); CREATE INDEX IF NOT EXISTS idx_tracks_file_path ON local_tracks(file_path); CREATE INDEX IF NOT EXISTS idx_tracks_title ON local_tracks(title); @@ -158,6 +161,40 @@ impl LibraryDatabase { ).map_err(|e| LibraryError::Database(format!("Migration failed: {}", e)))?; } + let has_album_group_key: bool = self + .conn + .query_row( + "SELECT COUNT(*) FROM pragma_table_info('local_tracks') WHERE name = 'album_group_key'", + [], + |row| row.get::<_, i32>(0), + ) + .map(|count| count > 0) + .unwrap_or(false); + + if !has_album_group_key { + log::info!("Running migration: adding album_group_key to local_tracks"); + self.conn + .execute_batch("ALTER TABLE local_tracks ADD COLUMN album_group_key TEXT;") + .map_err(|e| LibraryError::Database(format!("Migration failed: {}", e)))?; + } + + let has_album_group_title: bool = self + .conn + .query_row( + "SELECT COUNT(*) FROM pragma_table_info('local_tracks') WHERE name = 'album_group_title'", + [], + |row| row.get::<_, i32>(0), + ) + .map(|count| count > 0) + .unwrap_or(false); + + if !has_album_group_title { + log::info!("Running migration: adding album_group_title to local_tracks"); + self.conn + .execute_batch("ALTER TABLE local_tracks ADD COLUMN album_group_title TEXT;") + .map_err(|e| LibraryError::Database(format!("Migration failed: {}", e)))?; + } + Ok(()) } @@ -221,8 +258,9 @@ impl LibraryDatabase { (file_path, title, artist, album, album_artist, track_number, disc_number, year, genre, duration_secs, format, bit_depth, sample_rate, channels, file_size_bytes, cue_file_path, - cue_start_secs, cue_end_secs, artwork_path, last_modified, indexed_at) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"#, + cue_start_secs, cue_end_secs, artwork_path, last_modified, indexed_at, + album_group_key, album_group_title) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"#, params![ track.file_path, track.title, @@ -244,7 +282,9 @@ impl LibraryDatabase { track.cue_end_secs, track.artwork_path, track.last_modified, - track.indexed_at + track.indexed_at, + track.album_group_key, + track.album_group_title ], ) .map_err(|e| LibraryError::Database(e.to_string()))?; @@ -306,8 +346,12 @@ impl LibraryDatabase { .prepare( r#" SELECT - album, - COALESCE(album_artist, artist) as artist, + group_key, + MIN(title) as title, + CASE + WHEN COUNT(DISTINCT artist) > 1 THEN 'Various Artists' + ELSE MIN(artist) + END as artist, MIN(year) as year, MAX(artwork_path) as artwork, COUNT(*) as track_count, @@ -315,10 +359,22 @@ impl LibraryDatabase { MAX(format) as format, MAX(bit_depth) as bit_depth, MAX(sample_rate) as sample_rate, - MIN(file_path) as directory_path - FROM local_tracks - GROUP BY album, COALESCE(album_artist, artist) - ORDER BY artist, album + MAX(group_key) as directory_path + FROM ( + SELECT + COALESCE(album_group_key, album || '|' || COALESCE(album_artist, artist)) as group_key, + COALESCE(album_group_title, album) as title, + COALESCE(album_artist, artist) as artist, + year, + artwork_path, + duration_secs, + format, + bit_depth, + sample_rate + FROM local_tracks + ) + GROUP BY group_key + ORDER BY artist, title LIMIT ? OFFSET ? "#, ) @@ -326,22 +382,25 @@ impl LibraryDatabase { let rows = stmt .query_map(params![limit, offset], |row| { - let album: String = row.get(0)?; - let artist: String = row.get(1)?; + let group_key: String = row.get(0)?; + let album: String = row.get(1)?; + let artist: String = row.get(2)?; Ok(LocalAlbum { - id: format!("{}_{}", artist, album), + id: group_key.clone(), title: album, artist, - year: row.get(2)?, - artwork_path: row.get(3)?, - track_count: row.get(4)?, - total_duration_secs: row.get(5)?, + year: row.get(3)?, + artwork_path: row.get(4)?, + track_count: row.get(5)?, + total_duration_secs: row.get(6)?, format: Self::parse_format( - &row.get::<_, Option>(6)?.unwrap_or_default(), + &row.get::<_, Option>(7)?.unwrap_or_default(), ), - bit_depth: row.get(7)?, - sample_rate: row.get::<_, Option>(8)?.unwrap_or(44100), - directory_path: row.get::<_, String>(9).unwrap_or_default(), + bit_depth: row.get(8)?, + sample_rate: row.get::<_, Option>(9)?.unwrap_or(44100), + directory_path: row + .get::<_, Option>(10)? + .unwrap_or_else(|| group_key.clone()), }) }) .map_err(|e| LibraryError::Database(e.to_string()))?; @@ -353,25 +412,21 @@ impl LibraryDatabase { Ok(albums) } - /// Get tracks for an album - pub fn get_album_tracks( - &self, - album: &str, - artist: &str, - ) -> Result, LibraryError> { + /// Get tracks for an album group + pub fn get_album_tracks(&self, group_key: &str) -> Result, LibraryError> { let mut stmt = self .conn .prepare( r#" SELECT * FROM local_tracks - WHERE album = ? AND COALESCE(album_artist, artist) = ? + WHERE COALESCE(album_group_key, album || '|' || COALESCE(album_artist, artist)) = ? ORDER BY disc_number, track_number, title "#, ) .map_err(|e| LibraryError::Database(e.to_string()))?; let rows = stmt - .query_map(params![album, artist], |row| Self::row_to_track(row)) + .query_map(params![group_key], |row| Self::row_to_track(row)) .map_err(|e| LibraryError::Database(e.to_string()))?; let mut tracks = Vec::new(); @@ -389,7 +444,7 @@ impl LibraryDatabase { r#" SELECT COALESCE(album_artist, artist) as name, - COUNT(DISTINCT album) as album_count, + COUNT(DISTINCT COALESCE(album_group_key, album || '|' || COALESCE(album_artist, artist))) as album_count, COUNT(*) as track_count FROM local_tracks GROUP BY name @@ -415,25 +470,43 @@ impl LibraryDatabase { Ok(artists) } - /// Get albums without artwork (for Discogs fetching) - pub fn get_albums_without_artwork(&self) -> Result, LibraryError> { + /// Get album groups without artwork (for Discogs fetching) + pub fn get_albums_without_artwork( + &self, + ) -> Result, LibraryError> { let mut stmt = self .conn .prepare( r#" - SELECT DISTINCT - COALESCE(album_artist, artist) as artist, - album - FROM local_tracks - WHERE artwork_path IS NULL OR artwork_path = '' - ORDER BY artist, album + SELECT + group_key, + MIN(title) as title, + CASE + WHEN COUNT(DISTINCT artist) > 1 THEN 'Various Artists' + ELSE MIN(artist) + END as artist + FROM ( + SELECT + COALESCE(album_group_key, album || '|' || COALESCE(album_artist, artist)) as group_key, + COALESCE(album_group_title, album) as title, + COALESCE(album_artist, artist) as artist, + artwork_path + FROM local_tracks + WHERE artwork_path IS NULL OR artwork_path = '' + ) + GROUP BY group_key + ORDER BY artist, title "#, ) .map_err(|e| LibraryError::Database(e.to_string()))?; let rows = stmt .query_map([], |row| { - Ok((row.get::<_, String>(0)?, row.get::<_, String>(1)?)) + Ok(( + row.get::<_, String>(0)?, + row.get::<_, String>(1)?, + row.get::<_, String>(2)?, + )) }) .map_err(|e| LibraryError::Database(e.to_string()))?; @@ -464,6 +537,45 @@ impl LibraryDatabase { Ok(()) } + /// Update artwork path for all tracks in an album group + pub fn update_album_group_artwork( + &self, + group_key: &str, + artwork_path: &str, + ) -> Result<(), LibraryError> { + self.conn + .execute( + r#" + UPDATE local_tracks + SET artwork_path = ? + WHERE COALESCE(album_group_key, album || '|' || COALESCE(album_artist, artist)) = ? + "#, + params![artwork_path, group_key], + ) + .map_err(|e| LibraryError::Database(e.to_string()))?; + Ok(()) + } + + pub fn find_album_group_key( + &self, + album: &str, + artist: &str, + ) -> Result, LibraryError> { + self.conn + .query_row( + r#" + SELECT COALESCE(album_group_key, album || '|' || COALESCE(album_artist, artist)) + FROM local_tracks + WHERE album = ? AND COALESCE(album_artist, artist) = ? + LIMIT 1 + "#, + params![album, artist], + |row| row.get(0), + ) + .optional() + .map_err(|e| LibraryError::Database(e.to_string())) + } + /// Search tracks by title, artist, or album pub fn search(&self, query: &str, limit: u32) -> Result, LibraryError> { let pattern = format!("%{}%", query); @@ -499,7 +611,7 @@ impl LibraryDatabase { r#" SELECT COUNT(*) as track_count, - COUNT(DISTINCT album || COALESCE(album_artist, artist)) as album_count, + COUNT(DISTINCT COALESCE(album_group_key, album || '|' || COALESCE(album_artist, artist))) as album_count, COUNT(DISTINCT COALESCE(album_artist, artist)) as artist_count, COALESCE(SUM(duration_secs), 0) as total_duration, COALESCE(SUM(file_size_bytes), 0) as total_size @@ -531,6 +643,8 @@ impl LibraryDatabase { artist: row.get(3)?, album: row.get(4)?, album_artist: row.get(5)?, + album_group_key: row.get::<_, Option>(22)?.unwrap_or_default(), + album_group_title: row.get::<_, Option>(23)?.unwrap_or_default(), track_number: row.get(6)?, disc_number: row.get(7)?, year: row.get(8)?, @@ -1012,10 +1126,10 @@ impl LibraryDatabase { pub fn get_playlist_local_tracks(&self, qobuz_playlist_id: u64) -> Result, LibraryError> { let mut stmt = self.conn.prepare( "SELECT t.id, t.file_path, t.title, t.artist, t.album, t.album_artist, - t.track_number, t.disc_number, t.year, t.genre, t.duration_secs, - t.format, t.bit_depth, t.sample_rate, t.channels, t.file_size_bytes, - t.cue_file_path, t.cue_start_secs, t.cue_end_secs, t.artwork_path, - t.last_modified, t.indexed_at, plt.position + t.album_group_key, t.album_group_title, t.track_number, t.disc_number, + t.year, t.genre, t.duration_secs, t.format, t.bit_depth, t.sample_rate, + t.channels, t.file_size_bytes, t.cue_file_path, t.cue_start_secs, + t.cue_end_secs, t.artwork_path, t.last_modified, t.indexed_at, plt.position FROM playlist_local_tracks plt JOIN local_tracks t ON plt.local_track_id = t.id WHERE plt.qobuz_playlist_id = ?1 @@ -1030,22 +1144,24 @@ impl LibraryDatabase { artist: row.get(3)?, album: row.get(4)?, album_artist: row.get(5)?, - track_number: row.get(6)?, - disc_number: row.get(7)?, - year: row.get(8)?, - genre: row.get(9)?, - duration_secs: row.get(10)?, - format: Self::parse_format(&row.get::<_, String>(11)?), - bit_depth: row.get(12)?, - sample_rate: row.get(13)?, - channels: row.get(14)?, - file_size_bytes: row.get(15)?, - cue_file_path: row.get(16)?, - cue_start_secs: row.get(17)?, - cue_end_secs: row.get(18)?, - artwork_path: row.get(19)?, - last_modified: row.get(20)?, - indexed_at: row.get(21)?, + album_group_key: row.get::<_, Option>(6)?.unwrap_or_default(), + album_group_title: row.get::<_, Option>(7)?.unwrap_or_default(), + track_number: row.get(8)?, + disc_number: row.get(9)?, + year: row.get(10)?, + genre: row.get(11)?, + duration_secs: row.get(12)?, + format: Self::parse_format(&row.get::<_, String>(13)?), + bit_depth: row.get(14)?, + sample_rate: row.get(15)?, + channels: row.get(16)?, + file_size_bytes: row.get(17)?, + cue_file_path: row.get(18)?, + cue_start_secs: row.get(19)?, + cue_end_secs: row.get(20)?, + artwork_path: row.get(21)?, + last_modified: row.get(22)?, + indexed_at: row.get(23)?, }) }).map_err(|e| LibraryError::Database(format!("Failed to query playlist local tracks: {}", e)))?; diff --git a/src-tauri/src/library/metadata.rs b/src-tauri/src/library/metadata.rs index ed2d30f0c..f54470925 100644 --- a/src-tauri/src/library/metadata.rs +++ b/src-tauri/src/library/metadata.rs @@ -33,6 +33,71 @@ impl MetadataExtractor { trimmed.to_string() } + fn strip_disc_suffix(title: &str) -> String { + let trimmed = title.trim(); + + for (open, close) in [("(", ")"), ("[", "]")] { + if trimmed.ends_with(close) { + if let Some(start) = trimmed.rfind(open) { + let inside = trimmed[start + 1..trimmed.len() - 1].trim(); + if Self::is_disc_designator(inside) { + return trimmed[..start].trim().to_string(); + } + } + } + } + + let tokens: Vec<&str> = trimmed + .split_whitespace() + .filter(|token| *token != "-" && *token != "–" && *token != "—") + .collect(); + + if tokens.len() >= 2 { + let last = tokens[tokens.len() - 1]; + let prev = tokens[tokens.len() - 2]; + if Self::is_disc_marker(prev) && last.chars().all(|c| c.is_ascii_digit()) { + return tokens[..tokens.len() - 2].join(" ").trim().to_string(); + } + } + + if let Some(last) = tokens.last() { + if Self::is_disc_designator(last) { + if tokens.len() > 1 { + return tokens[..tokens.len() - 1].join(" ").trim().to_string(); + } + } + } + + trimmed.to_string() + } + + fn is_disc_marker(value: &str) -> bool { + matches!(value.to_lowercase().as_str(), "disc" | "disk" | "cd") + } + + fn is_disc_designator(value: &str) -> bool { + let cleaned: String = value + .to_lowercase() + .chars() + .filter(|c| c.is_ascii_alphanumeric()) + .collect(); + + if cleaned.starts_with("disc") { + let rest = &cleaned[4..]; + return !rest.is_empty() && rest.chars().all(|c| c.is_ascii_digit()); + } + if cleaned.starts_with("disk") { + let rest = &cleaned[4..]; + return !rest.is_empty() && rest.chars().all(|c| c.is_ascii_digit()); + } + if cleaned.starts_with("cd") { + let rest = &cleaned[2..]; + return !rest.is_empty() && rest.chars().all(|c| c.is_ascii_digit()); + } + + false + } + fn is_disc_folder(name: &str) -> bool { let lower = name.to_lowercase(); let tokens: Vec<&str> = lower @@ -71,26 +136,29 @@ impl MetadataExtractor { false } - fn infer_artist_album(file_path: &Path) -> (Option, Option) { - let parent_dir = file_path.parent(); - let parent_name = parent_dir.and_then(|p| p.file_name()).and_then(|s| s.to_str()); + fn album_root_dir(file_path: &Path) -> Option { + let parent_dir = file_path.parent()?; + let parent_name = parent_dir.file_name().and_then(|s| s.to_str()); - let (album_dir, album_name) = if let Some(name) = parent_name { + if let Some(name) = parent_name { if Self::is_disc_folder(name) { - let album_dir = parent_dir.and_then(|p| p.parent()); - let album_name = album_dir - .and_then(|p| p.file_name()) - .and_then(|s| s.to_str()) - .map(Self::strip_year_suffix); - (album_dir, album_name) - } else { - (parent_dir, parent_name.map(Self::strip_year_suffix)) + return parent_dir.parent().map(|p| p.to_path_buf()); } - } else { - (None, None) - }; + } + + Some(parent_dir.to_path_buf()) + } + + fn infer_artist_album(file_path: &Path) -> (Option, Option) { + let album_dir = Self::album_root_dir(file_path); + let album_name = album_dir + .as_ref() + .and_then(|p| p.file_name()) + .and_then(|s| s.to_str()) + .map(Self::strip_year_suffix); let artist_name = album_dir + .as_ref() .and_then(|p| p.parent()) .and_then(|p| p.file_name()) .and_then(|s| s.to_str()) @@ -110,6 +178,32 @@ impl MetadataExtractor { (artist_name, album_name) } + pub fn album_group_info(file_path: &Path, tag_album: Option<&str>) -> (String, String) { + let album_dir = Self::album_root_dir(file_path); + let group_key = album_dir + .as_ref() + .map(|dir| dir.to_string_lossy().to_string()) + .unwrap_or_else(|| file_path.to_string_lossy().to_string()); + + let mut group_title = tag_album + .map(|value| value.trim()) + .filter(|value| !value.is_empty()) + .filter(|value| !value.eq_ignore_ascii_case("Unknown Album")) + .map(|value| value.to_string()) + .or_else(|| { + album_dir + .as_ref() + .and_then(|dir| dir.file_name()) + .and_then(|s| s.to_str()) + .map(Self::strip_year_suffix) + }) + .unwrap_or_else(|| "Unknown Album".to_string()); + + group_title = Self::strip_disc_suffix(&group_title); + + (group_key, group_title) + } + /// Extract metadata from an audio file pub fn extract(file_path: &Path) -> Result { log::debug!("Extracting metadata from: {}", file_path.display()); @@ -154,6 +248,12 @@ impl MetadataExtractor { // Build track let track = if let Some(tag) = tag { + let album_title = Self::normalize_field(tag.album().as_deref()) + .or_else(|| fallback_album.clone()) + .unwrap_or_else(|| "Unknown Album".to_string()); + let (album_group_key, album_group_title) = + Self::album_group_info(file_path, Some(album_title.as_str())); + LocalTrack { id: 0, file_path: file_path.to_string_lossy().to_string(), @@ -164,10 +264,10 @@ impl MetadataExtractor { artist: Self::normalize_field(tag.artist().as_deref()) .or_else(|| fallback_artist.clone()) .unwrap_or_else(|| "Unknown Artist".to_string()), - album: Self::normalize_field(tag.album().as_deref()) - .or_else(|| fallback_album.clone()) - .unwrap_or_else(|| "Unknown Album".to_string()), + album: album_title, album_artist: tag.get_string(&ItemKey::AlbumArtist).map(|s| s.to_string()), + album_group_key, + album_group_title, track_number: tag.track().map(|t| t as u32), disc_number: tag.disk().map(|d| d as u32), year: tag.year().map(|y| y as u32), @@ -190,15 +290,22 @@ impl MetadataExtractor { } } else { // No tag found, use defaults + let album_title = fallback_album + .clone() + .unwrap_or_else(|| "Unknown Album".to_string()); + let (album_group_key, album_group_title) = + Self::album_group_info(file_path, Some(album_title.as_str())); + LocalTrack { id: 0, file_path: file_path.to_string_lossy().to_string(), title: filename, artist: fallback_artist .unwrap_or_else(|| "Unknown Artist".to_string()), - album: fallback_album - .unwrap_or_else(|| "Unknown Album".to_string()), + album: album_title, album_artist: None, + album_group_key, + album_group_title, track_number: None, disc_number: None, year: None, diff --git a/src-tauri/src/library/models.rs b/src-tauri/src/library/models.rs index 35a67ccd9..c9396bbeb 100644 --- a/src-tauri/src/library/models.rs +++ b/src-tauri/src/library/models.rs @@ -43,6 +43,8 @@ pub struct LocalTrack { pub artist: String, pub album: String, pub album_artist: Option, + pub album_group_key: String, + pub album_group_title: String, pub track_number: Option, pub disc_number: Option, pub year: Option, @@ -78,6 +80,8 @@ impl Default for LocalTrack { artist: "Unknown Artist".to_string(), album: "Unknown Album".to_string(), album_artist: None, + album_group_key: String::new(), + album_group_title: String::new(), track_number: None, disc_number: None, year: None,