Skip to content

Update settings handling, improve qBittorrent API integration, and enhance logging - #18

Open
Tailslide wants to merge 16 commits into
Webreaper:masterfrom
Tailslide:master
Open

Update settings handling, improve qBittorrent API integration, and enhance logging#18
Tailslide wants to merge 16 commits into
Webreaper:masterfrom
Tailslide:master

Conversation

@Tailslide

Copy link
Copy Markdown

Sorry about the giant PR.. feel free to reject it or use part of if. It fixes some breaking changes in QBT.

Cross-seed aware pruning, qBittorrent compatibility fixes, and .NET 8 upgrade

Summary

Adds the ability to delete a torrent's task without deleting its files (protecting cross-seeded data), a tag-based prune exemption, fixes for newer qBittorrent WebUI versions, removal of committed credentials, and an upgrade to .NET 8.

Changes

Delete task without files
Each torrent is now assigned a delete method (DeleteFile / DeleteTask / DeleteFileAndTask / PauseTask). Files are preserved (task only removed) when:

  • delete_task_not_file_if_other_tasks — another torrent shares the same content (matched by info-hash or a SHA-256 of sorted file name + size)
  • delete_task_not_file_tags — torrent has a listed tag (e.g. cross-seed)
  • delete_task_not_file_categories — torrent is in a listed category

Prune-exempt tags
New pruneExemptTags under qbt settings — torrents with any of these tags are skipped entirely during pruning.

qBittorrent compatibility

  • Accept both SID and the newer QBT_SID_<port> session cookie on login
  • Send inactiveSeedingTimeLimit and shareLimitAction (required by qBittorrent 5.1+) in setShareLimits
  • Format ratio/seeding-time with InvariantCulture
  • Log HTTP status code + response body on request/command failures

Tooling & dependencies

  • Target framework net7.0 → net8.0; CI to 8.0.x; version 1.1.0
  • Updated MailKit, Syndication, Serilog
  • ⚠️ RestSharp changed 108.0.2 → 106.15.0 (a downgrade) — please confirm this was intentional

Repo hygiene

  • Removed committed Settings.json (contained real credentials) and added it to .gitignore
  • Added Settings.sample.json template
  • README updated for the new settings

Notes for reviewers

GenerateTorrentFileHash still has debug leftovers (a hardcoded hash comparison + Debug.WriteLine), plus a few commented-out blocks worth cleaning up before merge.

Tailslide and others added 16 commits March 4, 2024 20:55
…ple settings file and rename to Settings.sample.json
…ple settings file and rename to Settings.sample.json
…ings

Fix API call to set limits broken in new QBT
- Changed project to target .NET 8.0 and updated package references for RestSharp, MailKit, System.ServiceModel.Syndication, and Serilog.
- Refactored `qbtService` constructor to directly instantiate `RestClient` without `RestClientOptions`.
- Standardized HTTP method constants to use uppercase (e.g., `Method.POST`).
- Enhanced `MakeRestRequest` method signatures for consistency.
- Added logging for null responses in `MakeRestRequest` to improve error handling.
This commit modifies the `dotnet-version` parameter in the
`Setup .NET` step of the `ci.yml` file, upgrading the
version from 7.0.x to 8.0.x to ensure compatibility with
the latest features and improvements.
Implemented `IsPruneExemptTag` method to check for tags that exempt torrents from pruning. Updated `ProcessTorrents` to utilize this method and log reasons for keeping torrents. Enhanced `Settings` class with a new `pruneExemptTags` property and updated `Settings.sample.json` with default values for exempt tags.
qBittorrent renamed the WebUI session cookie from "SID" to
"QBT_SID_<port>" in newer versions. SignIn() looked for a cookie
named exactly "SID", so it never found the session cookie and
reported "Login failed." even though authentication succeeded.

Match both the legacy "SID" name and the "QBT_SID" prefix so login
works across qBittorrent versions and regardless of the WebUI port.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EgL7a13MvXA8ZwZ95seSMs
…cf2lpe

Support qBittorrent's new QBT_SID session cookie format
qBittorrent 5.1 made shareLimitAction a required parameter of
/torrents/setShareLimits, so every call 400'd with
"Missing required parameters: shareLimitAction" and limits were never
applied. Send shareLimitAction="Default" (use the global action when a
limit is reached), preserving the previous behaviour.

Also:
- Log the HTTP status code and response body on command/request failure
  instead of RestSharp's transport status ("Completed"), which hid the
  real reason.
- Format ratioLimit/seedingTimeLimit with InvariantCulture so a
  comma-decimal locale can't send "1,2" and trigger a 400.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EgL7a13MvXA8ZwZ95seSMs
…cf2lpe

Fix setShareLimits 400 by sending required shareLimitAction param
@Webreaper

Copy link
Copy Markdown
Owner

Yikes. I presume this MR was done with Claude or similar?

Questions:

Why the restsharp download?
Why not upgrade to .Net 10, rather than 8?

@Tailslide

Tailslide commented Jun 28, 2026

Copy link
Copy Markdown
Author

Yikes. I presume this MR was done with Claude or similar?

The last couple commits and the readme was done by claude code (opus 4.8)

Questions:

Why the restsharp download? Why not upgrade to .Net 10, rather than 8?

.NET 7 was EOL so I just went to 8 because it was marked as long term support. The one after 8 at the time (9? 10?) actually had a shorter support window.

I believe there was a reason for the restsharp downgrade but sadly that was a year ago and it's been lost to time. It's possible the latest is fine now.

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.

3 participants