feat: Radarr import - add skip-guard to avoid unnecessary API calls
This commit is contained in:
parent
b04221cce4
commit
14faeb38a9
1 changed files with 30 additions and 0 deletions
|
|
@ -1,3 +1,17 @@
|
|||
/**
|
||||
* @name Radarr - Trigger Manual Import
|
||||
* @description Trigger Radarr ManualImport or downloadedMoviesScan with skip-guard.
|
||||
* @author FileFlows + Sascha
|
||||
* @revision 9
|
||||
* @output Import erfolgreich
|
||||
* @output Fehler
|
||||
* @param {string} URL Radarr root URL and port
|
||||
* @param {string} ApiKey Radarr API Key
|
||||
* @param {string} ImportPath Output path for import triggering
|
||||
* @param {bool} UseUnmappedPath Whether to Unmap the path
|
||||
* @param {bool} MoveMode Import mode: true=move, false=copy
|
||||
* @param {int} TimeOut Timeout in seconds (max 3600)
|
||||
*/
|
||||
import { Radarr } from 'Shared/Radarr';
|
||||
|
||||
|
||||
|
|
@ -9,6 +23,22 @@ function Script(URL, ApiKey, ImportPath, UseUnmappedPath, MoveMode, TimeOut) {
|
|||
ImportPath = UseUnmappedPath ? Flow.UnMapPath(ImportPath) : ImportPath;
|
||||
const importMode = MoveMode ? 'move' : 'copy';
|
||||
|
||||
// ── SKIP-GUARD: Nur API-Call machen, wenn der aktuelle ImportPath
|
||||
// mit dem konfigurierten Pfad uebereinstimmt. Sonst sofort OK.
|
||||
// Das verhindert 3 unnoetige API-Calls pro Datei (4 Arr-Instanzen).
|
||||
if (ImportPath && ImportPath.indexOf(URL) === -1) {
|
||||
// ImportPath ist ein Dateipfad, URL ist die Radarr-Instanz-URL.
|
||||
// Pruefe ob der ImportPath unter dem erwarteten Verzeichnis liegt.
|
||||
// Die Flow-Konfiguration setzt ImportPath z.B. auf /tdarr/converted/video4k/
|
||||
// oder /tdarr/converted/video/. Wenn der aktuelle file.FullName nicht
|
||||
// darunter liegt, sind wir nicht zustaendig.
|
||||
var currentFile = Variables['file.FullName'] || '';
|
||||
if (currentFile && ImportPath && currentFile.indexOf(ImportPath) === -1) {
|
||||
Logger.ILog(`Skip: current file '${currentFile}' not under ImportPath '${ImportPath}' - not responsible`);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
const radarr = new Radarr(URL, ApiKey);
|
||||
|
||||
/*── movieId detection ──────────────────────────────────*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue