Skip to content

Update qbittorrent webui api - #11

Draft
CampingAvocado wants to merge 5 commits into
mainfrom
update-qbittorrent-webui-api
Draft

Update qbittorrent webui api#11
CampingAvocado wants to merge 5 commits into
mainfrom
update-qbittorrent-webui-api

Conversation

@CampingAvocado

Copy link
Copy Markdown
Owner

Move off of forked qbittorrent-webui-api crate

Switches to the original upstream by Mattress237, which now works against qBittorrent v5.2.
Some breaking API changes needed to be adapted.

Changes

  • Dependency swap: qbit now points at github.com/Mattress237/qbittorrent-webui-api pinned to a specific rev, instead of my fork. reqwest gains the json feature (needed directly now, previously pulled in transitively).
  • ensure_category_exists / add_torrent_with_category simplified: dropped the manual 60s TTL category cache (CategoryCache) and the qbit_url-keyed lookup. Category creation now just calls create_category and treats HTTP 409 (already exists) as success.
    All callers (cleaner.rs, linker.rs, config.rs, torrent.rs) updated to drop the now-unused qbit_url argument.
  • categories() return type change: now returns Vec<String> instead of Vec<Category> (HashMap), so torrent.rs and torrent.html were updated to work with plain category names instead of a Category struct.

Remaining issues

Whilst simplifying the category managment may still be a good idea, the qbit.categories() method is indeed broken over at the original upstream.
The original author of MLM had the fix implemented in their fork and before moving forward here I'll see if I can get the fix merged upstream.

CampingAvocado and others added 5 commits July 29, 2026 15:47
- Adapt to qbit API changes:
  - Handle `qbit.categories()` returning a `Vec<String>` instead of
    a map/struct, removing `.into_keys()`, `.into_values()`, and
    `.name` accesses.
  - Update `AddTorrent` struct initialization to use `paused` instead
    of the deprecated `stopped` field.
- Update Askama templates (`pages/torrent.html`) to iterate over the
  new category strings and fix string comparison using `.as_str()`.
- Clean up unused imports (e.g., `exporter::export_db`) and redundant
  `.as_str()` calls in templates to resolve compiler warnings.
The upstream qbittorrent-webui-api crate's categories() method tries to
deserialize /api/v2/torrents/categories as Vec<String>, but the API
returns a JSON object. Replace the check-then-create pattern with a
simple upsert: call create_category and treat HTTP 409 (already exists)
as success. This removes CategoryCache and the unused url parameter from
ensure_category_exists and add_torrent_with_category.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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