Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yinyanfr/4267a522bd0bfd74cefadfd33cf7285e to your computer and use it in GitHub Desktop.
Save yinyanfr/4267a522bd0bfd74cefadfd33cf7285e to your computer and use it in GitHub Desktop.
Pause all unregistered torrents in Qbittorrent using the WebUI API
import qbittorrentAPI from "qbittorrent-api-v2"
async function pauseUnregisteredTorrents() {
const qbittorrent = await qbittorrentAPI.connect(
CONFIG.WebUIAddress,
CONFIG.Login,
CONFIG.Password
);
const torrents = await qbittorrent.torrents();
const unregistered = [];
for (const torrent of torrents) {
const trackers = await qbittorrent.trackers(torrent.hash);
if (trackers.find((e) => e.status === 4)) {
unregistered.push(torrent.hash);
}
}
await qbittorrent.pauseTorrents(unregistered.join("|"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment