#client #music #manner #odesli

odesli-rs

Unofficial library to communicate with Odesli API in an async manner

11 stable releases (4 major)

5.2.1 Apr 16, 2025
5.1.1 Dec 28, 2024
5.0.0 Nov 2, 2023
4.1.0 Oct 26, 2023
1.0.0 Oct 23, 2023

#262 in HTTP client

Download history 5/week @ 2025-01-07 1/week @ 2025-01-14 50/week @ 2025-02-11 6/week @ 2025-02-18 251/week @ 2025-04-15

251 downloads per month

MIT license

22KB
454 lines

odesli-rs

[UNOFFICIAL] Async Rust library to communicate with Odesli API

  • Supports getting by URLs and IDs

Example

  • In Cargo.toml
[package]
name = "odesli-test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
odesli-rs = "5.1.0"
strum = "0.25.0"
tokio = { version = "1.33.0", features = ["full"] }
  • In src/main.rs
use odesli_rs::{APIProvider, ClientBuilder, EntityType, Platform};
use strum::IntoEnumIterator;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    println!("Supported Platforms:");
    for platform in Platform::iter() {
        println!(" - {:?}", platform)
    }
    println!("");

    println!("Supported API Providers:");
    for provider in APIProvider::iter() {
        println!(" - {:?}", provider)
    }
    println!("");

    let client = ClientBuilder::default()
        // .with_api_key(String::from("<INSERT_YOUR_API_KEY_HERE>")) // OPTIONAL
        // .with_api_version(String::from(odesli_rs::API_VERSION)) // Will be useful if any new API versions are released
        // .with_http_client(reqwest::Client::default()) // If you want to change your `reqwest::Client`'s settings
        .build();

    dbg!(
        client
            .get_by_url("https://music.youtube.com/watch?v=cnnOwLfAxn0")
            .await
    );

    let result = client
        .get_by_id(
            "7CNUefGBVLn4cLoYv3ej8x",
            &Platform::Spotify,
            &EntityType::Song,
        )
        .await?;

    dbg!(&result);
    dbg!(result.get_platform_url(&Platform::YouTube));
    dbg!(result.get_platform_entity(&Platform::YouTube));

    Ok(())
}

Dependencies

~4–16MB
~223K SLoC