working songs but needs better edge case handling

This commit is contained in:
Chris Cochrun 2024-12-06 10:32:07 -06:00
parent b81584a76b
commit 6779b0c77c
2 changed files with 127 additions and 63 deletions

View file

@ -241,21 +241,16 @@ fn lisp_to_song(list: Vec<Value>) -> Song {
let mut lyrics = vec![];
if let Some(ref verse_order) = verse_order {
for verse in verse_order {
for element in lyric_elements {
let Value::List(lyric) = element else {
continue;
};
let Value::Symbol(Symbol(lyric_verse)) = &lyric[0]
else {
let Value::Symbol(Symbol(lyric_verse)) = &lyric[0] else {
continue;
};
let lyric = String::from(&lyric[1]);
println!("{lyric}");
let verse_title = match lyric_verse.as_str() {
"i1" => r#"\n\nIntro 1\n"#,
"i2" => r#"\n\nIntro 1\n"#,
@ -278,27 +273,17 @@ fn lisp_to_song(list: Vec<Value>) -> Song {
};
let lyric = format!("{verse_title}{lyric}");
println!("{lyric}");
if &lyric_verse.to_uppercase() == verse {
println!("lyric_final: {lyric}");
let lyric = lyric.replace(
"\\n", r#"
"#,
);
lyrics.push(lyric);
}
}
}
} else {
for element in lyric_elements {
let Value::List(lyric) = element else {
continue;
};
let lyric =
format!("{}{}", String::from(&lyric[1]), "\n");
lyrics.push(lyric);
}
}
let lyrics: String =
lyrics.iter().flat_map(|s| s.chars()).collect();
let lyrics = lyrics.replace(r#"\"#, "\\");
let lyrics = lyrics.trim_start_matches("\\n\\n").to_string();
let lyrics = lyrics.trim_start().to_string();
Song {
id,
@ -605,10 +590,10 @@ You saved my soul"
#[test]
pub fn test_lisp_conversion() {
let value = test_lisp_song();
let song = Song::from(value);
let lisp_song = Song::from(value);
let test_song = test_song();
println!("{}", test_song.lyrics.clone().unwrap());
println!("{}", song.lyrics.clone().unwrap());
assert_eq!(test_song, song);
println!("test_song: {}", test_song.lyrics.clone().unwrap());
println!("lisp_song: {}", lisp_song.lyrics.clone().unwrap());
assert_eq!(test_song, lisp_song);
}
}

View file

@ -6,11 +6,90 @@
:audio "file:///home/chris/music/North Point InsideOut/Nothing Ordinary, Pt. 1 (Live)/05 Death Was Arrested (feat. Seth Condrey).mp3"
:verse-order (i1 v1 v2 c1 v3 c1 v4 c1 b1 b1 e1 e2)
(i1 "Death Was Arrested\nNorth Point Worship")
(c1 "Oh, Your grace so free,\nWashes over me\n\nYou have made me new,\nNow life begins with You\n\nIt's Your endless love,\nPouring down on us\n\nYou have made us new,\nNow life begins with You")
(b1 "Oh, we're free, free,\nForever we're free\n\nCome join the song\nOf all the redeemed\n\nYes, we're free, free,\nForever amen\n\nWhen death was arrested\nAnd my life began\n\nOh, we're free, free,\nForever we're free\n\nCome join the song\nOf all the redeemed\n\nYes, we're free, free,\nForever amen\n\nWhen death was arrested\nAnd my life began")
(e1 "When death was arrested\nAnd my life began\n\nThat's when death was arrested\nAnd my life began")
(e2 "")
(v1 "Alone in my sorrow\nAnd dead in my sin\n\nLost without hope\nWith no place to begin\n\nYour love made a way\nTo let mercy come in\n\nWhen death was arrested\nAnd my life began")
(v2 "Ash was redeemed\nOnly beauty remains\n\nMy orphan heart\nWas given a name\n\nMy mourning grew quiet,\nMy feet rose to dance\n\nWhen death was arrested\nAnd my life began")
(v3 "Released from my chains,\nI'm a prisoner no more\n\nMy shame was a ransom\nHe faithfully bore\n\nHe cancelled my debt and\nHe called me His friend\n\nWhen death was arrested\nAnd my life began")
(v4 "Our Savior displayed\nOn a criminal's cross\n\nDarkness rejoiced as though\nHeaven had lost\n\nBut then Jesus arose\nWith our freedom in hand\n\nThat's when death was arrested\nAnd my life began\n\nThat's when death was arrested\nAnd my life began"))
(v1 "Alone in my sorrow
And dead in my sin
Lost without hope
With no place to begin
Your love made a way
To let mercy come in
When death was arrested
And my life began")
(v2 "Ash was redeemed
Only beauty remains
My orphan heart
Was given a name
My mourning grew quiet,
My feet rose to dance
When death was arrested
And my life began")
(c1 "Oh, Your grace so free,
Washes over me
You have made me new,
Now life begins with You
It's Your endless love,
Pouring down on us
You have made us new,
Now life begins with You")
(v3 "Released from my chains,
I'm a prisoner no more
My shame was a ransom
He faithfully bore
He cancelled my debt and
He called me His friend
When death was arrested
And my life began")
(v4 "Our Savior displayed
On a criminal's cross
Darkness rejoiced as though
Heaven had lost
But then Jesus arose
With our freedom in hand
That's when death was arrested
And my life began
That's when death was arrested
And my life began")
(b1 "Oh, we're free, free,
Forever we're free
Come join the song
Of all the redeemed
Yes, we're free, free,
Forever amen
When death was arrested
And my life began
Oh, we're free, free,
Forever we're free
Come join the song
Of all the redeemed
Yes, we're free, free,
Forever amen
When death was arrested
And my life began")
(e1 "When death was arrested
And my life began
That's when death was arrested
And my life began")
)