127 lines
4.5 KiB
Python
Executable File
127 lines
4.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Script de test pour valider la configuration du récapitulatif Plex
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
import os
|
|
import requests
|
|
|
|
CONFIG_FILE = os.path.join(os.path.dirname(__file__), 'plex-recap-config.json')
|
|
|
|
def test_config():
|
|
"""Teste la configuration"""
|
|
print("🔍 Test de la configuration...\n")
|
|
|
|
# Charger la configuration
|
|
try:
|
|
with open(CONFIG_FILE, 'r', encoding='utf-8') as f:
|
|
config = json.load(f)
|
|
except FileNotFoundError:
|
|
print(f"❌ Fichier de configuration non trouvé: {CONFIG_FILE}")
|
|
return False
|
|
except json.JSONDecodeError as e:
|
|
print(f"❌ Erreur de parsing JSON: {e}")
|
|
return False
|
|
|
|
print("✅ Fichier de configuration chargé\n")
|
|
|
|
# Test Discord webhook
|
|
discord_config = config.get('discord', {})
|
|
webhook_url = discord_config.get('webhook_url', '')
|
|
if not webhook_url:
|
|
print("⚠️ URL du webhook Discord non configurée")
|
|
print(" Veuillez ajouter l'URL dans plex-recap-config.json\n")
|
|
else:
|
|
print(f"✅ Webhook Discord configuré: {webhook_url[:50]}...")
|
|
# Test de connexion
|
|
try:
|
|
response = requests.get(webhook_url, timeout=5)
|
|
print("✅ Webhook Discord accessible\n")
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"⚠️ Impossible de tester le webhook: {e}\n")
|
|
|
|
# Test Jellyseerr
|
|
jellyseerr_config = config.get('jellyseerr', {})
|
|
jellyseerr_url = jellyseerr_config.get('url', '')
|
|
jellyseerr_key = jellyseerr_config.get('api_key', '')
|
|
|
|
if not jellyseerr_key:
|
|
print("⚠️ Clé API Jellyseerr non configurée\n")
|
|
else:
|
|
print(f"✅ Jellyseerr configuré: {jellyseerr_url}")
|
|
try:
|
|
headers = {'X-Api-Key': jellyseerr_key}
|
|
response = requests.get(
|
|
f"{jellyseerr_url}/api/v1/status",
|
|
headers=headers,
|
|
timeout=5
|
|
)
|
|
if response.status_code == 200:
|
|
print("✅ Jellyseerr API accessible\n")
|
|
else:
|
|
print(f"⚠️ Jellyseerr API retourne le code: {response.status_code}\n")
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"⚠️ Impossible d'accéder à Jellyseerr: {e}\n")
|
|
|
|
# Test Radarr
|
|
radarr_config = config.get('radarr', {})
|
|
radarr_host = radarr_config.get('hostname', '')
|
|
radarr_port = radarr_config.get('port', 7878)
|
|
radarr_key = radarr_config.get('api_key', '')
|
|
use_ssl = radarr_config.get('use_ssl', False)
|
|
|
|
if not radarr_key:
|
|
print("⚠️ Clé API Radarr non configurée\n")
|
|
else:
|
|
protocol = 'https' if use_ssl else 'http'
|
|
radarr_url = f"{protocol}://{radarr_host}:{radarr_port}"
|
|
print(f"✅ Radarr configuré: {radarr_url}")
|
|
try:
|
|
params = {'apikey': radarr_key}
|
|
response = requests.get(
|
|
f"{radarr_url}/api/v3/system/status",
|
|
params=params,
|
|
timeout=5
|
|
)
|
|
if response.status_code == 200:
|
|
print("✅ Radarr API accessible\n")
|
|
else:
|
|
print(f"⚠️ Radarr API retourne le code: {response.status_code}\n")
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"⚠️ Impossible d'accéder à Radarr: {e}\n")
|
|
|
|
# Test Sonarr
|
|
sonarr_config = config.get('sonarr', {})
|
|
sonarr_host = sonarr_config.get('hostname', '')
|
|
sonarr_port = sonarr_config.get('port', 8989)
|
|
sonarr_key = sonarr_config.get('api_key', '')
|
|
use_ssl = sonarr_config.get('use_ssl', False)
|
|
|
|
if not sonarr_key:
|
|
print("⚠️ Clé API Sonarr non configurée\n")
|
|
else:
|
|
protocol = 'https' if use_ssl else 'http'
|
|
sonarr_url = f"{protocol}://{sonarr_host}:{sonarr_port}"
|
|
print(f"✅ Sonarr configuré: {sonarr_url}")
|
|
try:
|
|
params = {'apikey': sonarr_key}
|
|
response = requests.get(
|
|
f"{sonarr_url}/api/v3/system/status",
|
|
params=params,
|
|
timeout=5
|
|
)
|
|
if response.status_code == 200:
|
|
print("✅ Sonarr API accessible\n")
|
|
else:
|
|
print(f"⚠️ Sonarr API retourne le code: {response.status_code}\n")
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"⚠️ Impossible d'accéder à Sonarr: {e}\n")
|
|
|
|
print("\n✅ Test de configuration terminé")
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
test_config()
|