INNER CODE UNIT · Rust

process_lyric

aome510/spotify-player · lyric_finder/src/lib.rs:110

    fn process_lyric(lyric: &str) -> String {
        // the below code modifies the `lyric` to make the newline between sections consistent
        lyric.replace("\n\n[", "\n[").replace("\n[", "\n\n[")
    }

    /// Get the lyric of a song satisfying a given `query`.
    pub async fn get_lyric(&self, query: &str) -> anyhow::Result<LyricResult> {
        // Perform the search for songs
        let results = self.search_songs(query).await?;

        // Filter to find the first result where the artist names do not contain 'Genius'
        let result = results
            .into_iter()
            .find(|result| !result.artist_names.contains("Genius"));

        // If no valid result is found, return LyricResult::None
        let Some(result) = result else {
            return Ok(LyricResult::None);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…