From 1d1674e3a135cfc475f74fb57094d02ce061e3b9 Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Tue, 17 Mar 2026 21:38:47 -0400 Subject: [PATCH] Updates for the "full flow" --- src/indexer.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/indexer.rs b/src/indexer.rs index a148851..a78ee7c 100644 --- a/src/indexer.rs +++ b/src/indexer.rs @@ -32,11 +32,30 @@ async fn process_file( // Extract metadata (CPU-bound, run in blocking thread) let path = scanned.path.clone(); - let meta: MusicMetadata = tokio::task::spawn_blocking(move || { + let mut meta: MusicMetadata = tokio::task::spawn_blocking(move || { metadata::extract_metadata(&path) }) .await??; + // Fallback: if missing title or artist from tags, try parsing from filename ("Artist - Title.ext") + if meta.title.is_none() || meta.artist.is_none() { + if let Some(stem) = scanned.path.file_stem().and_then(|s| s.to_str()) { + if let Some((artist, title)) = stem.split_once(" - ") { + let artist = artist.trim(); + let title = title.trim(); + if !artist.is_empty() && !title.is_empty() { + tracing::debug!(path = %file_path_str, artist = artist, title = title, "parsed metadata from filename"); + if meta.artist.is_none() { + meta.artist = Some(artist.to_string()); + } + if meta.title.is_none() { + meta.title = Some(title.to_string()); + } + } + } + } + } + tracing::info!( path = %file_path_str, title = ?meta.title,