fix(qbittorrent): support qBittorrent 5.2+ session cookies and JSON add responses - #6
Open
pindaroli wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes compatibility with qBittorrent v5.2.0 and later releases.
Background & Issues Fixed
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 legacySID. The previous strict checklogin.cookies.get("SID")returnsNoneand raisesqBittorrent login failed: no SID cookie returned.even when credentials are valid and a session cookie is returned.SID, falling back toSIDfor older versions.Subnet Whitelist Bypass & HTTP 204 Handling:
In qBittorrent 5.2.0+,
/api/v2/auth/loginreturnsHTTP 204 No Contenton success, or when subnet whitelist bypass is enabled (WebUI\AuthSubnetWhitelistEnabled=true), it may not issue any cookie at all.204/ subnet whitelist bypass scenarios gracefully without failing.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_resultonly checked forisinstance(result, str)and"ok.", causing successful additions to be reported as❌ Failed to add magnet._qbt_add_result, checkingsuccess_countandadded_torrent_ids.Testing
qbt_list_torrents), torrent details (qbt_torrent_details), and magnet additions (qbt_add_magnet).