diff --git a/Scripts/Flow/Applications/Radarr/Radarr - Rename.js b/Scripts/Flow/Applications/Radarr/Radarr - Rename.js index 34bd211..d239283 100644 --- a/Scripts/Flow/Applications/Radarr/Radarr - Rename.js +++ b/Scripts/Flow/Applications/Radarr/Radarr - Rename.js @@ -1,10 +1,9 @@ import { Radarr } from 'Shared/Radarr'; /** - * This script will search the active queue and blocklist and research - * For use alongside this strategy https://fileflows.com/docs/guides/sonarr-radarr + * This script will send a rename command to Radarr * @author Shaun Agius * @version 1.0.0 - * @revision 1 + * @revision 2 * @param {string} URI Radarr root URI and port (e.g. http://radarr:1234) * @param {string} ApiKey API Key * @output Item renamed @@ -12,7 +11,7 @@ import { Radarr } from 'Shared/Radarr'; */ function Script(URI, ApiKey) { let radarr = new Radarr(URI, ApiKey); - let movie = radarr.getMovieByPath(Variables.folder.Name); + let movie = radarr.getMovieByPath(Variables.file.Name); if (!movie) return 2; Logger.ILog(`Renaming ${movie.title}`); diff --git a/Scripts/Flow/Applications/Sonarr/Sonarr - Rename.js b/Scripts/Flow/Applications/Sonarr/Sonarr - Rename.js index 0efaea3..15d0bf0 100644 --- a/Scripts/Flow/Applications/Sonarr/Sonarr - Rename.js +++ b/Scripts/Flow/Applications/Sonarr/Sonarr - Rename.js @@ -1,10 +1,9 @@ import { Sonarr } from 'Shared/Sonarr'; /** - * This script will search the active queue and blocklist and research - * For use alongside this strategy https://fileflows.com/docs/guides/sonarr-radarr + * This script will send a rename command to Sonarr * @author Shaun Agius * @version 1.0.0 - * @revision 1 + * @revision 2 * @param {string} URI Sonarr root URI and port (e.g. http://sonarr:1234) * @param {string} ApiKey API Key * @output Item renamed @@ -12,7 +11,9 @@ import { Sonarr } from 'Shared/Sonarr'; */ function Script(URI, ApiKey) { let sonarr = new Sonarr(URI, ApiKey); - let series = sonarr.getShowByPath(Variables.folder.FullName); + let rx = /([A-Za-z\(\) [0-9]*\[tvdbid\-[0-9]*\])/g + let folder = rx.exec(Variables.folder.FullName) + let series = sonarr.getShowByPath(folder[1]); if (!series) return 2; Logger.ILog(`Renaming ${series.title}`); diff --git a/Scripts/Shared/Radarr.js b/Scripts/Shared/Radarr.js index 6fc2025..29f471a 100644 --- a/Scripts/Shared/Radarr.js +++ b/Scripts/Shared/Radarr.js @@ -1,7 +1,9 @@ +// path: Scripts/Shared/Radarr.js + /** * Class that interacts with Radarr * @name Radarr - * @revision 2 + * @revision 3 * @minimumVersion 1.0.0.0 */ export class Radarr @@ -59,10 +61,11 @@ export class Radarr let cp = path.toLowerCase(); let movie = movies.filter(x => { - let mp = x.movieFile?.path; + let mp = x.movieFile?.relativePath.split('.')[0].toLowerCase(); if (!mp) return false; - return cp.includes(x.title.toLowerCase()); + Logger.ILog('Checking path: ' + mp); + return mp.includes(cp.split('.')[0]); }); if (movie?.length) { diff --git a/Scripts/Shared/Sonarr.js b/Scripts/Shared/Sonarr.js index 40f86b2..f57f4ec 100644 --- a/Scripts/Shared/Sonarr.js +++ b/Scripts/Shared/Sonarr.js @@ -1,7 +1,9 @@ +// path: Scripts/Shared/Sonarr.js + /** * Class that interacts with Sonarr * @name Sonarr - * @revision 2 + * @revision 3 * @minimumVersion 1.0.0.0 */ export class Sonarr @@ -83,10 +85,10 @@ export class Sonarr let cp = path.toString().toLowerCase(); let show = shows.filter(x => { - let sp = x.path; + let sp = x.path.toLowerCase(); if (!sp) return false; - return cp.includes(x.title.toLowerCase()); + return sp.includes(path); }); if (show?.length) { @@ -146,10 +148,10 @@ export class Sonarr let cp = path.toString().toLowerCase(); let showfile = files.filter(x => { - let sp = x.path; + let sp = x.path.toLowerCase(); if (!sp) return false; - return cp.includes(x.title.toLowerCase()); + return sp.includes(path); }); if (showfile?.length) {