From ad42aa349fcd5db44a4bba5c558af9be5ca47b89 Mon Sep 17 00:00:00 2001 From: Kasper Plougmann Date: Wed, 9 Jul 2025 22:45:26 +0200 Subject: [PATCH] More logging --- fetch_torrents.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fetch_torrents.py b/fetch_torrents.py index bf0a4f1..d8e287c 100644 --- a/fetch_torrents.py +++ b/fetch_torrents.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import os import re +import json import requests import logging import time @@ -139,6 +140,20 @@ def fetch_kali_latest(): logging.error(f"Kali fetch error: {e}") return False +def log_seed_ratios_via_http(rpc_url="http://localhost:9091/transmission/rpc", + auth: tuple | None = None): + + r = requests.post(rpc_url) + headers = {"X-Transmission-Session-Id": r.headers["X-Transmission-Session-Id"]} + payload = { + "method": "torrent-get", + "arguments": {"fields": ["name", "uploadRatio"]} + } + r = requests.post(rpc_url, json=payload, headers=headers, auth=auth, timeout=15) + r.raise_for_status() + for t in r.json()["arguments"]["torrents"]: + logging.info("[ratio] %s → %.3f", t["name"], t["uploadRatio"]) + if __name__ == "__main__": start_time = time.time() logging.info("Starting torrent fetch run.") @@ -152,6 +167,11 @@ if __name__ == "__main__": else: failure_count += 1 + try: + log_seed_ratios_via_http() + except Exception as exc: + logging.warning("Could not query Transmission: %s", exc) + total, used, free = shutil.disk_usage("/downloads") logging.info(f"Downloads folder usage: {used // (2**30)} GB used / {total // (2**30)} GB total")