working songs but needs better edge case handling
This commit is contained in:
parent
b81584a76b
commit
6779b0c77c
|
@ -241,64 +241,49 @@ fn lisp_to_song(list: Vec<Value>) -> Song {
|
||||||
|
|
||||||
let mut lyrics = vec![];
|
let mut lyrics = vec![];
|
||||||
|
|
||||||
if let Some(ref verse_order) = verse_order {
|
for element in lyric_elements {
|
||||||
for verse in verse_order {
|
let Value::List(lyric) = element else {
|
||||||
for element in lyric_elements {
|
continue;
|
||||||
let Value::List(lyric) = element else {
|
};
|
||||||
continue;
|
let Value::Symbol(Symbol(lyric_verse)) = &lyric[0] else {
|
||||||
};
|
continue;
|
||||||
let Value::Symbol(Symbol(lyric_verse)) = &lyric[0]
|
};
|
||||||
else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
let lyric = String::from(&lyric[1]);
|
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"#,
|
||||||
|
"v1" => r#"\n\nVerse 1\n"#,
|
||||||
|
"v2" => r#"\n\nVerse 2\n"#,
|
||||||
|
"v3" => r#"\n\nVerse 3\n"#,
|
||||||
|
"v4" => r#"\n\nVerse 4\n"#,
|
||||||
|
"v5" => r#"\n\nVerse 5\n"#,
|
||||||
|
"c1" => r#"\n\nChorus 1\n"#,
|
||||||
|
"c2" => r#"\n\nChorus 2\n"#,
|
||||||
|
"c3" => r#"\n\nChorus 3\n"#,
|
||||||
|
"c4" => r#"\n\nChorus 4\n"#,
|
||||||
|
"b1" => r#"\n\nBridge 1\n"#,
|
||||||
|
"b2" => r#"\n\nBridge 2\n"#,
|
||||||
|
"e1" => r#"\n\nEnding 1\n"#,
|
||||||
|
"e2" => r#"\n\nEnding 2\n"#,
|
||||||
|
"o1" => r#"\n\nOther 1\n"#,
|
||||||
|
"o2" => r#"\n\nOther 2\n"#,
|
||||||
|
_ => "",
|
||||||
|
};
|
||||||
|
|
||||||
let verse_title = match lyric_verse.as_str() {
|
let lyric = format!("{verse_title}{lyric}");
|
||||||
"i1" => r#"\n\nIntro 1\n"#,
|
println!("lyric_final: {lyric}");
|
||||||
"i2" => r#"\n\nIntro 1\n"#,
|
let lyric = lyric.replace(
|
||||||
"v1" => r#"\n\nVerse 1\n"#,
|
"\\n", r#"
|
||||||
"v2" => r#"\n\nVerse 2\n"#,
|
"#,
|
||||||
"v3" => r#"\n\nVerse 3\n"#,
|
);
|
||||||
"v4" => r#"\n\nVerse 4\n"#,
|
lyrics.push(lyric);
|
||||||
"v5" => r#"\n\nVerse 5\n"#,
|
|
||||||
"c1" => r#"\n\nChorus 1\n"#,
|
|
||||||
"c2" => r#"\n\nChorus 2\n"#,
|
|
||||||
"c3" => r#"\n\nChorus 3\n"#,
|
|
||||||
"c4" => r#"\n\nChorus 4\n"#,
|
|
||||||
"b1" => r#"\n\nBridge 1\n"#,
|
|
||||||
"b2" => r#"\n\nBridge 2\n"#,
|
|
||||||
"e1" => r#"\n\nEnding 1\n"#,
|
|
||||||
"e2" => r#"\n\nEnding 2\n"#,
|
|
||||||
"o1" => r#"\n\nOther 1\n"#,
|
|
||||||
"o2" => r#"\n\nOther 2\n"#,
|
|
||||||
_ => "",
|
|
||||||
};
|
|
||||||
|
|
||||||
let lyric = format!("{verse_title}{lyric}");
|
|
||||||
println!("{lyric}");
|
|
||||||
if &lyric_verse.to_uppercase() == verse {
|
|
||||||
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 =
|
let lyrics: String =
|
||||||
lyrics.iter().flat_map(|s| s.chars()).collect();
|
lyrics.iter().flat_map(|s| s.chars()).collect();
|
||||||
let lyrics = lyrics.replace(r#"\"#, "\\");
|
let lyrics = lyrics.trim_start().to_string();
|
||||||
let lyrics = lyrics.trim_start_matches("\\n\\n").to_string();
|
|
||||||
|
|
||||||
Song {
|
Song {
|
||||||
id,
|
id,
|
||||||
|
@ -605,10 +590,10 @@ You saved my soul"
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_lisp_conversion() {
|
pub fn test_lisp_conversion() {
|
||||||
let value = test_lisp_song();
|
let value = test_lisp_song();
|
||||||
let song = Song::from(value);
|
let lisp_song = Song::from(value);
|
||||||
let test_song = test_song();
|
let test_song = test_song();
|
||||||
println!("{}", test_song.lyrics.clone().unwrap());
|
println!("test_song: {}", test_song.lyrics.clone().unwrap());
|
||||||
println!("{}", song.lyrics.clone().unwrap());
|
println!("lisp_song: {}", lisp_song.lyrics.clone().unwrap());
|
||||||
assert_eq!(test_song, song);
|
assert_eq!(test_song, lisp_song);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
: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)
|
:verse-order (i1 v1 v2 c1 v3 c1 v4 c1 b1 b1 e1 e2)
|
||||||
(i1 "Death Was Arrested\nNorth Point Worship")
|
(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")
|
(v1 "Alone in my sorrow
|
||||||
(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")
|
And dead in my sin
|
||||||
(e1 "When death was arrested\nAnd my life began\n\nThat's when death was arrested\nAnd my life began")
|
|
||||||
(e2 "")
|
Lost without hope
|
||||||
(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")
|
With no place to begin
|
||||||
(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")
|
Your love made a way
|
||||||
(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"))
|
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")
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue