Compare commits
1 Commits
884acfcd18
...
1d1674e3a1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d1674e3a1 |
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user