mirror of
https://github.com/TeamPiped/piped-rust-sdk.git
synced 2024-08-14 23:56:06 +00:00
Add playlist example.
This commit is contained in:
parent
b5964484ca
commit
ed6b94dc2d
3 changed files with 27 additions and 2 deletions
|
@ -13,6 +13,10 @@ tokio = {version = "1.5.0", features = ["macros", "rt-multi-thread"]}
|
||||||
name = "channel"
|
name = "channel"
|
||||||
path = "channel.rs"
|
path = "channel.rs"
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "playlist"
|
||||||
|
path = "playlist.rs"
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "trending"
|
name = "trending"
|
||||||
path = "trending.rs"
|
path = "trending.rs"
|
||||||
|
|
21
examples/playlist.rs
Normal file
21
examples/playlist.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
use piped::piped::PipedClient;
|
||||||
|
use reqwest::ClientBuilder;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
let httpclient = ClientBuilder::new()
|
||||||
|
.user_agent("Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0")
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let instance = "https://pipedapi.kavin.rocks".to_string();
|
||||||
|
|
||||||
|
let client = PipedClient::new(httpclient, instance);
|
||||||
|
|
||||||
|
let playlist = client
|
||||||
|
.get_playlist_from_id("PLQSoWXSpjA38FIQCvwnVNPlGPVA63WTD8".to_string())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
println!("{:?}", playlist);
|
||||||
|
}
|
|
@ -12,7 +12,7 @@ async fn main() {
|
||||||
|
|
||||||
let client = PipedClient::new(httpclient, instance);
|
let client = PipedClient::new(httpclient, instance);
|
||||||
|
|
||||||
let channel = client.get_trending().await.unwrap();
|
let streams = client.get_trending().await.unwrap();
|
||||||
|
|
||||||
println!("{:?}", channel);
|
println!("{:?}", streams);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue