Update qbittorrent webui api - #11
Draft
CampingAvocado wants to merge 5 commits into
Draft
Conversation
…ble with qbittorrent v5.2 now
- 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>
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.
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
github.com/Mattress237/qbittorrent-webui-apipinned to a specific rev, instead of my fork.reqwestgains the json feature (needed directly now, previously pulled in transitively).ensure_category_exists/add_torrent_with_categorysimplified: dropped the manual 60s TTL category cache (CategoryCache) and the qbit_url-keyed lookup. Category creation now just callscreate_categoryand 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 returnsVec<String>instead ofVec<Category>(HashMap), so torrent.rs and torrent.html were updated to work with plain category names instead of aCategorystruct.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.