Skip to content

Instantly share code, notes, and snippets.

@pettazz
Created February 9, 2026 15:35
Show Gist options
  • Select an option

  • Save pettazz/64561e923291807b59b5ab5fe3b1409d to your computer and use it in GitHub Desktop.

Select an option

Save pettazz/64561e923291807b59b5ab5fe3b1409d to your computer and use it in GitHub Desktop.
jackett tracker tracker
import datetime
import urllib.request
import urllib.error
JACKETT_BASEURL = "http://jackett.local"
TRACKERS = ["tracker", "names", "here"]
# i just output one line of somewhat obscured info to a file
# that's available on a public url via symlink to my http server
# so betterstack can alert when it doesn't say "it's all good!"
# with very simple error detail, without being too obvious;
# change as needed
RESULT_FILE = "/var/www/public/trackertracker"
out = ""
jcookie = None
# go through the jackett cookie login flow to get our token
opener = urllib.request.build_opener()
opener.addheaders = [("Cookie", "TestCookie=1")]
try:
response = opener.open(f"{JACKETT_BASEURL}/UI/Login?cookiesChecked=1")
out = "cookiefail"
except urllib.error.HTTPError as e:
if e.code == 302:
jcookie = e.headers.get("Set-Cookie")
if "Jackett" not in jcookie:
out ="loginfail"
jcookie = None
else:
out = f"HTTP/{e.code}"
except Exception as e:
out = f"general:{e}"
# if we got a token run jackett's built in test for each of our trackers
if jcookie:
all_good = True
for tracker in TRACKERS:
url = f"{JACKETT_BASEURL}/api/v2.0/indexers/{tracker}/test
req = urllib.request.Request(url, method="POST", headers={"Cookie":f"{jcookie};TestCookie=1"})
if urllib.request.urlopen(req).status != 204:
all_good = False
out += f"{tracker[:1]} failed;"
if all_good:
out = "it's all good!"
# write the output with a timestamp
with open(RESULT_FILE, "w") as f:
ts = datetime.datetime.now().isoformat()
f.write(f"[{ts}] {out}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment