fedarovich / qbittorrent-cli

Command line interface for QBittorrent
MIT License
312 stars 17 forks source link

Feature: Resume multiple torrents #71

Closed kingp0dd closed 9 months ago

kingp0dd commented 2 years ago

Is there a way to resume multiple torrents at once? Goal is to resume all "errored" torrents through cron.

So far, I was able to get the "hash" of all errored torrents, but I found out that I can't pass multiple hashes to qbt torrent resume

 $(qbt torrent list -f errored -F json  | grep -Eo '"hash":.*?[^\\]",' |awk -F':' '{print $2}' | awk 'match($0, /"[^"]*/) {print su
bstr($0, RSTART+1, RLENGTH-1)}')
fedarovich commented 1 year ago

You can likely do it using xargs linux command. You can see an example here: https://github.com/fedarovich/qbittorrent-cli/discussions/64

Jarsky commented 1 year ago

@kingp0dd

I assume you've already sorted this, but you through cron, use a bash script like this I just installed jq (apt-get install jq) to parse the json easily without having to awk it.

#!/bin/bash
jsonFilename=qbt-errored

# export torrent list as json
qbt torrent list -F json > $jsonFilename.json

# parse json file and find all torrents with "state": "errored"
hashes=$(jq -r '.[] | select(.state=="errored") | .hash' $jsonFilename.json)

# loop through each hash and pause the corresponding torrent
for hash in $hashes; do
  qbt torrent pause $hash
done

rm -f $jsonFilename.json