qbittorrent_web_api/api-gen/tests/add_torrent.rs
2022-07-10 17:06:19 +02:00

21 lines
750 B
Rust

use anyhow::Result;
use api_gen::QBittorrentApiGen;
const USERNAME: &str = "admin";
const PASSWORD: &str = "adminadmin";
const BASE_URL: &str = "http://localhost:8080";
#[derive(QBittorrentApiGen)]
struct Api {}
#[tokio::main]
async fn main() -> Result<()> {
let api = Api::login(BASE_URL, USERNAME, PASSWORD).await?;
// assuming this torrent will exist for a while: http://www.legittorrents.info/index.php?page=torrent-details&id=5cc013e801095be61d768e609e3039da58616fd0
const TORRENT_URL: &str = "http://www.legittorrents.info/download.php?id=5cc013e801095be61d768e609e3039da58616fd0&f=Oddepoxy%20-%20Oddepoxy%20(2013)%20[OGG%20320%20CBR].torrent";
let _ = api.torrent_management().add(TORRENT_URL).send().await?;
Ok(())
}