diff --git a/Scripts/Flow/Applications/Radarr/Radarr - Rename.js b/Scripts/Flow/Applications/Radarr/Radarr - Rename.js index 5a149a1..562aeb2 100644 --- a/Scripts/Flow/Applications/Radarr/Radarr - Rename.js +++ b/Scripts/Flow/Applications/Radarr/Radarr - Rename.js @@ -3,7 +3,7 @@ import { Radarr } from 'Shared/Radarr'; * This script will send a rename command to Radarr * @author Shaun Agius * @version 1.0.0 - * @revision 3 + * @revision 4 * @param {string} URI Radarr root URI and port (e.g. http://radarr:1234) * @param {string} ApiKey API Key * @output Item renamed @@ -15,8 +15,9 @@ function Script(URI, ApiKey) { if (!movie) return 2; Logger.ILog(`Renaming ${movie.title}`); - let endpoint = `rename?movieId=${movie.id}`; - let response = radarr.fetchJson(endpoint); + let endpoint = `rename`; + let queryParmeters = `movieId=${movie.id}` + let response = radarr.fetchJson(endpoint, queryParmeters); Logger.ILog(`Response ${response}`); return 1; } \ No newline at end of file diff --git a/Scripts/Flow/Applications/Sonarr/Sonarr - Rename.js b/Scripts/Flow/Applications/Sonarr/Sonarr - Rename.js index bb3b3d0..6764ea2 100644 --- a/Scripts/Flow/Applications/Sonarr/Sonarr - Rename.js +++ b/Scripts/Flow/Applications/Sonarr/Sonarr - Rename.js @@ -3,7 +3,7 @@ import { Sonarr } from 'Shared/Sonarr'; * This script will send a rename command to Sonarr * @author Shaun Agius * @version 1.0.0 - * @revision 3 + * @revision 4 * @param {string} URI Sonarr root URI and port (e.g. http://sonarr:1234) * @param {string} ApiKey API Key * @output Item renamed @@ -33,8 +33,9 @@ function Script(URI, ApiKey) { if (!series) return 2; Logger.ILog(`Renaming ${series.title}`); - let endpoint = `rename?seriesId=${series.id}`; - let response = sonarr.fetchJson(endpoint); + let endpoint = `rename`; + let queryParmeters = `seriesId=${series.id}` + let response = sonarr.fetchJson(endpoint, queryParmeters); Logger.ILog(`Response ${response}`); return 1; } \ No newline at end of file diff --git a/Scripts/Shared/Radarr.js b/Scripts/Shared/Radarr.js index 07bb137..1f54c5a 100644 --- a/Scripts/Shared/Radarr.js +++ b/Scripts/Shared/Radarr.js @@ -3,7 +3,7 @@ /** * Class that interacts with Radarr * @name Radarr - * @revision 4 + * @revision 5 * @minimumVersion 1.0.0.0 */ export class Radarr @@ -21,22 +21,25 @@ export class Radarr MissingVariable('Radarr.ApiKey'); } - getUrl(endpoint) + getUrl(endpoint, queryParmeters) { let url = '' + this.URL; if (url.endsWith('/') === false) url += '/'; - return `${url}api/v3/${endpoint}?apikey=${this.ApiKey}`; + url = `${url}api/v3/${endpoint}?apikey=${this.ApiKey}`; + if(queryParmeters) + url += '&' + queryParmeters; + return url; } - fetchJson(endpoint) + fetchJson(endpoint, queryParmeters) { - let url = this.getUrl(endpoint); + let url = this.getUrl(endpoint, queryParmeters); let response = http.GetAsync(url).Result; let body = response.Content.ReadAsStringAsync().Result; if (!response.IsSuccessStatusCode) { - Logger.WLog('Unable to fetch: ' + endpoint + '\n' + body); + Logger.WLog('Unable to fetch: ' + url + '\n' + body); return null; } return JSON.parse(body);