2 use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
7 use genius::{get_lyrics, search};
9 const GENIUS_CLIENT_TOKEN: &str = env!("LYRICLI_GENIUS_TOKEN");
10 const GENIUS_API_URL: &str = "https://api.genius.com/search";
12 pub async fn print_lyrics(track: Track, show_title: bool) -> Result<()> {
14 println!("{} - {}", track.artist, track.name);
17 let artist = utf8_percent_encode(&track.artist, NON_ALPHANUMERIC).to_string();
18 let name = utf8_percent_encode(&track.name, NON_ALPHANUMERIC).to_string();
19 let url = format!("{}?access_token={}&q={}%20{}", GENIUS_API_URL, GENIUS_CLIENT_TOKEN, artist, name);
21 let song_url = search(&url).await?;
22 let lyrics = get_lyrics(&song_url).await?;
24 println!("{}", lyrics);