mirror of
https://github.com/TeamPiped/piped-rust-sdk.git
synced 2024-08-14 23:56:06 +00:00
Update deps and add some fields.
This commit is contained in:
parent
5654524e72
commit
125fdee6c2
4 changed files with 20 additions and 16 deletions
|
@ -6,8 +6,8 @@ version = "0.0.0"
|
|||
|
||||
[dev-dependencies]
|
||||
piped = {path = "../piped"}
|
||||
reqwest = "0.11.3"
|
||||
tokio = {version = "1.5.0", features = ["macros", "rt-multi-thread"]}
|
||||
reqwest = "0.11.4"
|
||||
tokio = {version = "1.12.0", features = ["macros", "rt-multi-thread"]}
|
||||
|
||||
[[example]]
|
||||
name = "channel"
|
||||
|
|
|
@ -12,7 +12,7 @@ async fn main() {
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@ version = "0.0.0"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
reqwest = "0.11.3"
|
||||
serde = {version = "1.0.125", features = ["derive"]}
|
||||
serde_json = "1.0.64"
|
||||
reqwest = "0.11.4"
|
||||
serde = {version = "1.0.130", features = ["derive"]}
|
||||
serde_json = "1.0.68"
|
||||
|
|
|
@ -15,14 +15,14 @@ pub mod piped {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn get_trending(&self) -> Result<Vec<RelatedStream>, Box<dyn std::error::Error>> {
|
||||
let resp = &self
|
||||
.httpclient
|
||||
.get(format!("{}/trending", &self.instance))
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
pub async fn get_trending(
|
||||
&self,
|
||||
region: String,
|
||||
) -> Result<Vec<RelatedStream>, Box<dyn std::error::Error>> {
|
||||
let mut url = Url::parse(format!("{}/trending", &self.instance).as_str())?;
|
||||
url.query_pairs_mut().append_pair("region", region.as_str());
|
||||
|
||||
let resp = &self.httpclient.get(url).send().await?.text().await?;
|
||||
|
||||
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>> {
|
||||
let resp = &self
|
||||
.httpclient
|
||||
.get(format!("{}/channels/{}", &self.instance, id))
|
||||
.get(format!("{}/channel/{}", &self.instance, id))
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
|
@ -208,9 +208,11 @@ pub mod piped {
|
|||
pub url: String,
|
||||
pub title: String,
|
||||
pub thumbnail: String,
|
||||
pub uploader_avatar: Option<String>,
|
||||
pub uploader_name: String,
|
||||
pub uploader_url: String,
|
||||
pub uploaded_date: Option<String>,
|
||||
pub uploader_verified: bool,
|
||||
pub duration: i32,
|
||||
pub views: i64,
|
||||
}
|
||||
|
@ -220,15 +222,17 @@ pub mod piped {
|
|||
pub struct VideoInfo {
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub dash: Option<String>,
|
||||
pub upload_date: String,
|
||||
pub uploader: String,
|
||||
pub uploader_url: String,
|
||||
pub uploader_avatar: String,
|
||||
pub thumbnail_url: String,
|
||||
pub hls: ::serde_json::Value,
|
||||
pub hls: String,
|
||||
pub duration: i32,
|
||||
pub views: i64,
|
||||
pub likes: i64,
|
||||
pub lbry_id: Option<String>,
|
||||
pub dislikes: i64,
|
||||
pub audio_streams: Vec<Stream>,
|
||||
pub video_streams: Vec<Stream>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue