Skip to content

Commit

Permalink
add api torrent/export (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjiangqiu authored Jul 2, 2024
1 parent aac0f52 commit ce76a3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tap = "1.0.1"
thiserror = "1.0.61"
tracing = "0.1.40"
serde_json = "1.0.117"

bytes = "1.6.0"
[dev-dependencies]
tokio = { version = "1.27.0", features = ["full"] }

Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::{

pub mod model;
pub use builder::QbitBuilder;
use bytes::Bytes;
use reqwest::{header, Client, Method, Response, StatusCode};
use serde::Serialize;
use serde_with::skip_serializing_none;
Expand Down Expand Up @@ -356,6 +357,14 @@ impl Qbit {
.map_err(Into::into)
}

pub async fn export_torrent(&self, hash: impl AsRef<str> + Send + Sync) -> Result<Bytes> {
self.get_with("torrents/export", &HashArg::new(hash.as_ref()))
.await?
.bytes()
.await
.map_err(Into::into)
}

pub async fn get_torrent_properties(
&self,
hash: impl AsRef<str> + Send + Sync,
Expand Down Expand Up @@ -1677,4 +1686,5 @@ mod test {
.unwrap();
print!("{:#?}", list);
}

}

0 comments on commit ce76a3f

Please sign in to comment.