genius-rust

Crates.iogenius-rust
lib.rsgenius-rust
version0.1.1
sourcesrc
created_at2022-08-27 22:25:04.142105
updated_at2022-08-27 22:28:35.24455
descriptionRust library that allows interact with Genius API
homepage
repositoryhttps://github.com/tsirysndr/genius-rust
max_upload_size
id653634
size42,655
Tsiry Sandratraina (tsirysndr)

documentation

README

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

genius_rust

Rust library that allows interact with Genius API.

Searching for a song

use genius_rust::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_rust::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_rust::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)
}
Commit count: 119

cargo fmt