Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Latest commit

 

History

History
51 lines (39 loc) · 1.46 KB

README.md

File metadata and controls

51 lines (39 loc) · 1.46 KB

Crates.io Crates.io (recent) Crates.io

genius_rs

Rust library that allows interact with Genius API.

Warning

This library is not maintained anymore due to my lack of interest in genius and my change of focus in development to developing “commit

Searching for a song

use genius_rs::Genius;

#[tokio::main]
async fn main() {
    let genius = Genius::new(dotenv::var("TOKEN").unwrap());
    let response = genius.search("Ariana Grande").await.unwrap();
    println!("{}", response[0].result.full_title);
}

Getting lyrics

use genius_rs::Genius;

#[tokio::main]
async fn main() {
    let genius = Genius::new(dotenv::var("TOKEN").unwrap());
    let response = genius.search("Sia").await.unwrap();
    let lyrics = genius.get_lyrics(&response[0].result.id).await.unwrap();
    for verse in lyrics {
        println!("{}", verse);
    }
}

Getting deeper information for a song by id

use genius_rs::Genius;

#[tokio::main]
async fn main() {
    let genius = Genius::new(dotenv::var("TOKEN").unwrap());
    let response = genius.search("Weeknd").await.unwrap();
    let song = genius.get_song(response[0].result.id, "plain").await.unwrap();
    println!("{}", song.media.unwrap()[0].url)
}