Last active
September 10, 2025 15:19
-
-
Save thegrunge36/25acd61586bbb17ac545320e346c38df to your computer and use it in GitHub Desktop.
torrent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
# ⚙️ Config | |
radarr_url = "http://localhost:7878" | |
radarr_api = "votre clé api" | |
sonarr_url = "http://localhost:8989" | |
sonarr_api = "votre clé api" | |
# Mapping des indexeurs → catégories spécifiques | |
radarr_categories = { | |
"Abnormal (Prowlarr)": [2000, 100002, 100003, 100004], | |
"CrazySpirits (Prowlarr)": [2000, 2020, 2030, 2040, 2045, 2050, 2070, 2080, 100050, 100051, 100052, 100053, 100056, 100057, 100058, 100059, 100060, 100061, 100063, 100065, 100067, 100068, 100069, 100070, 100071, 100072, 100073, 100098, 100099, 100122, 100123, 100129, 100137, 100138, 100139, 1001340], | |
"Generation-Free (API) (Prowlarr)": [2000, 100001], | |
"HD-Forever (Prowlarr)": [2000, 100001, 100002, 100003, 100004], | |
"HD-Space (Prowlarr)": [2000, 2020, 2040, 2045, 2050, 100015, 100018, 100019, 100024, 100025, 100027, 100028, 100040, 100041, 100046, 100047, 100048, 100049], | |
"LeSaloon (Prowlarr)": [2000, 2030, 2040, 2045, 2050, 2060, 2070, 2080, 100013, 100015, 100018, 100019, 100020, 100026, 100027,100028, 100029, 100030, 100031, 100032, 100033, 100034, 100035, 100037,100038, 100039, 100040, 100041, 100042, 100071, 100072, 100074, 100075, 100077, 100078, 100079, 100080, 100082], | |
"SceneTime (Prowlarr)": [2000, 2020, 2030, 2040, 2045, 2060, 100016, 100047, 100057, 100059, 100064], | |
"Sharewood (API) (Prowlarr)": [2000, 2020, 8000, 8010, 100009, 100011, 100013, 100016], | |
"Team CT Game (Prowlarr)": [2000, 2040, 2045, 2050, 2070, 2080, 100414, 100415, 100416, 100417, 100418, 100419, 100420, 100421, 100422, 100423, 100424, 100425, 100426, 100427, 100428, 100429, 100430, 100431, 100432, 100433, 100434], | |
"The Old School (API) (Prowlarr)": [2000, 100001, 100006, 100010], | |
"TorrentLeech (Prowlarr)": [2000, 2010, 2020, 2030, 2040, 2045, 2050, 2070, 2080, 8000, 100011, 100012, 100013, 100014, 100015, 100029, 100036, 100037, 100043, 100047], | |
"Xthor (API) (Prowlarr)": [2000, 2020, 2030, 2040, 2045, 2050, 2070, 2080, 100001, 100002, 100004, 100005, 100006, 100007, 100008, 100009, 100012, 100020, 100031, 100033, 100094, 100095, 100100, 100107, 100118, 100119, 100122, 100125, 100126, 100127], | |
"YggAPI (Prowlarr)": [2000, 2020, 102145, 102178, 102179, 102180, 102181, 102182, 102183, 102184, 102185, 102186, 102187], | |
} | |
sonarr_categories = { | |
"Abnormal (Prowlarr)": [5000, 5070, 5080, 100001, 100009], | |
"CrazySpirits (Prowlarr)": [5000, 5030, 5040, 5045, 5050, 5060, 5070, 5080, 100074, 100075, 100077, 100084, 100085, 100088, 100092, 100093, 100094, 100095, 100096, 100097, 100128, 100130, 100133], | |
"Generation-Free (API) (Prowlarr)": [5000, 100002], | |
"HD-Forever (Prowlarr)": [5000, 5070, 100005, 100006], | |
"HD-Space (Prowlarr)": [5000, 5040, 5045, 5070, 5080, 100021, 100022, 100045], | |
"LeSaloon (Prowlarr)": [5000, 5030, 5040, 5050, 5060, 5070, 5080, 100017, 100021, 100022, 100023, 10043, 100044, 100045, 100046, 100047, 100048, 100049, 100050, 100051, 100052, 100083, 100085, 100086, 100087, 100088], | |
"SceneTime (Prowlarr)": [5000, 5030, 5040, 5045, 5070, 100001, 100002, 100009, 100043, 100077], | |
"Sharewood (API) (Prowlarr)": [5000, 5050, 5060, 5070, 5080, 100010, 100012, 100014], | |
"Team CT Game (Prowlarr)": [5000, 5030, 5040, 5060, 5070, 5080, 100440, 100441, 100442, 100443, 100444, 100445, 100446, 100447, 100448, 100449, 100051, 100052, 100053], | |
"The Old School (API) (Prowlarr)": [5000, 5060, 100002, 100007, 100008, 100009], | |
"TorrentLeech (Prowlarr)": [5000, 5020, 5030, 5040, 5070, 100026, 100027, 100032, 10034, 100035, 100044, 100093, 100094, 100095, 100096, 100097, 100128, 100130, 100133], | |
"Xthor (API) (Prowlarr)": [5000, 5030, 5040, 5050, 5060, 5070, 5080, 100013, 100014, 100015, 100016, 100017, 100030, 100032, 100034, 100098, 100101, 100104, 100109, 100110, 100123], | |
"YggAPI (Prowlarr)": [5000, 5050, 5060, 5070, 5080], | |
} | |
def set_categories(url, api_key, app_name, categories_map): | |
headers = {"X-Api-Key": api_key} | |
r = requests.get(f"{url}/api/v3/indexer", headers=headers) | |
r.raise_for_status() | |
indexers = r.json() | |
for idx in indexers: | |
idx_id = idx["id"] | |
idx_name = idx["name"] | |
if idx_name in categories_map: | |
cats = categories_map[idx_name] | |
print(f"🔧 {app_name} → mise à jour de {idx_name} avec {cats}") | |
# Chercher le champ "categories" | |
updated = False | |
for f in idx["fields"]: | |
if f["name"] == "categories": | |
f["value"] = cats | |
updated = True | |
if updated: | |
r2 = requests.put(f"{url}/api/v3/indexer/{idx_id}", headers=headers, json=idx) | |
r2.raise_for_status() | |
print(f"✅ {app_name} → {idx_name} mis à jour") | |
else: | |
print(f"⚠️ {app_name} → {idx_name} n’a pas de champ 'categories'") | |
else: | |
print(f"➡️ {app_name} → {idx_name} ignoré (pas dans config)") | |
if __name__ == "__main__": | |
try: | |
set_categories(radarr_url, radarr_api, "Radarr", radarr_categories) | |
set_categories(sonarr_url, sonarr_api, "Sonarr", sonarr_categories) | |
except Exception as e: | |
print(f"❌ Erreur: {e}") | |
# Ce script injecte automatiquement les catégories voulu dans radarr et sonarr | |
# sudo apt install python3.12-venv | |
# Ouvrir un terminal dans le dossier ou est le script | |
# python3 -m venv torrent | |
# source torrent/bin/activate | |
# pip install requests | |
# python3 torrent.py | |
# En tâche cron: | |
# sudo chmod +x /opt/script/torrent/torrent.py | |
# 0 * * * * root /usr/bin/python3 /opt/script/torrent/torrent.py > /dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment