George-Miao / qbit

A Rust library for interacting with qBittorrent's Web API
https://docs.rs/qbit-rs
MIT License
32 stars 12 forks source link

Calling client.get_torrent_list results in a panick #7

Closed DestinyofYeet closed 9 months ago

DestinyofYeet commented 9 months ago

Calling

client.get_torrent_list(GetTorrentListArg::default()).await.unwrap();

Results in a panick

log.txt

George-Miao commented 9 months ago

Try request the API manually and check if the result is what you would expect (list of torrents in json).

DestinyofYeet commented 9 months ago

It does work with other libraries, so I don't think the issue is on my end. Tested with https://github.com/Koro33/qbit-api-rs

George-Miao commented 9 months ago

Please provide more info, include qbittorrent version, qbit-rs version, and the test code you used.

DestinyofYeet commented 9 months ago

Sorry, took a while.

qbit-rs = "0.3.8" qBittorrent v4.2.5

test code:

use qbit_rs::model::{Credential, GetTorrentListArg};
use qbit_rs::Qbit;

#[tokio::main]
pub async fn main() {
    let client = Qbit::new("http://192.168.0.252:8080", Credential::new("xxx", "xxx"));

    client.login(true).await.unwrap();

    println!("Logged in!");

    let torrent_list = client.get_torrent_list(GetTorrentListArg::default()).await.unwrap();
}
George-Miao commented 9 months ago

Ok I know what's going on. In old version, torrents/info (maybe other "read" endpoints) only accepts GET with url param, while in new versions we can do a post request with JSON body. I'll fix this soon.

George-Miao commented 9 months ago

I have fixed the bug and tested with qbittorrent v4.2.5 without problem anymore. Please upgrade qbit-rs version to 0.4 and try again.

DestinyofYeet commented 8 months ago

Unfortunately, I'm now getting a

thread 'main' panicked at src/main.rs:8:30:
called `Result::unwrap()` on an `Err` value: BadResponse { explain: "Failed to extract cookie from response" }

with the same example

qbit-rs = "0.4.1"

rust_error.txt

Edit:

I'mma try to reproduce it at home, since I was using a vpn, but I don't think it should make a difference.

Another edit:

Nevermind, seems like the vpn was the issue