INNER CODE UNIT · Rust

get_lyric

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

    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);
        };

        // Retrieve the song lyrics from the URL of the result
        let lyric = self.retrieve_lyric(&result.url).await?;

        // Return a LyricResult::Some with the song information

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…