class

ArrJanitor::DownloadClient::QBittorrent

Inherits ArrJanitor::DownloadClient < Reference < Object

A qBittorrent download client, backed by the qbittorrent shard.

qBittorrent's WebUI authenticates with username/password (cookie session), not an API key, so this implementation always takes user + pass. Login is performed lazily on the first files_for call and the session is reused.

Constructors

new(base_url : String, username : String, password : String)
Source

Class methods

extract_paths(files : Array(::QBittorrent::Model::TorrentFile)) : Array(String)

Extracts the file paths from a list of qBittorrent TorrentFiles, dropping entries whose name is nil. Pure (no I/O) so it is unit-testable without a live server.

Source
translate_api_error(hash : String, ex : ::QBittorrent::ApiError) : Error

Maps a ::QBittorrent::ApiError onto this abstraction's error types: HTTP 404 (torrent no longer present) becomes TorrentNotFound; any other non-2xx becomes a generic Error carrying the original as its cause. Pure (no I/O) so the translation is unit-testable without a live server.

Source

Instance methods

files_for(hash : String) : Array(String)

Lists the file paths inside the torrent hash. Ensures a session (the underlying client logs in on demand) and maps each returned TorrentFile to its name, dropping any nil entries.

Translates qBittorrent API failures into this abstraction's own error types so callers never need to know about ::QBittorrent::ApiError: a 404 (torrent no longer in the client) becomes TorrentNotFound, any other non-2xx becomes Error.

Source