fix: add exemptions for contractions when formatting song names

This commit is contained in:
Tal 2024-09-28 00:50:44 +02:00
parent 3de4bbfdde
commit 4ee86ec4f2
5 changed files with 16 additions and 5 deletions

2
Cargo.lock generated
View File

@ -982,7 +982,7 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "lowfi"
version = "1.0.0"
version = "1.0.1"
dependencies = [
"Inflector",
"arc-swap",

View File

@ -1,6 +1,6 @@
[package]
name = "lowfi"
version = "1.0.0"
version = "1.0.1"
edition = "2021"
description = "An extremely simple lofi player."
license = "MIT"

View File

@ -147,6 +147,10 @@ impl Player {
match msg {
Messages::Next | Messages::Init => {
// Skip as early as possible so that music doesn't play
// while lowfi is "loading".
queue.sink.stop();
// Serves as an indicator that the queue is "loading".
// This is also set by Player::next.
queue.current.store(None);
@ -155,7 +159,6 @@ impl Player {
// in the buffer.
itx.send(()).await?;
queue.sink.stop();
let track = Self::next(Arc::clone(&queue)).await?;
queue.sink.append(track.data);
}

View File

@ -126,7 +126,7 @@ async fn interface(queue: Arc<Player>) -> eyre::Result<()> {
MoveUp(4)
)?;
sleep(Duration::from_secs_f32(1.0 / 60.0)).await;
sleep(Duration::from_secs_f32(10.0 / 60.0)).await;
}
}

View File

@ -57,7 +57,15 @@ impl TrackInfo {
.unwrap()
.strip_suffix(".mp3")
.unwrap()
.to_title_case();
.to_title_case()
// Inflector doesn't like contractions...
// Replaces a few very common ones.
// TODO: Properly handle these.
.replace(" S ", "'s ")
.replace(" T ", "'t ")
.replace(" D ", "'d ")
.replace(" Ve ", "'ve ")
.replace(" M ", "'m ");
let mut skip = 0;