diff options
| author | Robert Günzler <r@gnzler.io> | 2025-09-07 17:32:13 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2025-09-25 12:56:47 +0200 |
| commit | 8db9d0cc31582750026c66fa02236c494c2a8e2c (patch) | |
| tree | c8c89acfed7ad9a0016936e700b69f67db6b269f /bundles/bitfroest/files/qbapi | |
| parent | 0bb17cd2f34918add1ddaedeb0a66531dea561a3 (diff) | |
add bitfroest bundle
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bundles/bitfroest/files/qbapi')
| -rwxr-xr-x | bundles/bitfroest/files/qbapi | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/bundles/bitfroest/files/qbapi b/bundles/bitfroest/files/qbapi new file mode 100755 index 0000000..89d328e --- /dev/null +++ b/bundles/bitfroest/files/qbapi @@ -0,0 +1,45 @@ +#!/bin/sh +set -eu + +qb_host=https://porphyrion.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,.content_path]|@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() { + test -f "$qb_cookiejar" || do_login + + case "$1" in + getnew) do_getnew ;; + markx) do_markx "$2" ;; + esac +} + +main "$@" |