blob: bed63bafc2cf35f886f67c38799227f11f3f1503 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/bin/sh
[ -n "$DEBUG" ] && set -x
set -eu
qb_host=https://poseidon.feralhosting.com/kum4/qbittorrent
qb_user=kum4
qb_pass=${repo.vault.cmd("rbw get 6e66abae-094c-4c98-83ad-9b7bae3eb1b2")}
qb_cookiejar=/dev/shm/qb.cookies
do_login() {
curl -sS -o /dev/null \
-H "Referer: $qb_host" \
-d "username=$qb_user&password=$qb_pass" \
-c "$qb_cookiejar" \
"$qb_host/api/v2/auth/login"
}
do_getnew() {
curl -sS -b "$qb_cookiejar" \
"$qb_host/api/v2/torrents/info?filter=completed&sort=added_on&tag=" |
jq -rc '.[]|[.name,(if .root_path != "" then .root_path else .content_path end)]|@tsv'
}
do_markx() {
local name=$1
local hash
hash=$(curl -sS -b "$qb_cookiejar" \
"$qb_host/api/v2/torrents/info?filter=completed&sort=added_on&tag=" |
jq -rc --arg filter "$name" '.[]|select(.name==$filter)|.hash')
curl -sS -b "$qb_cookiejar" \
-d "hashes=$hash&tags=x" \
"$qb_host/api/v2/torrents/addTags"
}
main() {
rm -f "$qb_cookiejar" && do_login
case "$1" in
getnew) do_getnew ;;
markx) do_markx "$2" ;;
esac
}
main "$@"
|