QBittorrent::Api::Torrents
Reopens Api::Torrents (see torrents.cr for the class definition and the
read/info endpoints) to add the lifecycle & queue mutation endpoints of
the torrents group (ext/api-map.md §2.5):
- adding torrents (
torrents/add) from magnet/HTTP URLs and/or a raw.torrentupload; - the lifecycle actions
start/stop/delete/recheck/reannounce; - the queue-priority actions
topPrio/bottomPrio/increasePrio/decreasePrio.
All of these are POST actions that return an empty 200 on success
(torrents/add returns the text Ok./Fails.), so every method here
returns Nil. The *hashes* helpers accept "all", a single hash, or an enumerable of hashes (joined with |`).
Constructors
Instance methods
POST torrents/add — add one or more torrents from urls (magnet or
HTTP links) and/or a single raw .torrent upload (torrent content,
announced as torrent_filename). At least one source must be given.
urls may be a single string or an enumerable of links (joined with
newlines, as the API expects). Supplying torrent sends the request as
multipart/form-data (the transport torrents/add requires for file
uploads); with only urls the multipart body carries just the fields.
The remaining parameters map to the qB 5.x add options: savepath,
category, tags (a single string or an enumerable joined with commas),
stopped (add without starting), stop_condition
(None/MetadataReceived/FilesChecked), content_layout
(Original/Subfolder/NoSubfolder), add_to_top_of_queue,
download_path / use_download_path (incomplete-files path), rename
(initial torrent name), up_limit / dl_limit (bytes/s), ratio_limit,
seeding_time_limit (minutes), auto_tmm, sequential_download,
first_last_piece_prio and cookie (sent when downloading from urls).
Raises ArgumentError when neither urls nor torrent is given, and a
QBittorrent::Error when the server rejects every source (Fails.).
POST torrents/addPeers — add peers to the torrents. peers is a
single host:port entry or an enumerable (joined with |).
POST torrents/addTags — add tags to the torrents. tags is a single
tag or an enumerable (joined with commas).
POST torrents/addTrackers — add tracker urls to the torrent hash.
urls is a single URL or an enumerable (joined with newlines).
POST torrents/bottomPrio — move the given torrents to the bottom of the
queue. Requires queueing enabled (409 otherwise).
POST torrents/createCategory — create category, optionally with a
save_path.
POST torrents/createTags — create tags. tags is a single tag or an
enumerable (joined with commas).
POST torrents/decreasePrio — move the given torrents one step down the
queue. Requires queueing enabled (409 otherwise).
POST torrents/delete — remove the given torrents. When delete_files is
true the downloaded data is deleted from disk as well.
POST torrents/deleteTags — delete tags. tags is a single tag or an
enumerable (joined with commas).
torrents/downloadLimit — per-torrent download limits as
{hash => bytes/s} (0 = unlimited). Sent as a POST form (the
transport most reliably accepted across 5.x builds; see api-map §7.6).
POST torrents/editCategory — set category's save path to save_path.
POST torrents/editTracker — replace tracker orig_url with new_url on
the torrent hash.
GET torrents/export — export the torrent hash as raw .torrent file
bytes (qB 5.x runtime; thinly documented on the wiki).
GET torrents/files — files of the torrent hash. indexes restricts
to specific file indexes (a single index/string or an enumerable, joined
with |).
POST torrents/increasePrio — move the given torrents one step up the
queue. Requires queueing enabled (409 otherwise).
GET torrents/info — list torrents, optionally filtered/sorted/paged.
filter narrows by state group (mapped to its API string via the enum);
category and tag narrow by category/tag name (pass "" to match the
uncategorised/untagged set). sort names a TorrentInfo field to sort
by and reverse reverses that order. limit/offset page the result.
hashes restricts to specific torrents; pass a single hash string or an
enumerable of hashes (joined with |).
GET torrents/pieceHashes — per-piece hashes of the torrent hash, in
piece order (hex strings).
GET torrents/pieceStates — per-piece download state of the torrent
hash, in piece order.
The wire form is an array of ints (0/1/2); they are decoded here
through PieceState's strict enum codec (the value set is closed).
GET torrents/properties — detailed properties of the torrent hash.
POST torrents/reannounce — re-announce the given torrents to their
trackers.
POST torrents/recheck — force a re-check of the given torrents.
POST torrents/removeCategories — delete one or more categories.
categories is a single name or an enumerable (joined with newlines).
POST torrents/removeTags — remove tags from the torrents (an empty
tags removes all). tags is a single tag or an enumerable (joined with
commas).
POST torrents/removeTrackers — remove tracker urls from the torrent
hash. urls is a single URL or an enumerable (joined with |).
POST torrents/rename — rename the torrent hash to name.
POST torrents/renameFile — rename a file within the torrent hash from
old_path to new_path (both relative to the torrent root).
POST torrents/renameFolder — rename a folder within the torrent hash
from old_path to new_path (both relative to the torrent root).
POST torrents/setAutoManagement — enable/disable automatic torrent
management (auto-TMM) for the torrents.
POST torrents/setCategory — assign category (pass "" to clear).
POST torrents/setDownloadLimit — per-torrent download rate limit,
limit in bytes/s (0 = unlimited).
POST torrents/setDownloadPath — set the incomplete-files download path
(qB 5.x). id is a hash argument (the API names the field id).
POST torrents/setForceStart — set force-start on the torrents.
POST torrents/setLocation — move the torrents' content to location.
POST torrents/setSavePath — set the (completed) save path (qB 5.x).
id is a hash argument (the API names the field id).
POST torrents/setSuperSeeding — set super-seeding on the torrents.
POST torrents/setUploadLimit — per-torrent upload rate limit,
limit in bytes/s (0 = unlimited).
POST torrents/start — start (resume) the given torrents. qB 5.x rename
of torrents/resume. hashes is "all", a single hash, or an enumerable.
POST torrents/stop — stop (pause) the given torrents. qB 5.x rename of
torrents/pause.
POST torrents/toggleFirstLastPiecePrio — flip first/last-piece priority
on/off for the torrents.
POST torrents/toggleSequentialDownload — flip sequential download on/off
for the torrents.
POST torrents/topPrio — move the given torrents to the top of the queue.
Requires queueing to be enabled (the server answers 409 otherwise).
GET torrents/trackers — trackers of the torrent hash (includes the
synthetic DHT/PeX/LSD pseudo-rows).
torrents/uploadLimit — per-torrent upload limits as
{hash => bytes/s} (0 = unlimited). Sent as a POST form (see
api-map §7.6).