From ed6b94dc2d2d97581d1f7c6445e9c5ba5d4405c9 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 29 Apr 2021 22:11:32 +0530 Subject: [PATCH] Add playlist example. --- examples/Cargo.toml | 4 ++++ examples/playlist.rs | 21 +++++++++++++++++++++ examples/trending.rs | 4 ++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 examples/playlist.rs diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 9b52963..f270c11 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -13,6 +13,10 @@ tokio = {version = "1.5.0", features = ["macros", "rt-multi-thread"]} name = "channel" path = "channel.rs" +[[example]] +name = "playlist" +path = "playlist.rs" + [[example]] name = "trending" path = "trending.rs" diff --git a/examples/playlist.rs b/examples/playlist.rs new file mode 100644 index 0000000..1eb5a29 --- /dev/null +++ b/examples/playlist.rs @@ -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); +} diff --git a/examples/trending.rs b/examples/trending.rs index 7806a45..ace3c67 100644 --- a/examples/trending.rs +++ b/examples/trending.rs @@ -12,7 +12,7 @@ async fn main() { let client = PipedClient::new(httpclient, instance); - let channel = client.get_trending().await.unwrap(); + let streams = client.get_trending().await.unwrap(); - println!("{:?}", channel); + println!("{:?}", streams); }