From 3511cc2276528eea9564b2dc569e3e714c21a47b Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 29 Mar 2024 09:15:55 +0100 Subject: [PATCH] Addded lookup url for Sonarr --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 11 ++++++----- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 8f2f94c..62701de 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -104,7 +104,7 @@ var details = function () { return ({ ], }); }; exports.details = details; -var getId = function (args, arrHost, headers, fileName, refreshType) { return __awaiter(void 0, void 0, void 0, function () { +var getId = function (args, arr, arrHost, headers, fileName, refreshType) { return __awaiter(void 0, void 0, void 0, function () { var imdbId, id, _a, _b, _c, _d; var _e, _f, _g, _h; return __generator(this, function (_j) { @@ -115,7 +115,7 @@ var getId = function (args, arrHost, headers, fileName, refreshType) { return __ _b = Number; return [4 /*yield*/, args.deps.axios({ method: 'get', - url: "".concat(arrHost, "/api/v3/movie/lookup?term=imdb:").concat(imdbId), + url: "".concat(arrHost, "/api/v3/").concat(arr === 'radarr' ? 'movie' : 'serie', "/lookup?term=imdb:").concat(imdbId), headers: headers, })]; case 1: @@ -126,6 +126,7 @@ var getId = function (args, arrHost, headers, fileName, refreshType) { return __ _j.label = 3; case 3: id = _a; + args.jobLog("".concat(refreshType.content, " ").concat(id !== -1 ? "".concat(id, " found") : 'not found', " for imdb '").concat(imdbId, "'")); if (!(id === -1)) return [3 /*break*/, 5]; _d = (_c = refreshType.delegates).getIdFromParseResponse; return [4 /*yield*/, args.deps.axios({ @@ -137,7 +138,7 @@ var getId = function (args, arrHost, headers, fileName, refreshType) { return __ id = _d.apply(_c, [(_j.sent())]); _j.label = 5; case 5: - args.jobLog("".concat(refreshType.content, " ").concat(id !== -1 ? "".concat(id, " found") : 'not found', " for '").concat(fileName, "', imdb '").concat(imdbId, "'")); + args.jobLog("".concat(refreshType.content, " ").concat(id !== -1 ? "".concat(id, " found") : 'not found', " for '").concat((0, fileUtils_1.getFileName)(fileName), "'")); return [2 /*return*/, id]; } }); @@ -184,11 +185,11 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function }; args.jobLog('Going to force scan'); args.jobLog("Refreshing ".concat(refreshType.appName, "...")); - return [4 /*yield*/, getId(args, arrHost, headers, fileNames.originalFileName, refreshType)]; + return [4 /*yield*/, getId(args, arr, arrHost, headers, fileNames.originalFileName, refreshType)]; case 1: id = _g.sent(); if (!(id === -1 && fileNames.currentFileName !== fileNames.originalFileName)) return [3 /*break*/, 3]; - return [4 /*yield*/, getId(args, arrHost, headers, fileNames.currentFileName, refreshType)]; + return [4 /*yield*/, getId(args, arr, arrHost, headers, fileNames.currentFileName, refreshType)]; case 2: id = _g.sent(); _g.label = 3; diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 4f0c071..e7e219a 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -91,6 +91,7 @@ interface IRefreshType { const getId = async ( args: IpluginInputArgs, + arr: string, arrHost: string, headers: IHTTPHeaders, fileName: string, refreshType: IRefreshType, @@ -101,11 +102,12 @@ const getId = async ( ? Number( (await args.deps.axios({ method: 'get', - url: `${arrHost}/api/v3/movie/lookup?term=imdb:${imdbId}`, + url: `${arrHost}/api/v3/${arr === 'radarr' ? 'movie' : 'serie'}/lookup?term=imdb:${imdbId}`, headers, })).data?.id ?? -1, ) : -1; + args.jobLog(`${refreshType.content} ${id !== -1 ? `${id} found` : 'not found'} for imdb '${imdbId}'`); if (id === -1) { id = refreshType.delegates.getIdFromParseResponse( (await args.deps.axios({ @@ -115,7 +117,7 @@ const getId = async ( })), ); } - args.jobLog(`${refreshType.content} ${id !== -1 ? `${id} found` : 'not found'} for '${fileName}', imdb '${imdbId}'`); + args.jobLog(`${refreshType.content} ${id !== -1 ? `${id} found` : 'not found'} for '${getFileName(fileName)}'`); return id; }; @@ -164,10 +166,10 @@ const plugin = async (args: IpluginInputArgs): Promise => { args.jobLog('Going to force scan'); args.jobLog(`Refreshing ${refreshType.appName}...`); - let id = await getId(args, arrHost, headers, fileNames.originalFileName, refreshType); + let id = await getId(args, arr, arrHost, headers, fileNames.originalFileName, refreshType); // Useful in some edge cases if (id === -1 && fileNames.currentFileName !== fileNames.originalFileName) { - id = await getId(args, arrHost, headers, fileNames.currentFileName, refreshType); + id = await getId(args, arr, arrHost, headers, fileNames.currentFileName, refreshType); } // Checking that the file has been found