From ed16ebc19e6fd306d1e9c718d5fe2d261279458d Mon Sep 17 00:00:00 2001 From: kevin9327 <5299031+kevin9327@users.noreply.github.com> Date: Sun, 20 Sep 2026 20:13:09 +0900 Subject: [PATCH] fix(local): drop a leading track number from an untagged filename --- CHANGELOG.md | 2 ++ crates/music/src/local/wire.rs | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1453526e..19e404a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). tracks it queued, instead of keeping a pause button over its cover. - Lyrics timed with hours, such as `[01:02:03.00]`, show at the right moment instead of being skipped. +- An untagged song named like `01. Title` keeps the title and drops the track number, instead + of using the whole filename. - Deezer playlists and favorites show the day they were added or last changed, instead of leaving the date column blank. - A Deezer song whose explicit flag arrives as a number still shows the explicit mark. diff --git a/crates/music/src/local/wire.rs b/crates/music/src/local/wire.rs index f770a5b2..8e19eb6d 100644 --- a/crates/music/src/local/wire.rs +++ b/crates/music/src/local/wire.rs @@ -180,7 +180,18 @@ fn infer_from_stem(stem: &str) -> (Option, Option) { return (Some(left.to_owned()), Some(right.to_owned())); } } - (None, None) + numbered(stem) + .map(|title| (Some(title), None)) + .unwrap_or((None, None)) +} + +fn numbered(stem: &str) -> Option { + let (digits, rest) = stem.split_once('.')?; + if digits.is_empty() || digits.len() > 3 || !digits.chars().all(|c| c.is_ascii_digit()) { + return None; + } + let rest = rest.trim(); + (!rest.is_empty()).then(|| rest.to_owned()) } struct FallbackProbe {