Update deps and add some fields.

This commit is contained in:
FireMaskterK 2021-10-04 12:55:06 +01:00
parent 5654524e72
commit 125fdee6c2
4 changed files with 20 additions and 16 deletions

View file

@ -6,8 +6,8 @@ version = "0.0.0"
[dev-dependencies] [dev-dependencies]
piped = {path = "../piped"} piped = {path = "../piped"}
reqwest = "0.11.3" reqwest = "0.11.4"
tokio = {version = "1.5.0", features = ["macros", "rt-multi-thread"]} tokio = {version = "1.12.0", features = ["macros", "rt-multi-thread"]}
[[example]] [[example]]
name = "channel" name = "channel"

View file

@ -12,7 +12,7 @@ async fn main() {
let client = PipedClient::new(httpclient, instance); let client = PipedClient::new(httpclient, instance);
let streams = client.get_trending().await.unwrap(); let streams = client.get_trending("US".to_string()).await.unwrap();
println!("{:?}", streams); println!("{:?}", streams);
} }

View file

@ -11,6 +11,6 @@ version = "0.0.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
reqwest = "0.11.3" reqwest = "0.11.4"
serde = {version = "1.0.125", features = ["derive"]} serde = {version = "1.0.130", features = ["derive"]}
serde_json = "1.0.64" serde_json = "1.0.68"

View file

@ -15,14 +15,14 @@ pub mod piped {
} }
} }
pub async fn get_trending(&self) -> Result<Vec<RelatedStream>, Box<dyn std::error::Error>> { pub async fn get_trending(
let resp = &self &self,
.httpclient region: String,
.get(format!("{}/trending", &self.instance)) ) -> Result<Vec<RelatedStream>, Box<dyn std::error::Error>> {
.send() let mut url = Url::parse(format!("{}/trending", &self.instance).as_str())?;
.await? url.query_pairs_mut().append_pair("region", region.as_str());
.text()
.await?; let resp = &self.httpclient.get(url).send().await?.text().await?;
let streams: Vec<RelatedStream> = serde_json::from_str(resp.as_str())?; let streams: Vec<RelatedStream> = serde_json::from_str(resp.as_str())?;
@ -35,7 +35,7 @@ pub mod piped {
) -> Result<Channel, Box<dyn std::error::Error>> { ) -> Result<Channel, Box<dyn std::error::Error>> {
let resp = &self let resp = &self
.httpclient .httpclient
.get(format!("{}/channels/{}", &self.instance, id)) .get(format!("{}/channel/{}", &self.instance, id))
.send() .send()
.await? .await?
.text() .text()
@ -208,9 +208,11 @@ pub mod piped {
pub url: String, pub url: String,
pub title: String, pub title: String,
pub thumbnail: String, pub thumbnail: String,
pub uploader_avatar: Option<String>,
pub uploader_name: String, pub uploader_name: String,
pub uploader_url: String, pub uploader_url: String,
pub uploaded_date: Option<String>, pub uploaded_date: Option<String>,
pub uploader_verified: bool,
pub duration: i32, pub duration: i32,
pub views: i64, pub views: i64,
} }
@ -220,15 +222,17 @@ pub mod piped {
pub struct VideoInfo { pub struct VideoInfo {
pub title: String, pub title: String,
pub description: String, pub description: String,
pub dash: Option<String>,
pub upload_date: String, pub upload_date: String,
pub uploader: String, pub uploader: String,
pub uploader_url: String, pub uploader_url: String,
pub uploader_avatar: String, pub uploader_avatar: String,
pub thumbnail_url: String, pub thumbnail_url: String,
pub hls: ::serde_json::Value, pub hls: String,
pub duration: i32, pub duration: i32,
pub views: i64, pub views: i64,
pub likes: i64, pub likes: i64,
pub lbry_id: Option<String>,
pub dislikes: i64, pub dislikes: i64,
pub audio_streams: Vec<Stream>, pub audio_streams: Vec<Stream>,
pub video_streams: Vec<Stream>, pub video_streams: Vec<Stream>,