# 🎭 Radarr-TMDB Spectacle Tagger > Parce qu'Ă  50 ans, on a le droit d'avoir une bibliothĂšque Radarr bien rangĂ©e > ET de savoir distinguer un one-man-show d'un concert de CĂ©line Dion. ## Quoi ? Un script Python qui : 1. Scanne ta bibliothĂšque Radarr 2. Interroge TMDB pour chaque film 3. DĂ©tecte les **spectacles vivants** (stand-up, théùtre, one-man/woman show, cabaret, monologues, etc.) 4. Exclut explicitement les **concerts de musique** 5. Ajoute un tag **"spectacle"** dans Radarr **Dry-run par dĂ©faut** — on ne touche Ă  rien sans `--apply`. --- ## 📁 Structure du projet mon-projet/ ├── .env.global ← UN NIVEAU AU-DESSUS (../), JAMAIS commitĂ© ├── spectacle-tagger/ ← TON REPO │ ├── script.py │ ├── config.yaml ← ta config personnalisĂ©e (optionnel) │ ├── config.yaml.example │ ├── requirements.txt │ ├── .gitignore │ ├── README.md │ └── checklist.txt --- ## 🔐 Gestion des secrets (../.env.global) Le fichier `../.env.global` contient tes clĂ©s API. Il est stockĂ© **un niveau au-dessus** du repo pour ne jamais ĂȘtre commitĂ© accidentellement. ### CrĂ©ation automatique Si `../.env.global` n'existe pas au lancement du script, **il te demandera les 3 valeurs interactivement** (les clĂ©s sont saisies en mode masquĂ©) : CrĂ©ation de ../.env.global (Tes secrets restent entre toi et ton serveur) RADARR_URL (ex: http://localhost:7878) : http://mon-radarr:7878 RADARR_APIKEY (saisie masquĂ©e) : ******** TMDB_APIKEY (saisie masquĂ©e) : ******** ✅ Fichier créé : /home/moi/projets/.env.global ⚠ Ne le commite JAMAIS. Jamais. Nada. Que dalle. ### CrĂ©ation manuelle Tu peux aussi le crĂ©er toi-mĂȘme : ```bash cat > ../.env.global << 'EOF' RADARR_URL="http://localhost:7878" RADARR_APIKEY="ta-clĂ©-radarr-ici" TMDB_APIKEY="ta-clĂ©-tmdb-ici" EOF chmod 600 ../.env.global Messages d'erreur courants Copier le tableau Situation Message Fichier absent Fichier ../.env.global introuvable → crĂ©ation interactive Variable manquante Variables manquantes dans ../.env.global : TMDB_APIKEY Radarr injoignable Impossible de vĂ©rifier/crĂ©er le tag dans Radarr Rate limit TMDB Rate limit TMDB — on patiente Xs 🚀 Installation # Cloner le repo git clone https://ta-forge-gitea.local/ton-user/spectacle-tagger.git cd spectacle-tagger # Environnement virtuel (recommandĂ©, on n'est plus des sauvages) python3 -m venv venv source venv/bin/activate # Linux/Mac # venv\Scripts\activate # Windows # DĂ©pendances pip install -r requirements.txt # Config (optionnel — le script marche avec les dĂ©fauts) cp config.yaml.example config.yaml # Édite config.yaml selon tes goĂ»ts 🎼 Utilisation Dry-run (par dĂ©faut — on regarde, on touche pas) # 5 premiers films python script.py # 50 films python script.py --limit 50 # Tous les films python script.py --limit 0 # Mode verbeux python script.py --verbose # Mode silencieux python script.py --quiet Application rĂ©elle des tags # Tagger les spectacles dĂ©tectĂ©s (5 films) python script.py --limit 5 --apply # Tagger TOUT (fais un backup Radarr avant !) python script.py --limit 0 --apply Tous les arguments Copier le tableau Argument Description DĂ©faut --apply Applique rĂ©ellement les tags dry-run --limit N Nombre de films (0 = tous) 5 --tag NOM Nom du tag Radarr spectacle --output FICHIER Chemin du CSV results_spectacle_dryrun.csv --sensitivity strict|loose strict = keyword+runtime, loose = keyword suffit loose --verbose Logs dĂ©taillĂ©s non --quiet Logs minimaux non ⚙ Configuration (config.yaml) Copie config.yaml.example en config.yaml et adapte : TAG_NAME: "spectacle" DRY_RUN: true MIN_RUNTIME: 15 MAX_RUNTIME: 240 LIMIT: 5 SENSITIVITY: "loose" # ou "strict" OUTPUT_CSV: "results_spectacle_dryrun.csv" LOG_LEVEL: "INFO" EXTRA_KEYWORDS: - "stand-up" - "one-man" - "théùtre" # ... voir config.yaml.example pour la liste complĂšte EXCLUDE_KEYWORDS: - "concert" - "music" # ... voir config.yaml.example 🔄 Rollback (retirer un tag) Si tu as taguĂ© un film par erreur : Via l'interface Radarr Ouvre le film → Éditer → Retire le tag "spectacle" → Sauvegarder. Via l'API (curl) # 1. Trouver l'ID du tag curl -s -H "X-Api-Key: TA_CLÉ" http://localhost:7878/api/v3/tag | python3 -m json.tool # 2. RĂ©cupĂ©rer le film (ex: id=42) curl -s -H "X-Api-Key: TA_CLÉ" http://localhost:7878/api/v3/movie/42 > film.json # 3. Éditer film.json : retirer l'ID du tag du tableau "tags" # 4. Mettre Ă  jour curl -X PUT -H "X-Api-Key: TA_CLÉ" -H "Content-Type: application/json" \ -d @film.json http://localhost:7878/api/v3/movie/42 ⚠ SĂ©curitĂ© — Les trucs importants ../.env.global n'est JAMAIS commitĂ© (il est dans .gitignore ET un niveau au-dessus) Les clĂ©s ne sont jamais loggĂ©es ni Ă©crites dans le CSV Fais une sauvegarde Radarr avant toute modification massive : Radarr → System → Backup → Backup Now Le dry-run est activĂ© par dĂ©faut — il faut explicitement passer --apply