mirror of
https://github.com/kristoferssolo/transmission-rpc.git
synced 2025-10-21 20:10:37 +00:00
25 lines
872 B
Rust
25 lines
872 B
Rust
extern crate transmission_rpc;
|
|
|
|
use std::env;
|
|
use dotenv::dotenv;
|
|
use transmission_rpc::TransClient;
|
|
use transmission_rpc::types::{Result, RpcResponse, BasicAuth};
|
|
use transmission_rpc::types::{TorrentAddArgs, TorrentAdded};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
dotenv().ok();
|
|
env_logger::init();
|
|
let url= env::var("TURL")?;
|
|
let basic_auth = BasicAuth{user: env::var("TUSER")?, password: env::var("TPWD")?};
|
|
let client = TransClient::with_auth(&url, basic_auth);
|
|
let add: TorrentAddArgs = TorrentAddArgs {
|
|
filename: Some("https://releases.ubuntu.com/20.04/ubuntu-20.04-desktop-amd64.iso.torrent".to_string()),
|
|
..TorrentAddArgs::default()
|
|
};
|
|
let res: RpcResponse<TorrentAdded> = client.torrent_add(add).await?;
|
|
println!("Add result: {:?}", &res.is_ok());
|
|
println!("response: {:?}", &res);
|
|
|
|
Ok(())
|
|
} |