feat: Sonarr import - add skip-guard to avoid unnecessary API calls
This commit is contained in:
parent
14faeb38a9
commit
88001b1ce0
1 changed files with 25 additions and 0 deletions
|
|
@ -1,3 +1,17 @@
|
||||||
|
/**
|
||||||
|
* @name Sonarr - Trigger Manual Import
|
||||||
|
* @description Trigger Sonarr ManualImport or downloadedEpisodesScan with skip-guard.
|
||||||
|
* @author FileFlows + Sascha
|
||||||
|
* @revision 8
|
||||||
|
* @output Import erfolgreich
|
||||||
|
* @output Fehler
|
||||||
|
* @param {string} URL Sonarr root URL and port
|
||||||
|
* @param {string} ApiKey Sonarr 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 { Sonarr } from 'Shared/Sonarr';
|
import { Sonarr } from 'Shared/Sonarr';
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -9,6 +23,17 @@ function Script(URL, ApiKey, ImportPath, UseUnmappedPath, MoveMode, TimeOut) {
|
||||||
ImportPath = UseUnmappedPath ? Flow.UnMapPath(ImportPath) : ImportPath;
|
ImportPath = UseUnmappedPath ? Flow.UnMapPath(ImportPath) : ImportPath;
|
||||||
const importMode = MoveMode ? 'move' : 'copy';
|
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) {
|
||||||
|
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 sonarr = new Sonarr(URL, ApiKey);
|
const sonarr = new Sonarr(URL, ApiKey);
|
||||||
|
|
||||||
/*── seriesId / episodeId detection ──────────────────────────────────*/
|
/*── seriesId / episodeId detection ──────────────────────────────────*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue