From d050417e015004f1784dcd9a489ffa297aae47f5 Mon Sep 17 00:00:00 2001 From: Patrick Veverka Date: Thu, 29 Jan 2026 13:41:19 -0500 Subject: [PATCH] fix newer versions of rtorrent (#549) Closes https://github.com/calibrain/shelfmark/issues/534 This pull request enhances the rTorrent client testing and implementation by adding more robust checks for directory paths and improving how the base path is retrieved. The main focus is on verifying and obtaining the correct download and base directories for torrents. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- scripts/test_clients.py | 22 +++++++++++++++++-- .../prowlarr/clients/rtorrent.py | 14 ++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/scripts/test_clients.py b/scripts/test_clients.py index afdd899d..e734e874 100755 --- a/scripts/test_clients.py +++ b/scripts/test_clients.py @@ -434,6 +434,10 @@ def test_rtorrent(): version = client.system.library_version() print(f" Connected to rTorrent {version}") + # default download directory test + default_dir = client.directory.default() + print(f" Default download directory: {default_dir}") + # Get torrent list torrents = client.download_list() print(f" Active torrents: {len(torrents)}") @@ -458,10 +462,13 @@ def test_rtorrent(): torrent_id = "3B245504CF5F11BBDBE1201CEA6A6BF45AEE1BC0" # rtorrent uses uppercase hashes print(f" Added test torrent: {torrent_id}") + torrents = client.download_list() + print(f" Active torrents: {len(torrents)}") + torrent_list = client.d.multicall.filtered( "", "default", - f"equal=d.hash=,cat={torrent_id}", + f"equal={{d.hash=,cat={torrent_id}}}" "d.hash=", "d.state=", "d.completed_bytes=", @@ -472,11 +479,22 @@ def test_rtorrent(): "d.complete=", ) torrent = torrent_list[0] + if not torrent: print(" ERROR: Could not find added torrent in list") return False - + # let's test the base path call + details = client.d.multicall.filtered( + "", + "default", + f"equal=d.hash=,cat={torrent_id}", + "d.base_path=", + ) + + base_path = details[0][0] if details else None + + print(f" Base path: {base_path}") client.d.erase(torrent_id) print(" Removed test torrent") diff --git a/shelfmark/release_sources/prowlarr/clients/rtorrent.py b/shelfmark/release_sources/prowlarr/clients/rtorrent.py index 3f57cd67..14d28965 100644 --- a/shelfmark/release_sources/prowlarr/clients/rtorrent.py +++ b/shelfmark/release_sources/prowlarr/clients/rtorrent.py @@ -310,7 +310,17 @@ class RTorrentClient(DownloadClient): this corresponds to `d.get_base_path()`. """ try: - base_path = self._rpc.d.get_base_path(download_id) - return base_path if base_path else None + # rTorrent is case sensitive for hashes; use uppercase as in get_status() + download_hash = download_id.upper() + details = self._rpc.d.multicall.filtered( + "", + "default", + f"equal={{d.hash=,cat={download_hash}}}", + "d.base_path=", + ) + if not details: + return None + path = details[0][0] + return path if path else None except Exception: return None