From f87bad25496025479cc212773c192d9863dcc1b0 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Tue, 28 Nov 2023 05:20:38 +0000 Subject: [PATCH 1/2] Use original library file --- .../tools/notifyRadarrOrSonarr/1.0.0/index.js | 24 ++++++++++--------- .../tools/notifyRadarrOrSonarr/1.0.0/index.ts | 7 +++--- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.js index 9856ecd..5c77085 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.js @@ -96,16 +96,17 @@ var details = function () { return ({ }); }; exports.details = details; var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () { - var lib, _a, arr, arr_api_key, arr_host, meta, arrHost, headers, requestConfig, res, movieId, requestConfig2, requestConfig, res, seriesId, requestConfig2; - return __generator(this, function (_b) { - switch (_b.label) { + var lib, _a, arr, arr_api_key, arr_host, fileName, arrHost, headers, requestConfig, res, movieId, requestConfig2, requestConfig, res, seriesId, requestConfig2; + var _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { case 0: lib = require('../../../../../methods/lib')(); // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign args.inputs = lib.loadDefaultValues(args.inputs, details); _a = args.inputs, arr = _a.arr, arr_api_key = _a.arr_api_key; arr_host = String(args.inputs.arr_host).trim(); - meta = args.inputFileObj.meta; + fileName = ((_c = (_b = args.originalLibraryFile) === null || _b === void 0 ? void 0 : _b.meta) === null || _c === void 0 ? void 0 : _c.FileName) || ''; arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; headers = { 'Content-Type': 'application/json', @@ -117,12 +118,13 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function args.jobLog('Refreshing Radarr...'); requestConfig = { method: 'get', - url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent((meta === null || meta === void 0 ? void 0 : meta.FileName) || '')), + url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent(fileName)), headers: headers, }; return [4 /*yield*/, args.deps.axios(requestConfig)]; case 1: - res = _b.sent(); + res = _d.sent(); + console.log(res.data); movieId = res.data.movie.movieFile.movieId; requestConfig2 = { method: 'post', @@ -135,7 +137,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function }; return [4 /*yield*/, args.deps.axios(requestConfig2)]; case 2: - _b.sent(); + _d.sent(); args.jobLog("\u2714 Refreshed movie ".concat(movieId, " in Radarr.")); return [3 /*break*/, 7]; case 3: @@ -143,12 +145,12 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function args.jobLog('Refreshing Sonarr...'); requestConfig = { method: 'get', - url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent((meta === null || meta === void 0 ? void 0 : meta.FileName) || '')), + url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent(fileName)), headers: headers, }; return [4 /*yield*/, args.deps.axios(requestConfig)]; case 4: - res = _b.sent(); + res = _d.sent(); seriesId = res.data.series.id; requestConfig2 = { method: 'post', @@ -161,12 +163,12 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function }; return [4 /*yield*/, args.deps.axios(requestConfig2)]; case 5: - _b.sent(); + _d.sent(); args.jobLog("\u2714 Refreshed series ".concat(seriesId, " in Sonarr.")); return [3 /*break*/, 7]; case 6: args.jobLog('No arr specified in plugin inputs.'); - _b.label = 7; + _d.label = 7; case 7: return [2 /*return*/, { outputFileObj: args.inputFileObj, outputNumber: 1, diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.ts index 2d9f75b..620ccdc 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.ts @@ -70,7 +70,8 @@ const plugin = async (args: IpluginInputArgs): Promise => { const { arr, arr_api_key } = args.inputs; const arr_host = String(args.inputs.arr_host).trim(); - const { meta } = args.inputFileObj; + const fileName = args.originalLibraryFile?.meta?.FileName || ''; + const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; const headers = { @@ -86,7 +87,7 @@ const plugin = async (args: IpluginInputArgs): Promise => { const requestConfig = { method: 'get', - url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(meta?.FileName || '')}`, + url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(fileName)}`, headers, }; @@ -111,7 +112,7 @@ const plugin = async (args: IpluginInputArgs): Promise => { const requestConfig = { method: 'get', - url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(meta?.FileName || '')}`, + url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(fileName)}`, headers, }; From 0a6aa3643701e224e0da6f47bc45ab7dfc1c8833 Mon Sep 17 00:00:00 2001 From: HaveAGitGat Date: Tue, 28 Nov 2023 05:22:34 +0000 Subject: [PATCH 2/2] Apply auto-build changes --- .../tools/notifyRadarrOrSonarr/1.0.0/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.js index 5c77085..88a827f 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/1.0.0/index.js @@ -124,7 +124,6 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function return [4 /*yield*/, args.deps.axios(requestConfig)]; case 1: res = _d.sent(); - console.log(res.data); movieId = res.data.movie.movieFile.movieId; requestConfig2 = { method: 'post',