Skip to content

fix(qbittorrent): support qBittorrent 5.2+ session cookies and JSON add responses - #6

Open
pindaroli wants to merge 1 commit into
CT4nk3r:mainfrom
pindaroli:fix-qbittorrent-5.2-compatibility
Open

fix(qbittorrent): support qBittorrent 5.2+ session cookies and JSON add responses#6
pindaroli wants to merge 1 commit into
CT4nk3r:mainfrom
pindaroli:fix-qbittorrent-5.2-compatibility

Conversation

@pindaroli

Copy link
Copy Markdown

Summary

This PR fixes compatibility with qBittorrent v5.2.0 and later releases.

Background & Issues Fixed

  1. Session Cookie Name Breaking Change:
    Starting with qBittorrent 5.2.0, WebUI session cookies are formatted as QBT_SID_<PORT> (e.g. QBT_SID_8080) rather than the legacy SID. The previous strict check login.cookies.get("SID") returns None and raises qBittorrent login failed: no SID cookie returned. even when credentials are valid and a session cookie is returned.

    • Fix: Dynamically inspect returned cookies for any cookie containing SID, falling back to SID for older versions.
  2. Subnet Whitelist Bypass & HTTP 204 Handling:
    In qBittorrent 5.2.0+, /api/v2/auth/login returns HTTP 204 No Content on success, or when subnet whitelist bypass is enabled (WebUI\AuthSubnetWhitelistEnabled=true), it may not issue any cookie at all.

    • Fix: Handle 204 / subnet whitelist bypass scenarios gracefully without failing.
  3. Structured JSON Responses in /api/v2/torrents/add:
    Modern qBittorrent endpoints return structured JSON dicts (e.g. {"added_torrent_ids": [...], "success_count": 1, "failure_count": 0}) rather than plain text "Ok.". Previously, _qbt_add_result only checked for isinstance(result, str) and "ok.", causing successful additions to be reported as ❌ Failed to add magnet.

    • Fix: Added support for dictionary returns in _qbt_add_result, checking success_count and added_torrent_ids.

Testing

  • Tested against live qBittorrent v5.2.3 instances.
  • Successfully verified authentication, torrent listing (qbt_list_torrents), torrent details (qbt_torrent_details), and magnet additions (qbt_add_magnet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant