Skip to content

Commit

Permalink
Merge pull request #73 from BuSHari/feature/add_new_arr_import_scripts
Browse files Browse the repository at this point in the history
Feature/add new arr import scripts
  • Loading branch information
revenz authored Dec 19, 2024
2 parents 984c342 + 34c05a5 commit 2e7a67a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Scripts/Flow/Applications/Radarr/Radarr - Movie Lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ 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
* @output Movie found
* @output Movie not found
*/
function Script(URL, ApiKey) {
URL = URL || Variables['Radarr.Url'];
function Script(URL, ApiKey, UseFolderName) {
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;
Expand Down
37 changes: 37 additions & 0 deletions Scripts/Flow/Applications/Radarr/Radarr - Trigger Manual Import.js
Original file line number Diff line number Diff line change
@@ -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(URL, ApiKey, ImportPath, UseUnmappedPath, MoveMode) {
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;
}
8 changes: 4 additions & 4 deletions Scripts/Flow/Applications/Sonarr/Sonarr - TV Show Lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ 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.<br>If the folder starts with "Season", "Staffel", "Saison", or "Specials", the parent folder will be used.
* @output TV Show found
* @output TV Show NOT found
*/
function Script(URL, ApiKey) {
URL = URL || Variables['Sonarr.Url'];
function Script(URL, ApiKey, UseFolderName) {
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;
Expand Down
38 changes: 38 additions & 0 deletions Scripts/Flow/Applications/Sonarr/Sonarr - Trigger Manual Import.js
Original file line number Diff line number Diff line change
@@ -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(URL, ApiKey, ImportPath, UseUnmappedPath, MoveMode) {
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;
}

0 comments on commit 2e7a67a

Please sign in to comment.