From 41e07686aebbb31a6ec0e66c0e5cbae600d5aedf Mon Sep 17 00:00:00 2001 From: Idan Bush Date: Wed, 18 Dec 2024 06:56:27 +0000 Subject: [PATCH 1/4] Add improved arr scripts for manual import --- .../Radarr/Radarr - Trigger Manual Import.js | 37 ++++++++++++++++++ .../Sonarr/Sonarr - Trigger Manual Import.js | 38 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js create mode 100644 Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js diff --git a/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js b/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js new file mode 100644 index 0000000..732a4ab --- /dev/null +++ b/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js @@ -0,0 +1,37 @@ +import { Radarr } from 'Shared/Radarr'; + +/** + * @name Radarr - Trigger Manual Import 2.0 + * @uid cd8926f3-a9ab-4fa7-a36e-cceb8ad58987 + * @description Trigger Radarr to manually import the media, run after last file in folder moved. + * @author iBuSH + * @revision 1 + * @param {string} URL Radarr root URL and port (e.g. http://radarr:7878) + * @param {string} ApiKey Radarr API Key + * @param {string} ImportPath The output path for import triggering (default Working File) + * @param {bool} UseUnmappedPath Whether to Unmap the path to the original FileFlows Server path when using nodes in different platforms (e.g. Docker and Windows) + * @param {bool} MoveMode Import mode 'copy' or 'move' (default copy) + * @output Command sent + */ +function Script(URI, ApiKey) { + URL = URL || Variables['Radarr.Url'] || Variables["Radarr.URI"]; + ApiKey = ApiKey || Variables["Radarr.ApiKey"]; + ImportPath = ImportPath || Variables.file.FullName; + const ImportMode = MoveMode ? "move" : "copy"; + const radarr = new Radarr(URL, ApiKey); + + if (UseUnmappedPath) ImportPath = Flow.UnMapPath(ImportPath); + + Logger.ILog(`Triggering URL: ${URL}`); + Logger.ILog(`Triggering Path: ${ImportPath}`); + Logger.ILog(`Import Mode: ${ImportMode}`); + + let commandBody = { + path: ImportPath, + importMode: ImportMode + }; + + if (radarr.sendCommand('downloadedMoviesScan', commandBody)) return 1; + + return -1; +} \ No newline at end of file diff --git a/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js b/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js new file mode 100644 index 0000000..0c0bb68 --- /dev/null +++ b/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js @@ -0,0 +1,38 @@ +import { Sonarr } from 'Shared/Sonarr'; + +/** + * @name Sonarr - Trigger Manual Import 2.0 + * @uid 544e1d8f-c3b5-4d1a-8f2c-5fdf24126100 + * @description Trigger Sonarr to manually import the media, run after last file in folder moved. + * @author iBuSH + * @revision 1 + * @param {string} URL Sonarr root URL and port (e.g. http://sonarr:8989) + * @param {string} ApiKey Sonarr API Key + * @param {string} ImportPath The output path for import triggering (default Working File) + * @param {bool} UseUnmappedPath Whether to Unmap the path to the original FileFlows Server path when using nodes in different platforms (e.g. Docker and Windows) + * @param {bool} MoveMode Import mode 'copy' or 'move' (default copy) + * @output Command sent + */ +function Script(URI, ApiKey) { + URL = URL || Variables['Sonarr.Url'] || Variables['Sonarr.URI']; + ApiKey = ApiKey || Variables['Sonarr.ApiKey']; + ImportPath = ImportPath || Variables.file.FullName; + const ImportMode = MoveMode ? "move" : "copy"; + const sonarr = new Sonarr(URL, ApiKey); + + if (UseUnmappedPath) ImportPath = Flow.UnMapPath(ImportPath); + + Logger.ILog(`Triggering URL: ${URL}`); + Logger.ILog(`Triggering Path: ${ImportPath}`); + Logger.ILog(`Import Mode: ${ImportMode}`); + + + let commandBody = { + path: ImportPath, + importMode: ImportMode + }; + + if (sonarr.sendCommand('downloadedEpisodesScan', commandBody)) return 1; + + return -1; +} \ No newline at end of file From c5ded52229cd12bd475a084ef0b9c3372f8858fd Mon Sep 17 00:00:00 2001 From: Idan Bush Date: Wed, 18 Dec 2024 06:56:54 +0000 Subject: [PATCH 2/4] small fixes for arr lookups --- Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js | 6 +++--- Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js b/Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js index e3a9d0f..d1e0928 100644 --- a/Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js +++ b/Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js @@ -3,9 +3,9 @@ import { Radarr } from 'Shared/Radarr'; /** * @name Radarr - Movie Lookup * @description This script looks up a Movie from Radarr and retrieves its metadata - * @author Idan Bush + * @author iBuSH * @uid 1153e3fb-e7bb-4162-87ad-5c15cd9c081f - * @revision 2 + * @revision 3 * @param {string} URL Radarr root URL and port (e.g., http://radarr:1234) * @param {string} ApiKey API Key for Radarr * @param {bool} UseFolderName Whether to use the folder name instead of the file name for search @@ -13,7 +13,7 @@ import { Radarr } from 'Shared/Radarr'; * @output Movie not found */ function Script(URL, ApiKey) { - URL = URL || Variables['Radarr.Url']; + URL = URL || Variables['Radarr.Url'] || Variables["Radarr.URI"]; ApiKey = ApiKey || Variables['Radarr.ApiKey']; const radarr = new Radarr(URL, ApiKey); const folderPath = Variables.folder.Orig.FullName; diff --git a/Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js b/Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js index b04c23e..93d7e97 100644 --- a/Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js +++ b/Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js @@ -3,9 +3,9 @@ import { Sonarr } from 'Shared/Sonarr'; /** * @name Sonarr - TV Show Lookup * @description This script looks up a TV Show from Sonarr and retrieves its metadata - * @author Idan Bush + * @author iBuSH * @uid 9f25c573-1c3c-4a1e-8429-5f1fc69fc6d8 - * @revision 2 + * @revision 3 * @param {string} URL Sonarr root URL and port (e.g., http://sonarr:1234) * @param {string} ApiKey API Key for Sonarr * @param {bool} UseFolderName Whether to use the folder name instead of the file name for the search pattern.
If the folder starts with "Season", "Staffel", "Saison", or "Specials", the parent folder will be used. @@ -13,7 +13,7 @@ import { Sonarr } from 'Shared/Sonarr'; * @output TV Show NOT found */ function Script(URL, ApiKey) { - URL = URL || Variables['Sonarr.Url']; + URL = URL || Variables['Sonarr.Url'] || Variables['Sonarr.URI']; ApiKey = ApiKey || Variables['Sonarr.ApiKey']; const sonarr = new Sonarr(URL, ApiKey); const folderPath = Variables.folder.Orig.FullName; From f46dc9599bdcd2ffe1cedaf927e4a41f9d4d73af Mon Sep 17 00:00:00 2001 From: Idan Bush Date: Wed, 18 Dec 2024 06:59:30 +0000 Subject: [PATCH 3/4] fixed typo --- .../Flow/Applications/Radarr/Radarr - Trigger Manual Import.js | 2 +- .../Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js b/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js index 732a4ab..e2a7b92 100644 --- a/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js +++ b/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js @@ -13,7 +13,7 @@ import { Radarr } from 'Shared/Radarr'; * @param {bool} MoveMode Import mode 'copy' or 'move' (default copy) * @output Command sent */ -function Script(URI, ApiKey) { +function Script(URL, ApiKey) { URL = URL || Variables['Radarr.Url'] || Variables["Radarr.URI"]; ApiKey = ApiKey || Variables["Radarr.ApiKey"]; ImportPath = ImportPath || Variables.file.FullName; diff --git a/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js b/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js index 0c0bb68..61543e0 100644 --- a/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js +++ b/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js @@ -13,7 +13,7 @@ import { Sonarr } from 'Shared/Sonarr'; * @param {bool} MoveMode Import mode 'copy' or 'move' (default copy) * @output Command sent */ -function Script(URI, ApiKey) { +function Script(URL, ApiKey) { URL = URL || Variables['Sonarr.Url'] || Variables['Sonarr.URI']; ApiKey = ApiKey || Variables['Sonarr.ApiKey']; ImportPath = ImportPath || Variables.file.FullName; From 34c05a5865443a3e6aa028a4f8ecb9ca6bb5b030 Mon Sep 17 00:00:00 2001 From: Idan Bush Date: Thu, 19 Dec 2024 07:14:17 +0000 Subject: [PATCH 4/4] Fix parameters --- Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js | 2 +- .../Flow/Applications/Radarr/Radarr - Trigger Manual Import.js | 2 +- Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js | 2 +- .../Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js b/Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js index d1e0928..1e5ac8c 100644 --- a/Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js +++ b/Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js @@ -12,7 +12,7 @@ import { Radarr } from 'Shared/Radarr'; * @output Movie found * @output Movie not found */ -function Script(URL, ApiKey) { +function Script(URL, ApiKey, UseFolderName) { URL = URL || Variables['Radarr.Url'] || Variables["Radarr.URI"]; ApiKey = ApiKey || Variables['Radarr.ApiKey']; const radarr = new Radarr(URL, ApiKey); diff --git a/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js b/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js index e2a7b92..cfef4a3 100644 --- a/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js +++ b/Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js @@ -13,7 +13,7 @@ import { Radarr } from 'Shared/Radarr'; * @param {bool} MoveMode Import mode 'copy' or 'move' (default copy) * @output Command sent */ -function Script(URL, ApiKey) { +function Script(URL, ApiKey, ImportPath, UseUnmappedPath, MoveMode) { URL = URL || Variables['Radarr.Url'] || Variables["Radarr.URI"]; ApiKey = ApiKey || Variables["Radarr.ApiKey"]; ImportPath = ImportPath || Variables.file.FullName; diff --git a/Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js b/Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js index 93d7e97..3d70b10 100644 --- a/Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js +++ b/Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js @@ -12,7 +12,7 @@ import { Sonarr } from 'Shared/Sonarr'; * @output TV Show found * @output TV Show NOT found */ -function Script(URL, ApiKey) { +function Script(URL, ApiKey, UseFolderName) { URL = URL || Variables['Sonarr.Url'] || Variables['Sonarr.URI']; ApiKey = ApiKey || Variables['Sonarr.ApiKey']; const sonarr = new Sonarr(URL, ApiKey); diff --git a/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js b/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js index 61543e0..977ad4f 100644 --- a/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js +++ b/Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js @@ -13,7 +13,7 @@ import { Sonarr } from 'Shared/Sonarr'; * @param {bool} MoveMode Import mode 'copy' or 'move' (default copy) * @output Command sent */ -function Script(URL, ApiKey) { +function Script(URL, ApiKey, ImportPath, UseUnmappedPath, MoveMode) { URL = URL || Variables['Sonarr.Url'] || Variables['Sonarr.URI']; ApiKey = ApiKey || Variables['Sonarr.ApiKey']; ImportPath = ImportPath || Variables.file.FullName;