Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# torrt changelog

### Unreleased
* ** qBittorrent: preserve torrent category on update.

### v1.1.0 [2026-03-30]
* !! QA. Dropped QA for Py 3.7, 3.8, 3.9, 3.10.
* ++ Add support to pass custom RPC parameters.
Expand Down
9 changes: 8 additions & 1 deletion src/torrt/rpc/qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,18 @@ def method_get_torrents(self, hashes: list[str] | None = None) -> list[dict]:
)
self.normalize_field_names(addition_data)

torrent_params: dict = {}

category = torrent_data.get('category')
if category:
torrent_params['category'] = category

torrents_info.append({
'hash': torrent_data_hash,
'name': torrent_data['name'],
'download_to': torrent_data['download_to'],
'comment': addition_data['comment']
'comment': addition_data['comment'],
'params': torrent_params,
})

return torrents_info
Expand Down
24 changes: 23 additions & 1 deletion tests/rpc/test_qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def test_get_torrents(response_mock, qbit, torrent_params):

with response_mock([
f'POST {qbit.url}auth/login -> 200:Ok.',
f'GET {qbit.url}torrents/info -> 200:' + '[{"hash": "xxxxx", "name": "mytorr", "save_path": "/home/idle"}]',
f'GET {qbit.url}torrents/info -> 200:'
'[{"hash": "xxxxx", "name": "mytorr", "save_path": "/home/idle", "category": "tv"}]',
f'POST {qbit.url}torrents/properties -> 200:' + '{"comment": "somecomment"}',
],
bypass=False
Expand All @@ -24,6 +25,27 @@ def test_get_torrents(response_mock, qbit, torrent_params):
'name': 'mytorr',
'hash': 'xxxxx',
'download_to': '/home/idle',
'params': {'category': 'tv'},
}]


def test_get_torrents_no_category(response_mock, qbit, torrent_params):

with response_mock([
f'POST {qbit.url}auth/login -> 200:Ok.',
f'GET {qbit.url}torrents/info -> 200:'
'[{"hash": "xxxxx", "name": "mytorr", "save_path": "/home/idle", "category": ""}]',
f'POST {qbit.url}torrents/properties -> 200:' + '{"comment": "somecomment"}',
],
bypass=False
):
response = qbit.method_get_torrents(hashes=['xxxxx'])
assert response == [{
'comment': 'somecomment',
'name': 'mytorr',
'hash': 'xxxxx',
'download_to': '/home/idle',
'params': {},
}]


Expand Down
Loading