From e581a90864e4fa13bf56e144fa76c9e3d85f337e Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Sun, 25 Feb 2024 17:38:18 +0100 Subject: [PATCH 01/18] Refactoring + more robust + added safeties and a new output for file not found --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 210 ++++++++++++++++++ .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 189 ++++++++++++++++ 2 files changed, 399 insertions(+) create mode 100644 FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js create mode 100644 FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js new file mode 100644 index 0000000..6ede5f4 --- /dev/null +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -0,0 +1,210 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.plugin = exports.details = void 0; +var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils"); +var details = function () { return ({ + name: 'Notify Radarr or Sonarr', + description: 'Notify Radarr or Sonarr to refresh after file change', + style: { + borderColor: 'green', + }, + tags: '', + isStartPlugin: false, + pType: '', + requiresVersion: '2.11.01', + sidebarPosition: -1, + icon: 'faBell', + inputs: [ + { + label: 'Arr', + name: 'arr', + type: 'string', + defaultValue: 'radarr', + inputUI: { + type: 'dropdown', + options: ['radarr', 'sonarr'], + }, + tooltip: 'Specify which arr to use', + }, + { + label: 'Arr API Key', + name: 'arr_api_key', + type: 'string', + defaultValue: '', + inputUI: { + type: 'text', + }, + tooltip: 'Input your arr api key here', + }, + { + label: 'Arr Host', + name: 'arr_host', + type: 'string', + defaultValue: 'http://192.168.1.1:7878', + inputUI: { + type: 'text', + }, + tooltip: 'Input your arr host here.' + + '\\nExample:\\n' + + 'http://192.168.1.1:7878\\n' + + 'http://192.168.1.1:8989\\n' + + 'https://radarr.domain.com\\n' + + 'https://sonarr.domain.com\\n', + }, + ], + outputs: [ + { + number: 1, + tooltip: 'Radarr or Sonnar notified', + }, + { + number: 2, + tooltip: 'Radarr or Sonnar do not know this file', + } + ], +}); }; +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, arrHost, fileNames, refresh, refreshTypes, refreshed; + var _b, _c, _d, _e; + return __generator(this, function (_f) { + switch (_f.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(); + arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; + fileNames = { + originalFileName: (0, fileUtils_1.getFileName)((_c = (_b = args.originalLibraryFile) === null || _b === void 0 ? void 0 : _b._id) !== null && _c !== void 0 ? _c : ''), + currentFileName: (0, fileUtils_1.getFileName)((_e = (_d = args.inputFileObj) === null || _d === void 0 ? void 0 : _d._id) !== null && _e !== void 0 ? _e : '') + }; + refresh = function (refreshType) { return __awaiter(void 0, void 0, void 0, function () { + var refreshed, headers, getId, fileName, id, refreshResquestConfig; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + args.jobLog('Going to force scan'); + args.jobLog("Refreshing ".concat(refreshType.appName, "...")); + refreshed = false; + headers = { + 'Content-Type': 'application/json', + 'X-Api-Key': arr_api_key, + Accept: 'application/json', + }; + getId = function (fileName) { return __awaiter(void 0, void 0, void 0, function () { + var parseRequestConfig, parseRequestResult, id; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + parseRequestConfig = { + method: 'get', + url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent(fileName)), + headers: headers, + }; + return [4 /*yield*/, args.deps.axios(parseRequestConfig)]; + case 1: + parseRequestResult = _a.sent(); + id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult); + args.jobLog(id !== -1 ? + "Found ".concat(refreshType.contentName, " ").concat(id, " with a file named '").concat(fileName, "'") + : "Didn't find ".concat(refreshType.contentName, " with a file named '").concat(fileName, "' in ").concat(arrHost, ".")); + return [2 /*return*/, id]; + } + }); + }); }; + fileName = fileNames.originalFileName; + return [4 /*yield*/, getId(fileName)]; + case 1: + id = _a.sent(); + if (!(id == -1 && fileNames.currentFileName !== fileNames.originalFileName)) return [3 /*break*/, 3]; + fileName = fileNames.currentFileName; + return [4 /*yield*/, getId(fileName)]; + case 2: + id = _a.sent(); + _a.label = 3; + case 3: + if (!(id !== -1)) return [3 /*break*/, 5]; + refreshResquestConfig = { + method: 'post', + url: "".concat(arrHost, "/api/v3/command"), + headers: headers, + data: refreshType.delegates.buildRefreshResquestData(id) + }; + return [4 /*yield*/, args.deps.axios(refreshResquestConfig)]; + case 4: + _a.sent(); + refreshed = true; + args.jobLog("\u2714 Refreshed ".concat(refreshType.contentName, " ").concat(id, " in ").concat(refreshType.appName, ".")); + _a.label = 5; + case 5: return [2 /*return*/, refreshed]; + } + }); + }); }; + refreshTypes = { + radarr: { + appName: 'Radarr', + contentName: 'movie', + delegates: { + getIdFromParseRequestResult: function (parseRequestResult) { var _a, _b, _c, _d; return Number((_d = (_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.movie) === null || _b === void 0 ? void 0 : _b.movieFile) === null || _c === void 0 ? void 0 : _c.movieId) !== null && _d !== void 0 ? _d : -1); }, + buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }); } + } + }, + sonarr: { + appName: 'Sonarr', + contentName: 'serie', + delegates: { + getIdFromParseRequestResult: function (parseRequestResult) { var _a, _b, _c; return Number((_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1); }, + buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshSeries', seriesId: id }); } + }, + }, + }; + return [4 /*yield*/, refresh(arr === 'radarr' ? refreshTypes.radarr : refreshTypes.sonarr)]; + case 1: + refreshed = _f.sent(); + return [2 /*return*/, { + outputFileObj: args.inputFileObj, + outputNumber: refreshed ? 1 : 2, + variables: args.variables, + }]; + } + }); +}); }; +exports.plugin = plugin; diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts new file mode 100644 index 0000000..864d6e5 --- /dev/null +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -0,0 +1,189 @@ +import { get } from 'http'; +import { + getContainer, getFileAbosluteDir, getFileName, +} from '../../../../FlowHelpers/1.0.0/fileUtils'; +import { + IpluginDetails, + IpluginInputArgs, + IpluginOutputArgs, +} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces'; + +const details = (): IpluginDetails => ({ + name: 'Notify Radarr or Sonarr', + description: 'Notify Radarr or Sonarr to refresh after file change', + style: { + borderColor: 'green', + }, + tags: '', + isStartPlugin: false, + pType: '', + requiresVersion: '2.11.01', + sidebarPosition: -1, + icon: 'faBell', + inputs: [ + { + label: 'Arr', + name: 'arr', + type: 'string', + defaultValue: 'radarr', + inputUI: { + type: 'dropdown', + options: ['radarr', 'sonarr'], + }, + tooltip: 'Specify which arr to use', + }, + { + label: 'Arr API Key', + name: 'arr_api_key', + type: 'string', + defaultValue: '', + inputUI: { + type: 'text', + }, + tooltip: 'Input your arr api key here', + }, + { + label: 'Arr Host', + name: 'arr_host', + type: 'string', + defaultValue: 'http://192.168.1.1:7878', + inputUI: { + type: 'text', + }, + tooltip: 'Input your arr host here.' + + '\\nExample:\\n' + + 'http://192.168.1.1:7878\\n' + + 'http://192.168.1.1:8989\\n' + + 'https://radarr.domain.com\\n' + + 'https://sonarr.domain.com\\n', + }, + ], + outputs: [ + { + number: 1, + tooltip: 'Radarr or Sonnar notified', + }, + { + number: 2, + tooltip: 'Radarr or Sonnar do not know this file', + } + ], +}); + +interface IFileNames { + originalFileName: string, + currentFileName : string +} +interface IRefreshDelegates { + getIdFromParseRequestResult: (parseRequestResult: any) => number, + buildRefreshResquestData: (id: number) => string +} +interface IRefreshType { + appName: string, + contentName: string, + delegates: IRefreshDelegates +} +interface IRefreshTypes { + radarr: IRefreshType, + sonarr: IRefreshType +} + +const plugin = async (args: IpluginInputArgs): Promise => { + const lib = require('../../../../../methods/lib')(); + // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign + args.inputs = lib.loadDefaultValues(args.inputs, details); + + const { arr, arr_api_key } = args.inputs; + const arr_host = String(args.inputs.arr_host).trim(); + const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; + const fileNames : IFileNames = { + originalFileName : getFileName(args.originalLibraryFile?._id ?? ''), + currentFileName: getFileName(args.inputFileObj?._id ?? '') + }; + + const refresh = async (refreshType: IRefreshType) + : Promise => { + args.jobLog('Going to force scan'); + args.jobLog(`Refreshing ${refreshType.appName}...`); + + let refreshed = false; + const headers = { + 'Content-Type': 'application/json', + 'X-Api-Key': arr_api_key, + Accept: 'application/json', + }; + + const getId = async (fileName : string) + : Promise => { + // Using parse endpoint to get the movie/serie's id. + const parseRequestConfig = { + method: 'get', + url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(fileName)}`, + headers, + }; + const parseRequestResult = await args.deps.axios(parseRequestConfig); + const id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult); + args.jobLog(id !== -1 ? + `Found ${refreshType.contentName} ${id} with a file named '${fileName}'` + : `Didn't find ${refreshType.contentName} with a file named '${fileName}' in ${arrHost}.`); + return id; + } + + let fileName = fileNames.originalFileName; + let id = await getId(fileName); + // In case there has been a name change and the arr app already noticed it. + if(id == -1 && fileNames.currentFileName !== fileNames.originalFileName) { + fileName = fileNames.currentFileName; + id = await getId(fileName); + } + + // Checking that the file has been found. + if (id !== -1) { + // Using refresh command endpoint to force rescan. + const refreshResquestConfig = { + method: 'post', + url: `${arrHost}/api/v3/command`, + headers, + data: refreshType.delegates.buildRefreshResquestData(id) + }; + await args.deps.axios(refreshResquestConfig); + + refreshed = true; + args.jobLog(`✔ Refreshed ${refreshType.contentName} ${id} in ${refreshType.appName}.`); + } + + return refreshed; + }; + + const refreshTypes: IRefreshTypes = { + radarr: { + appName: 'Radarr', + contentName: 'movie', + delegates: { + getIdFromParseRequestResult: (parseRequestResult) => Number(parseRequestResult.data?.movie?.movieFile?.movieId ?? -1), + buildRefreshResquestData: id => JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }) + } + }, + sonarr: { + appName: 'Sonarr', + contentName: 'serie', + delegates: { + getIdFromParseRequestResult: (parseRequestResult) => Number(parseRequestResult.data?.series?.id ?? -1), + buildRefreshResquestData: id => JSON.stringify({ name: 'RefreshSeries', seriesId: id }) + }, + }, + } + + const refreshed = await refresh(arr === 'radarr' ? refreshTypes.radarr : refreshTypes.sonarr); + + return { + outputFileObj: args.inputFileObj, + outputNumber: refreshed ? 1 : 2, + variables: args.variables, + }; +}; + +export { + details, + plugin, +}; \ No newline at end of file From 142134a19283efdc69a19218da1c0bddb19701be Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 22 Mar 2024 22:28:51 +0100 Subject: [PATCH 02/18] Fix eslint warnings and errors --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 16 +++---- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 43 ++++++++++--------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 6ede5f4..2fd9922 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -114,7 +114,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; fileNames = { originalFileName: (0, fileUtils_1.getFileName)((_c = (_b = args.originalLibraryFile) === null || _b === void 0 ? void 0 : _b._id) !== null && _c !== void 0 ? _c : ''), - currentFileName: (0, fileUtils_1.getFileName)((_e = (_d = args.inputFileObj) === null || _d === void 0 ? void 0 : _d._id) !== null && _e !== void 0 ? _e : '') + currentFileName: (0, fileUtils_1.getFileName)((_e = (_d = args.inputFileObj) === null || _d === void 0 ? void 0 : _d._id) !== null && _e !== void 0 ? _e : ''), }; refresh = function (refreshType) { return __awaiter(void 0, void 0, void 0, function () { var refreshed, headers, getId, fileName, id, refreshResquestConfig; @@ -143,8 +143,8 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function case 1: parseRequestResult = _a.sent(); id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult); - args.jobLog(id !== -1 ? - "Found ".concat(refreshType.contentName, " ").concat(id, " with a file named '").concat(fileName, "'") + args.jobLog(id !== -1 + ? "Found ".concat(refreshType.contentName, " ").concat(id, " with a file named '").concat(fileName, "'") : "Didn't find ".concat(refreshType.contentName, " with a file named '").concat(fileName, "' in ").concat(arrHost, ".")); return [2 /*return*/, id]; } @@ -154,7 +154,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function return [4 /*yield*/, getId(fileName)]; case 1: id = _a.sent(); - if (!(id == -1 && fileNames.currentFileName !== fileNames.originalFileName)) return [3 /*break*/, 3]; + if (!(id === -1 && fileNames.currentFileName !== fileNames.originalFileName)) return [3 /*break*/, 3]; fileName = fileNames.currentFileName; return [4 /*yield*/, getId(fileName)]; case 2: @@ -166,7 +166,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function method: 'post', url: "".concat(arrHost, "/api/v3/command"), headers: headers, - data: refreshType.delegates.buildRefreshResquestData(id) + data: refreshType.delegates.buildRefreshResquestData(id), }; return [4 /*yield*/, args.deps.axios(refreshResquestConfig)]; case 4: @@ -184,15 +184,15 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function contentName: 'movie', delegates: { getIdFromParseRequestResult: function (parseRequestResult) { var _a, _b, _c, _d; return Number((_d = (_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.movie) === null || _b === void 0 ? void 0 : _b.movieFile) === null || _c === void 0 ? void 0 : _c.movieId) !== null && _d !== void 0 ? _d : -1); }, - buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }); } - } + buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }); }, + }, }, sonarr: { appName: 'Sonarr', contentName: 'serie', delegates: { getIdFromParseRequestResult: function (parseRequestResult) { var _a, _b, _c; return Number((_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1); }, - buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshSeries', seriesId: id }); } + buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshSeries', seriesId: id }); }, }, }, }; diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 864d6e5..3027f10 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -1,7 +1,4 @@ -import { get } from 'http'; -import { - getContainer, getFileAbosluteDir, getFileName, -} from '../../../../FlowHelpers/1.0.0/fileUtils'; +import { getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils'; import { IpluginDetails, IpluginInputArgs, @@ -72,7 +69,7 @@ const details = (): IpluginDetails => ({ interface IFileNames { originalFileName: string, - currentFileName : string + currentFileName: string } interface IRefreshDelegates { getIdFromParseRequestResult: (parseRequestResult: any) => number, @@ -96,9 +93,9 @@ const plugin = async (args: IpluginInputArgs): Promise => { const { arr, arr_api_key } = args.inputs; const arr_host = String(args.inputs.arr_host).trim(); const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; - const fileNames : IFileNames = { - originalFileName : getFileName(args.originalLibraryFile?._id ?? ''), - currentFileName: getFileName(args.inputFileObj?._id ?? '') + const fileNames: IFileNames = { + originalFileName: getFileName(args.originalLibraryFile?._id ?? ''), + currentFileName: getFileName(args.inputFileObj?._id ?? ''), }; const refresh = async (refreshType: IRefreshType) @@ -113,8 +110,8 @@ const plugin = async (args: IpluginInputArgs): Promise => { Accept: 'application/json', }; - const getId = async (fileName : string) - : Promise => { + const getId = async (fileName: string) + : Promise => { // Using parse endpoint to get the movie/serie's id. const parseRequestConfig = { method: 'get', @@ -123,16 +120,16 @@ const plugin = async (args: IpluginInputArgs): Promise => { }; const parseRequestResult = await args.deps.axios(parseRequestConfig); const id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult); - args.jobLog(id !== -1 ? - `Found ${refreshType.contentName} ${id} with a file named '${fileName}'` + args.jobLog(id !== -1 + ? `Found ${refreshType.contentName} ${id} with a file named '${fileName}'` : `Didn't find ${refreshType.contentName} with a file named '${fileName}' in ${arrHost}.`); return id; - } + }; let fileName = fileNames.originalFileName; let id = await getId(fileName); // In case there has been a name change and the arr app already noticed it. - if(id == -1 && fileNames.currentFileName !== fileNames.originalFileName) { + if (id === -1 && fileNames.currentFileName !== fileNames.originalFileName) { fileName = fileNames.currentFileName; id = await getId(fileName); } @@ -144,7 +141,7 @@ const plugin = async (args: IpluginInputArgs): Promise => { method: 'post', url: `${arrHost}/api/v3/command`, headers, - data: refreshType.delegates.buildRefreshResquestData(id) + data: refreshType.delegates.buildRefreshResquestData(id), }; await args.deps.axios(refreshResquestConfig); @@ -160,16 +157,20 @@ const plugin = async (args: IpluginInputArgs): Promise => { appName: 'Radarr', contentName: 'movie', delegates: { - getIdFromParseRequestResult: (parseRequestResult) => Number(parseRequestResult.data?.movie?.movieFile?.movieId ?? -1), - buildRefreshResquestData: id => JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }) - } + getIdFromParseRequestResult: + (parseRequestResult) => Number(parseRequestResult.data?.movie?.movieFile?.movieId ?? -1), + buildRefreshResquestData: + (id) => JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }), + }, }, sonarr: { appName: 'Sonarr', contentName: 'serie', delegates: { - getIdFromParseRequestResult: (parseRequestResult) => Number(parseRequestResult.data?.series?.id ?? -1), - buildRefreshResquestData: id => JSON.stringify({ name: 'RefreshSeries', seriesId: id }) + getIdFromParseRequestResult: + (parseRequestResult) => Number(parseRequestResult.data?.series?.id ?? -1), + buildRefreshResquestData: + (id) => JSON.stringify({ name: 'RefreshSeries', seriesId: id }), }, }, } @@ -186,4 +187,4 @@ const plugin = async (args: IpluginInputArgs): Promise => { export { details, plugin, -}; \ No newline at end of file +}; From 65e6d5b3d9420cc39db51485fc1d009c49744292 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 22 Mar 2024 22:38:36 +0100 Subject: [PATCH 03/18] More eslint fixes --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 2 +- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 2fd9922..4c3e840 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -96,7 +96,7 @@ var details = function () { return ({ { number: 2, tooltip: 'Radarr or Sonnar do not know this file', - } + }, ], }); }; exports.details = details; diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 3027f10..2420758 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -63,7 +63,7 @@ const details = (): IpluginDetails => ({ { number: 2, tooltip: 'Radarr or Sonnar do not know this file', - } + }, ], }); @@ -173,7 +173,7 @@ const plugin = async (args: IpluginInputArgs): Promise => { (id) => JSON.stringify({ name: 'RefreshSeries', seriesId: id }), }, }, - } + }; const refreshed = await refresh(arr === 'radarr' ? refreshTypes.radarr : refreshTypes.sonarr); From 3b577fe73b1ebb6c50150735a8c7621422ea3fdb Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 22 Mar 2024 23:49:29 +0100 Subject: [PATCH 04/18] Replaced any by inferred interface --- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 2420758..eb78346 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -71,8 +71,20 @@ interface IFileNames { originalFileName: string, currentFileName: string } +interface IParsedRequestResult { + data: { + movie: { + movieFile: { + movieId: number + } + } + series: { + id: number + } + } +} interface IRefreshDelegates { - getIdFromParseRequestResult: (parseRequestResult: any) => number, + getIdFromParseRequestResult: (parseRequestResult: IParsedRequestResult) => number, buildRefreshResquestData: (id: number) => string } interface IRefreshType { From cf974234eac1dce85e7375ee718018361270fea9 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Sat, 23 Mar 2024 01:03:09 +0100 Subject: [PATCH 05/18] Commas added where missing --- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index eb78346..a7a0dd0 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -73,15 +73,15 @@ interface IFileNames { } interface IParsedRequestResult { data: { - movie: { + movie?: { movieFile: { movieId: number - } - } - series: { + }, + }, + series?: { id: number - } - } + }, + }, } interface IRefreshDelegates { getIdFromParseRequestResult: (parseRequestResult: IParsedRequestResult) => number, From e5638dda65c8be181126196b335d9ba9ea4546ca Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 29 Mar 2024 00:08:00 +0100 Subject: [PATCH 06/18] Added imdbid detection from file name to get the movie or serie id --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 180 +++++++++--------- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 173 ++++++++--------- 2 files changed, 178 insertions(+), 175 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 4c3e840..458a5d4 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -35,8 +35,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.plugin = exports.details = void 0; +var path_1 = __importDefault(require("path")); var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils"); var details = function () { return ({ name: 'Notify Radarr or Sonarr', @@ -100,110 +104,114 @@ 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 imdbId, id, _a, _b, _c, _d; + var _e, _f, _g, _h; + return __generator(this, function (_j) { + switch (_j.label) { + case 0: + imdbId = (_f = (_e = /\b(tt|nm|co|ev|ch|ni)\d{7,10}\b/i.exec(fileName)) === null || _e === void 0 ? void 0 : _e.at(0)) !== null && _f !== void 0 ? _f : ''; + if (!(imdbId !== '')) return [3 /*break*/, 2]; + _b = Number; + return [4 /*yield*/, args.deps.axios({ + method: 'get', + url: "".concat(arrHost, "/api/v3/movie/lookup?terms=imdb:").concat(imdbId), + headers: headers, + })]; + case 1: + _a = _b.apply(void 0, [(_h = (_g = (_j.sent()).data) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : -1]); + return [3 /*break*/, 3]; + case 2: + _a = -1; + _j.label = 3; + case 3: + id = _a; + if (!(id === -1)) return [3 /*break*/, 5]; + _d = (_c = refreshType.delegates).getIdFromParseResponse; + return [4 /*yield*/, args.deps.axios({ + method: 'get', + url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent((0, fileUtils_1.getFileName)(fileName))), + headers: headers, + })]; + case 4: + 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, "'")); + return [2 /*return*/, id]; + } + }); +}); }; var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () { - var lib, _a, arr, arr_api_key, arr_host, arrHost, fileNames, refresh, refreshTypes, refreshed; - var _b, _c, _d, _e; - return __generator(this, function (_f) { - switch (_f.label) { + var lib, refreshed, arr, arr_host, arrHost, absoluteFileDir, fileNames, headers, refreshType, id; + var _a, _b, _c, _d, _e, _f; + return __generator(this, function (_g) { + switch (_g.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; + refreshed = false; + arr = String(args.inputs.arr); arr_host = String(args.inputs.arr_host).trim(); arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; + absoluteFileDir = (0, fileUtils_1.getFileAbosluteDir)((_b = (_a = args.originalLibraryFile) === null || _a === void 0 ? void 0 : _a._id) !== null && _b !== void 0 ? _b : ''); fileNames = { - originalFileName: (0, fileUtils_1.getFileName)((_c = (_b = args.originalLibraryFile) === null || _b === void 0 ? void 0 : _b._id) !== null && _c !== void 0 ? _c : ''), - currentFileName: (0, fileUtils_1.getFileName)((_e = (_d = args.inputFileObj) === null || _d === void 0 ? void 0 : _d._id) !== null && _e !== void 0 ? _e : ''), + originalFileName: path_1.default.join(absoluteFileDir, (0, fileUtils_1.getFileName)((_d = (_c = args.originalLibraryFile) === null || _c === void 0 ? void 0 : _c._id) !== null && _d !== void 0 ? _d : '')), + currentFileName: path_1.default.join(absoluteFileDir, (0, fileUtils_1.getFileName)((_f = (_e = args.inputFileObj) === null || _e === void 0 ? void 0 : _e._id) !== null && _f !== void 0 ? _f : '')), }; - refresh = function (refreshType) { return __awaiter(void 0, void 0, void 0, function () { - var refreshed, headers, getId, fileName, id, refreshResquestConfig; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - args.jobLog('Going to force scan'); - args.jobLog("Refreshing ".concat(refreshType.appName, "...")); - refreshed = false; - headers = { - 'Content-Type': 'application/json', - 'X-Api-Key': arr_api_key, - Accept: 'application/json', - }; - getId = function (fileName) { return __awaiter(void 0, void 0, void 0, function () { - var parseRequestConfig, parseRequestResult, id; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - parseRequestConfig = { - method: 'get', - url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent(fileName)), - headers: headers, - }; - return [4 /*yield*/, args.deps.axios(parseRequestConfig)]; - case 1: - parseRequestResult = _a.sent(); - id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult); - args.jobLog(id !== -1 - ? "Found ".concat(refreshType.contentName, " ").concat(id, " with a file named '").concat(fileName, "'") - : "Didn't find ".concat(refreshType.contentName, " with a file named '").concat(fileName, "' in ").concat(arrHost, ".")); - return [2 /*return*/, id]; - } - }); - }); }; - fileName = fileNames.originalFileName; - return [4 /*yield*/, getId(fileName)]; - case 1: - id = _a.sent(); - if (!(id === -1 && fileNames.currentFileName !== fileNames.originalFileName)) return [3 /*break*/, 3]; - fileName = fileNames.currentFileName; - return [4 /*yield*/, getId(fileName)]; - case 2: - id = _a.sent(); - _a.label = 3; - case 3: - if (!(id !== -1)) return [3 /*break*/, 5]; - refreshResquestConfig = { - method: 'post', - url: "".concat(arrHost, "/api/v3/command"), - headers: headers, - data: refreshType.delegates.buildRefreshResquestData(id), - }; - return [4 /*yield*/, args.deps.axios(refreshResquestConfig)]; - case 4: - _a.sent(); - refreshed = true; - args.jobLog("\u2714 Refreshed ".concat(refreshType.contentName, " ").concat(id, " in ").concat(refreshType.appName, ".")); - _a.label = 5; - case 5: return [2 /*return*/, refreshed]; - } - }); - }); }; - refreshTypes = { - radarr: { + headers = { + 'Content-Type': 'application/json', + 'X-Api-Key': String(args.inputs.arr_api_key), + Accept: 'application/json', + }; + refreshType = arr === 'radarr' + ? { appName: 'Radarr', - contentName: 'movie', + content: 'Movie', delegates: { - getIdFromParseRequestResult: function (parseRequestResult) { var _a, _b, _c, _d; return Number((_d = (_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.movie) === null || _b === void 0 ? void 0 : _b.movieFile) === null || _c === void 0 ? void 0 : _c.movieId) !== null && _d !== void 0 ? _d : -1); }, + getIdFromParseResponse: function (parseRequestResult) { var _a, _b, _c; return Number((_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.movie) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1); }, buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }); }, }, - }, - sonarr: { + } + : { appName: 'Sonarr', - contentName: 'serie', + content: 'Serie', delegates: { - getIdFromParseRequestResult: function (parseRequestResult) { var _a, _b, _c; return Number((_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1); }, + getIdFromParseResponse: function (parseRequestResult) { var _a, _b, _c; return Number((_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1); }, buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshSeries', seriesId: id }); }, }, - }, - }; - return [4 /*yield*/, refresh(arr === 'radarr' ? refreshTypes.radarr : refreshTypes.sonarr)]; + }; + args.jobLog('Going to force scan'); + args.jobLog("Refreshing ".concat(refreshType.appName, "...")); + return [4 /*yield*/, getId(args, arrHost, headers, fileNames.originalFileName, refreshType)]; case 1: - refreshed = _f.sent(); - return [2 /*return*/, { - outputFileObj: args.inputFileObj, - outputNumber: refreshed ? 1 : 2, - variables: args.variables, - }]; + id = _g.sent(); + if (!(id === -1 && fileNames.currentFileName !== fileNames.originalFileName)) return [3 /*break*/, 3]; + return [4 /*yield*/, getId(args, arrHost, headers, fileNames.currentFileName, refreshType)]; + case 2: + id = _g.sent(); + _g.label = 3; + case 3: + if (!(id !== -1)) return [3 /*break*/, 5]; + // Using command endpoint to queue a refresh task + return [4 /*yield*/, args.deps.axios({ + method: 'post', + url: "".concat(arrHost, "/api/v3/command"), + headers: headers, + data: refreshType.delegates.buildRefreshResquestData(id), + })]; + case 4: + // Using command endpoint to queue a refresh task + _g.sent(); + refreshed = true; + args.jobLog("\u2714 Refreshed ".concat(refreshType.content, " ").concat(id, " in ").concat(refreshType.appName, ".")); + _g.label = 5; + case 5: return [2 /*return*/, { + outputFileObj: args.inputFileObj, + outputNumber: refreshed ? 1 : 2, + variables: args.variables, + }]; } }); }); }; diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index a7a0dd0..7b294c3 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -1,4 +1,5 @@ -import { getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils'; +import path from 'path'; +import { getFileAbosluteDir, getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils'; import { IpluginDetails, IpluginInputArgs, @@ -67,127 +68,121 @@ const details = (): IpluginDetails => ({ ], }); -interface IFileNames { - originalFileName: string, - currentFileName: string +interface IHTTPHeaders { + 'Content-Type': string, + 'X-Api-Key': string, + Accept: string, } interface IParsedRequestResult { data: { - movie?: { - movieFile: { - movieId: number - }, - }, - series?: { - id: number - }, + movie?: { id: number }, + series?: { id: number }, }, } interface IRefreshDelegates { - getIdFromParseRequestResult: (parseRequestResult: IParsedRequestResult) => number, + getIdFromParseResponse: (parseRequestResult: IParsedRequestResult) => number, buildRefreshResquestData: (id: number) => string } interface IRefreshType { appName: string, - contentName: string, + content: string, delegates: IRefreshDelegates } -interface IRefreshTypes { - radarr: IRefreshType, - sonarr: IRefreshType -} + +const getId = async ( + args: IpluginInputArgs, + arrHost: string, headers: IHTTPHeaders, + fileName: string, + refreshType: IRefreshType, +) + : Promise => { + const imdbId = /\b(tt|nm|co|ev|ch|ni)\d{7,10}\b/i.exec(fileName)?.at(0) ?? ''; + let id = (imdbId !== '') + ? Number( + (await args.deps.axios({ + method: 'get', + url: `${arrHost}/api/v3/movie/lookup?terms=imdb:${imdbId}`, + headers, + })).data?.id ?? -1, + ) + : -1; + if (id === -1) { + id = refreshType.delegates.getIdFromParseResponse( + (await args.deps.axios({ + method: 'get', + url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(getFileName(fileName))}`, + headers, + })), + ); + } + args.jobLog(`${refreshType.content} ${id !== -1 ? `${id} found` : 'not found'} for '${fileName}', imdb '${imdbId}'`); + return id; +}; const plugin = async (args: IpluginInputArgs): Promise => { const lib = require('../../../../../methods/lib')(); // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign args.inputs = lib.loadDefaultValues(args.inputs, details); - const { arr, arr_api_key } = args.inputs; + // Variables initialization + let refreshed = false; + const arr = String(args.inputs.arr); const arr_host = String(args.inputs.arr_host).trim(); const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; - const fileNames: IFileNames = { - originalFileName: getFileName(args.originalLibraryFile?._id ?? ''), - currentFileName: getFileName(args.inputFileObj?._id ?? ''), + const absoluteFileDir = getFileAbosluteDir(args.originalLibraryFile?._id ?? ''); + const fileNames = { + originalFileName: path.join(absoluteFileDir, getFileName(args.originalLibraryFile?._id ?? '')), + currentFileName: path.join(absoluteFileDir, getFileName(args.inputFileObj?._id ?? '')), }; - - const refresh = async (refreshType: IRefreshType) - : Promise => { - args.jobLog('Going to force scan'); - args.jobLog(`Refreshing ${refreshType.appName}...`); - - let refreshed = false; - const headers = { - 'Content-Type': 'application/json', - 'X-Api-Key': arr_api_key, - Accept: 'application/json', - }; - - const getId = async (fileName: string) - : Promise => { - // Using parse endpoint to get the movie/serie's id. - const parseRequestConfig = { - method: 'get', - url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(fileName)}`, - headers, - }; - const parseRequestResult = await args.deps.axios(parseRequestConfig); - const id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult); - args.jobLog(id !== -1 - ? `Found ${refreshType.contentName} ${id} with a file named '${fileName}'` - : `Didn't find ${refreshType.contentName} with a file named '${fileName}' in ${arrHost}.`); - return id; - }; - - let fileName = fileNames.originalFileName; - let id = await getId(fileName); - // In case there has been a name change and the arr app already noticed it. - if (id === -1 && fileNames.currentFileName !== fileNames.originalFileName) { - fileName = fileNames.currentFileName; - id = await getId(fileName); - } - - // Checking that the file has been found. - if (id !== -1) { - // Using refresh command endpoint to force rescan. - const refreshResquestConfig = { - method: 'post', - url: `${arrHost}/api/v3/command`, - headers, - data: refreshType.delegates.buildRefreshResquestData(id), - }; - await args.deps.axios(refreshResquestConfig); - - refreshed = true; - args.jobLog(`✔ Refreshed ${refreshType.contentName} ${id} in ${refreshType.appName}.`); - } - - return refreshed; + const headers: IHTTPHeaders = { + 'Content-Type': 'application/json', + 'X-Api-Key': String(args.inputs.arr_api_key), + Accept: 'application/json', }; - - const refreshTypes: IRefreshTypes = { - radarr: { + const refreshType: IRefreshType = arr === 'radarr' + ? { appName: 'Radarr', - contentName: 'movie', + content: 'Movie', delegates: { - getIdFromParseRequestResult: - (parseRequestResult) => Number(parseRequestResult.data?.movie?.movieFile?.movieId ?? -1), + getIdFromParseResponse: + (parseRequestResult: IParsedRequestResult) => Number(parseRequestResult.data?.movie?.id ?? -1), buildRefreshResquestData: (id) => JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }), }, - }, - sonarr: { + } + : { appName: 'Sonarr', - contentName: 'serie', + content: 'Serie', delegates: { - getIdFromParseRequestResult: - (parseRequestResult) => Number(parseRequestResult.data?.series?.id ?? -1), + getIdFromParseResponse: + (parseRequestResult: IParsedRequestResult) => Number(parseRequestResult.data?.series?.id ?? -1), buildRefreshResquestData: (id) => JSON.stringify({ name: 'RefreshSeries', seriesId: id }), }, - }, - }; + }; + + args.jobLog('Going to force scan'); + args.jobLog(`Refreshing ${refreshType.appName}...`); + + let id = await getId(args, 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); + } + + // Checking that the file has been found + if (id !== -1) { + // Using command endpoint to queue a refresh task + await args.deps.axios({ + method: 'post', + url: `${arrHost}/api/v3/command`, + headers, + data: refreshType.delegates.buildRefreshResquestData(id), + }); - const refreshed = await refresh(arr === 'radarr' ? refreshTypes.radarr : refreshTypes.sonarr); + refreshed = true; + args.jobLog(`✔ Refreshed ${refreshType.content} ${id} in ${refreshType.appName}.`); + } return { outputFileObj: args.inputFileObj, From 1bc893b7b9c2c0403a9d04499dd4f84a0eaef056 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 29 Mar 2024 00:20:29 +0100 Subject: [PATCH 07/18] Corrected lookup endpoint param name --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 2 +- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 458a5d4..f8f494e 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -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?terms=imdb:").concat(imdbId), + url: "".concat(arrHost, "/api/v3/movie/lookup?term=imdb:").concat(imdbId), headers: headers, })]; case 1: diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 7b294c3..4a1dc24 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -101,7 +101,7 @@ const getId = async ( ? Number( (await args.deps.axios({ method: 'get', - url: `${arrHost}/api/v3/movie/lookup?terms=imdb:${imdbId}`, + url: `${arrHost}/api/v3/movie/lookup?term=imdb:${imdbId}`, headers, })).data?.id ?? -1, ) From 12f61a34c903729b141fa35645566893e3f9bd3e Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 29 Mar 2024 00:22:03 +0100 Subject: [PATCH 08/18] Log corrected --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 2 +- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index f8f494e..8f2f94c 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -205,7 +205,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function // Using command endpoint to queue a refresh task _g.sent(); refreshed = true; - args.jobLog("\u2714 Refreshed ".concat(refreshType.content, " ").concat(id, " in ").concat(refreshType.appName, ".")); + args.jobLog("\u2714 ".concat(refreshType.content, " ").concat(id, " refreshed in ").concat(refreshType.appName, ".")); _g.label = 5; case 5: return [2 /*return*/, { outputFileObj: args.inputFileObj, diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 4a1dc24..4f0c071 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -181,7 +181,7 @@ const plugin = async (args: IpluginInputArgs): Promise => { }); refreshed = true; - args.jobLog(`✔ Refreshed ${refreshType.content} ${id} in ${refreshType.appName}.`); + args.jobLog(`✔ ${refreshType.content} ${id} refreshed in ${refreshType.appName}.`); } return { 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 09/18] 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 From 694ae59f22ef90a5b18677ce396fb04b8c9b1b4b Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 29 Mar 2024 09:27:58 +0100 Subject: [PATCH 10/18] Serie lookup url corrected --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 2 +- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 62701de..82a61b9 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -115,7 +115,7 @@ var getId = function (args, arr, arrHost, headers, fileName, refreshType) { retu _b = Number; return [4 /*yield*/, args.deps.axios({ method: 'get', - url: "".concat(arrHost, "/api/v3/").concat(arr === 'radarr' ? 'movie' : 'serie', "/lookup?term=imdb:").concat(imdbId), + url: "".concat(arrHost, "/api/v3/").concat(arr === 'radarr' ? 'movie' : 'series', "/lookup?term=imdb:").concat(imdbId), headers: headers, })]; case 1: diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index e7e219a..021b750 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -102,7 +102,7 @@ const getId = async ( ? Number( (await args.deps.axios({ method: 'get', - url: `${arrHost}/api/v3/${arr === 'radarr' ? 'movie' : 'serie'}/lookup?term=imdb:${imdbId}`, + url: `${arrHost}/api/v3/${arr === 'radarr' ? 'movie' : 'series'}/lookup?term=imdb:${imdbId}`, headers, })).data?.id ?? -1, ) From c21e9594a527b89fae84ea72502cff6404384747 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 29 Mar 2024 09:43:31 +0100 Subject: [PATCH 11/18] Multiple small adjustments --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 31 +++++++++---------- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 24 ++++++-------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 82a61b9..8687652 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -144,10 +144,10 @@ var getId = function (args, arr, arrHost, headers, fileName, refreshType) { retu }); }); }; var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () { - var lib, refreshed, arr, arr_host, arrHost, absoluteFileDir, fileNames, headers, refreshType, id; - var _a, _b, _c, _d, _e, _f; - return __generator(this, function (_g) { - switch (_g.label) { + var lib, refreshed, arr, arr_host, arrHost, originalFileName, currentFileName, headers, refreshType, id; + var _a, _b, _c, _d; + return __generator(this, function (_e) { + switch (_e.label) { case 0: lib = require('../../../../../methods/lib')(); // eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign @@ -156,11 +156,8 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function arr = String(args.inputs.arr); arr_host = String(args.inputs.arr_host).trim(); arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; - absoluteFileDir = (0, fileUtils_1.getFileAbosluteDir)((_b = (_a = args.originalLibraryFile) === null || _a === void 0 ? void 0 : _a._id) !== null && _b !== void 0 ? _b : ''); - fileNames = { - originalFileName: path_1.default.join(absoluteFileDir, (0, fileUtils_1.getFileName)((_d = (_c = args.originalLibraryFile) === null || _c === void 0 ? void 0 : _c._id) !== null && _d !== void 0 ? _d : '')), - currentFileName: path_1.default.join(absoluteFileDir, (0, fileUtils_1.getFileName)((_f = (_e = args.inputFileObj) === null || _e === void 0 ? void 0 : _e._id) !== null && _f !== void 0 ? _f : '')), - }; + originalFileName = path_1.default.join((_b = (_a = args.originalLibraryFile) === null || _a === void 0 ? void 0 : _a._id) !== null && _b !== void 0 ? _b : ''); + currentFileName = path_1.default.join((_d = (_c = args.inputFileObj) === null || _c === void 0 ? void 0 : _c._id) !== null && _d !== void 0 ? _d : ''); headers = { 'Content-Type': 'application/json', 'X-Api-Key': String(args.inputs.arr_api_key), @@ -185,14 +182,14 @@ 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, arr, arrHost, headers, fileNames.originalFileName, refreshType)]; + return [4 /*yield*/, getId(args, arr, arrHost, headers, originalFileName, refreshType)]; case 1: - id = _g.sent(); - if (!(id === -1 && fileNames.currentFileName !== fileNames.originalFileName)) return [3 /*break*/, 3]; - return [4 /*yield*/, getId(args, arr, arrHost, headers, fileNames.currentFileName, refreshType)]; + id = _e.sent(); + if (!(id === -1 && currentFileName !== originalFileName)) return [3 /*break*/, 3]; + return [4 /*yield*/, getId(args, arr, arrHost, headers, currentFileName, refreshType)]; case 2: - id = _g.sent(); - _g.label = 3; + id = _e.sent(); + _e.label = 3; case 3: if (!(id !== -1)) return [3 /*break*/, 5]; // Using command endpoint to queue a refresh task @@ -204,10 +201,10 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function })]; case 4: // Using command endpoint to queue a refresh task - _g.sent(); + _e.sent(); refreshed = true; args.jobLog("\u2714 ".concat(refreshType.content, " ").concat(id, " refreshed in ").concat(refreshType.appName, ".")); - _g.label = 5; + _e.label = 5; case 5: return [2 /*return*/, { outputFileObj: args.inputFileObj, outputNumber: refreshed ? 1 : 2, diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 021b750..fe398b7 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { getFileAbosluteDir, getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils'; +import { getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils'; import { IpluginDetails, IpluginInputArgs, @@ -79,14 +79,13 @@ interface IParsedRequestResult { series?: { id: number }, }, } -interface IRefreshDelegates { - getIdFromParseResponse: (parseRequestResult: IParsedRequestResult) => number, - buildRefreshResquestData: (id: number) => string -} interface IRefreshType { appName: string, content: string, - delegates: IRefreshDelegates + delegates: { + getIdFromParseResponse: (parseRequestResult: IParsedRequestResult) => number, + buildRefreshResquestData: (id: number) => string + } } const getId = async ( @@ -131,11 +130,8 @@ const plugin = async (args: IpluginInputArgs): Promise => { const arr = String(args.inputs.arr); const arr_host = String(args.inputs.arr_host).trim(); const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; - const absoluteFileDir = getFileAbosluteDir(args.originalLibraryFile?._id ?? ''); - const fileNames = { - originalFileName: path.join(absoluteFileDir, getFileName(args.originalLibraryFile?._id ?? '')), - currentFileName: path.join(absoluteFileDir, getFileName(args.inputFileObj?._id ?? '')), - }; + const originalFileName = path.join(args.originalLibraryFile?._id ?? ''); + const currentFileName = path.join(args.inputFileObj?._id ?? ''); const headers: IHTTPHeaders = { 'Content-Type': 'application/json', 'X-Api-Key': String(args.inputs.arr_api_key), @@ -166,10 +162,10 @@ const plugin = async (args: IpluginInputArgs): Promise => { args.jobLog('Going to force scan'); args.jobLog(`Refreshing ${refreshType.appName}...`); - let id = await getId(args, arr, arrHost, headers, fileNames.originalFileName, refreshType); + let id = await getId(args, arr, arrHost, headers, originalFileName, refreshType); // Useful in some edge cases - if (id === -1 && fileNames.currentFileName !== fileNames.originalFileName) { - id = await getId(args, arr, arrHost, headers, fileNames.currentFileName, refreshType); + if (id === -1 && currentFileName !== originalFileName) { + id = await getId(args, arr, arrHost, headers, currentFileName, refreshType); } // Checking that the file has been found From d6b7e51389bda7e33694373c43768cea570db5c6 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 29 Mar 2024 10:12:09 +0100 Subject: [PATCH 12/18] Corrected log position --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 5 ++--- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 8687652..8c69472 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -136,10 +136,9 @@ var getId = function (args, arr, arrHost, headers, fileName, refreshType) { retu })]; case 4: 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((0, fileUtils_1.getFileName)(fileName), "'")); - return [2 /*return*/, id]; + _j.label = 5; + case 5: return [2 /*return*/, id]; } }); }); }; diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index fe398b7..2471142 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -115,8 +115,8 @@ const getId = async ( headers, })), ); + args.jobLog(`${refreshType.content} ${id !== -1 ? `${id} found` : 'not found'} for '${getFileName(fileName)}'`); } - args.jobLog(`${refreshType.content} ${id !== -1 ? `${id} found` : 'not found'} for '${getFileName(fileName)}'`); return id; }; From a02379f2407d084f91d8c546e69011030a1b7408 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 29 Mar 2024 11:36:35 +0100 Subject: [PATCH 13/18] Final corrections after testing --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 14 +++++++------- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 8c69472..c960a2a 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -106,9 +106,9 @@ var details = function () { return ({ exports.details = details; 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) { - switch (_j.label) { + var _e, _f, _g, _h, _j; + return __generator(this, function (_k) { + switch (_k.label) { case 0: imdbId = (_f = (_e = /\b(tt|nm|co|ev|ch|ni)\d{7,10}\b/i.exec(fileName)) === null || _e === void 0 ? void 0 : _e.at(0)) !== null && _f !== void 0 ? _f : ''; if (!(imdbId !== '')) return [3 /*break*/, 2]; @@ -119,11 +119,11 @@ var getId = function (args, arr, arrHost, headers, fileName, refreshType) { retu headers: headers, })]; case 1: - _a = _b.apply(void 0, [(_h = (_g = (_j.sent()).data) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : -1]); + _a = _b.apply(void 0, [(_j = (_h = (_g = (_k.sent()).data) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.id) !== null && _j !== void 0 ? _j : -1]); return [3 /*break*/, 3]; case 2: _a = -1; - _j.label = 3; + _k.label = 3; case 3: id = _a; args.jobLog("".concat(refreshType.content, " ").concat(id !== -1 ? "".concat(id, " found") : 'not found', " for imdb '").concat(imdbId, "'")); @@ -135,9 +135,9 @@ var getId = function (args, arr, arrHost, headers, fileName, refreshType) { retu headers: headers, })]; case 4: - id = _d.apply(_c, [(_j.sent())]); + id = _d.apply(_c, [(_k.sent())]); args.jobLog("".concat(refreshType.content, " ").concat(id !== -1 ? "".concat(id, " found") : 'not found', " for '").concat((0, fileUtils_1.getFileName)(fileName), "'")); - _j.label = 5; + _k.label = 5; case 5: return [2 /*return*/, id]; } }); diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 2471142..883f4e9 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -103,7 +103,7 @@ const getId = async ( method: 'get', url: `${arrHost}/api/v3/${arr === 'radarr' ? 'movie' : 'series'}/lookup?term=imdb:${imdbId}`, headers, - })).data?.id ?? -1, + })).data?.at(0)?.id ?? -1, ) : -1; args.jobLog(`${refreshType.content} ${id !== -1 ? `${id} found` : 'not found'} for imdb '${imdbId}'`); From 5198d4b805603931e11efe41d2bf1df28e997dd9 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 29 Mar 2024 11:53:49 +0100 Subject: [PATCH 14/18] Removed useless dependency --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 8 ++------ .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 5 ++--- 2 files changed, 4 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 c960a2a..7a0e86a 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -35,12 +35,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.plugin = exports.details = void 0; -var path_1 = __importDefault(require("path")); var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils"); var details = function () { return ({ name: 'Notify Radarr or Sonarr', @@ -155,8 +151,8 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function arr = String(args.inputs.arr); arr_host = String(args.inputs.arr_host).trim(); arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; - originalFileName = path_1.default.join((_b = (_a = args.originalLibraryFile) === null || _a === void 0 ? void 0 : _a._id) !== null && _b !== void 0 ? _b : ''); - currentFileName = path_1.default.join((_d = (_c = args.inputFileObj) === null || _c === void 0 ? void 0 : _c._id) !== null && _d !== void 0 ? _d : ''); + originalFileName = (_b = (_a = args.originalLibraryFile) === null || _a === void 0 ? void 0 : _a._id) !== null && _b !== void 0 ? _b : ''; + currentFileName = (_d = (_c = args.inputFileObj) === null || _c === void 0 ? void 0 : _c._id) !== null && _d !== void 0 ? _d : ''; headers = { 'Content-Type': 'application/json', 'X-Api-Key': String(args.inputs.arr_api_key), diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 883f4e9..151fa96 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -1,4 +1,3 @@ -import path from 'path'; import { getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils'; import { IpluginDetails, @@ -130,8 +129,8 @@ const plugin = async (args: IpluginInputArgs): Promise => { const arr = String(args.inputs.arr); const arr_host = String(args.inputs.arr_host).trim(); const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host; - const originalFileName = path.join(args.originalLibraryFile?._id ?? ''); - const currentFileName = path.join(args.inputFileObj?._id ?? ''); + const originalFileName = args.originalLibraryFile?._id ?? ''; + const currentFileName = args.inputFileObj?._id ?? ''; const headers: IHTTPHeaders = { 'Content-Type': 'application/json', 'X-Api-Key': String(args.inputs.arr_api_key), From f9e9215bcb51ea5b00bc65b4d8451de164a30ff1 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Sun, 31 Mar 2024 11:50:22 +0200 Subject: [PATCH 15/18] After thorough testing, some renaming and refactoring --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 44 +++++++------ .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 62 ++++++++++--------- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 7a0e86a..4d80235 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -100,7 +100,7 @@ var details = function () { return ({ ], }); }; exports.details = details; -var getId = function (args, arr, arrHost, headers, fileName, refreshType) { return __awaiter(void 0, void 0, void 0, function () { +var getId = function (args, arrApp, fileName) { return __awaiter(void 0, void 0, void 0, function () { var imdbId, id, _a, _b, _c, _d; var _e, _f, _g, _h, _j; return __generator(this, function (_k) { @@ -111,8 +111,8 @@ var getId = function (args, arr, arrHost, headers, fileName, refreshType) { retu _b = Number; return [4 /*yield*/, args.deps.axios({ method: 'get', - url: "".concat(arrHost, "/api/v3/").concat(arr === 'radarr' ? 'movie' : 'series', "/lookup?term=imdb:").concat(imdbId), - headers: headers, + url: "".concat(arrApp.host, "/api/v3/").concat(arrApp.name === 'radarr' ? 'movie' : 'series', "/lookup?term=imdb:").concat(imdbId), + headers: arrApp.headers, })]; case 1: _a = _b.apply(void 0, [(_j = (_h = (_g = (_k.sent()).data) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.id) !== null && _j !== void 0 ? _j : -1]); @@ -122,24 +122,24 @@ var getId = function (args, arr, arrHost, headers, fileName, refreshType) { retu _k.label = 3; case 3: id = _a; - args.jobLog("".concat(refreshType.content, " ").concat(id !== -1 ? "".concat(id, " found") : 'not found', " for imdb '").concat(imdbId, "'")); + args.jobLog("".concat(arrApp.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; + _d = (_c = arrApp.delegates).getIdFromParseResponse; return [4 /*yield*/, args.deps.axios({ method: 'get', - url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent((0, fileUtils_1.getFileName)(fileName))), - headers: headers, + url: "".concat(arrApp.host, "/api/v3/parse?title=").concat(encodeURIComponent((0, fileUtils_1.getFileName)(fileName))), + headers: arrApp.headers, })]; case 4: id = _d.apply(_c, [(_k.sent())]); - args.jobLog("".concat(refreshType.content, " ").concat(id !== -1 ? "".concat(id, " found") : 'not found', " for '").concat((0, fileUtils_1.getFileName)(fileName), "'")); + args.jobLog("".concat(arrApp.content, " ").concat(id !== -1 ? "'".concat(id, "' found") : 'not found', " for '").concat((0, fileUtils_1.getFileName)(fileName), "'")); _k.label = 5; case 5: return [2 /*return*/, id]; } }); }); }; var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () { - var lib, refreshed, arr, arr_host, arrHost, originalFileName, currentFileName, headers, refreshType, id; + var lib, refreshed, arr, arr_host, arrHost, originalFileName, currentFileName, headers, arrApp, id; var _a, _b, _c, _d; return __generator(this, function (_e) { switch (_e.label) { @@ -158,30 +158,34 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function 'X-Api-Key': String(args.inputs.arr_api_key), Accept: 'application/json', }; - refreshType = arr === 'radarr' + arrApp = arr === 'radarr' ? { - appName: 'Radarr', + name: arr, + host: arrHost, + headers: headers, content: 'Movie', delegates: { - getIdFromParseResponse: function (parseRequestResult) { var _a, _b, _c; return Number((_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.movie) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1); }, + getIdFromParseResponse: function (parseResponse) { var _a, _b, _c; return Number((_c = (_b = (_a = parseResponse === null || parseResponse === void 0 ? void 0 : parseResponse.data) === null || _a === void 0 ? void 0 : _a.movie) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1); }, buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }); }, }, } : { - appName: 'Sonarr', + name: arr, + host: arrHost, + headers: headers, content: 'Serie', delegates: { - getIdFromParseResponse: function (parseRequestResult) { var _a, _b, _c; return Number((_c = (_b = (_a = parseRequestResult.data) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1); }, + getIdFromParseResponse: function (parseResponse) { var _a, _b, _c; return Number((_c = (_b = (_a = parseResponse === null || parseResponse === void 0 ? void 0 : parseResponse.data) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : -1); }, buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshSeries', seriesId: id }); }, }, }; args.jobLog('Going to force scan'); - args.jobLog("Refreshing ".concat(refreshType.appName, "...")); - return [4 /*yield*/, getId(args, arr, arrHost, headers, originalFileName, refreshType)]; + args.jobLog("Refreshing ".concat(arrApp.name, "...")); + return [4 /*yield*/, getId(args, arrApp, originalFileName)]; case 1: id = _e.sent(); if (!(id === -1 && currentFileName !== originalFileName)) return [3 /*break*/, 3]; - return [4 /*yield*/, getId(args, arr, arrHost, headers, currentFileName, refreshType)]; + return [4 /*yield*/, getId(args, arrApp, currentFileName)]; case 2: id = _e.sent(); _e.label = 3; @@ -190,15 +194,15 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function // Using command endpoint to queue a refresh task return [4 /*yield*/, args.deps.axios({ method: 'post', - url: "".concat(arrHost, "/api/v3/command"), + url: "".concat(arrApp.host, "/api/v3/command"), headers: headers, - data: refreshType.delegates.buildRefreshResquestData(id), + data: arrApp.delegates.buildRefreshResquestData(id), })]; case 4: // Using command endpoint to queue a refresh task _e.sent(); refreshed = true; - args.jobLog("\u2714 ".concat(refreshType.content, " ").concat(id, " refreshed in ").concat(refreshType.appName, ".")); + args.jobLog("\u2714 ".concat(arrApp.content, " '").concat(id, "' refreshed in ").concat(arrApp.name, ".")); _e.label = 5; case 5: return [2 /*return*/, { outputFileObj: args.inputFileObj, diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 151fa96..241806d 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -72,49 +72,47 @@ interface IHTTPHeaders { 'X-Api-Key': string, Accept: string, } -interface IParsedRequestResult { +interface IParseResponse { data: { movie?: { id: number }, series?: { id: number }, }, } -interface IRefreshType { - appName: string, +interface IArrApp { + name: string, + host: string, + headers: IHTTPHeaders, content: string, delegates: { - getIdFromParseResponse: (parseRequestResult: IParsedRequestResult) => number, + getIdFromParseResponse: (parseResponse: IParseResponse) => number, buildRefreshResquestData: (id: number) => string } } const getId = async ( args: IpluginInputArgs, - arr: string, - arrHost: string, headers: IHTTPHeaders, + arrApp: IArrApp, fileName: string, - refreshType: IRefreshType, ) : Promise => { const imdbId = /\b(tt|nm|co|ev|ch|ni)\d{7,10}\b/i.exec(fileName)?.at(0) ?? ''; let id = (imdbId !== '') - ? Number( - (await args.deps.axios({ - method: 'get', - url: `${arrHost}/api/v3/${arr === 'radarr' ? 'movie' : 'series'}/lookup?term=imdb:${imdbId}`, - headers, - })).data?.at(0)?.id ?? -1, - ) + ? Number((await args.deps.axios({ + method: 'get', + url: `${arrApp.host}/api/v3/${arrApp.name === 'radarr' ? 'movie' : 'series'}/lookup?term=imdb:${imdbId}`, + headers: arrApp.headers, + })).data?.at(0)?.id ?? -1) : -1; - args.jobLog(`${refreshType.content} ${id !== -1 ? `${id} found` : 'not found'} for imdb '${imdbId}'`); + args.jobLog(`${arrApp.content} ${id !== -1 ? `'${id}' found` : 'not found'} for imdb '${imdbId}'`); if (id === -1) { - id = refreshType.delegates.getIdFromParseResponse( + id = arrApp.delegates.getIdFromParseResponse( (await args.deps.axios({ method: 'get', - url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(getFileName(fileName))}`, - headers, + url: `${arrApp.host}/api/v3/parse?title=${encodeURIComponent(getFileName(fileName))}`, + headers: arrApp.headers, })), ); - args.jobLog(`${refreshType.content} ${id !== -1 ? `${id} found` : 'not found'} for '${getFileName(fileName)}'`); + args.jobLog(`${arrApp.content} ${id !== -1 ? `'${id}' found` : 'not found'} for '${getFileName(fileName)}'`); } return id; }; @@ -136,35 +134,39 @@ const plugin = async (args: IpluginInputArgs): Promise => { 'X-Api-Key': String(args.inputs.arr_api_key), Accept: 'application/json', }; - const refreshType: IRefreshType = arr === 'radarr' + const arrApp: IArrApp = arr === 'radarr' ? { - appName: 'Radarr', + name: arr, + host: arrHost, + headers, content: 'Movie', delegates: { getIdFromParseResponse: - (parseRequestResult: IParsedRequestResult) => Number(parseRequestResult.data?.movie?.id ?? -1), + (parseResponse: IParseResponse) => Number(parseResponse?.data?.movie?.id ?? -1), buildRefreshResquestData: (id) => JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }), }, } : { - appName: 'Sonarr', + name: arr, + host: arrHost, + headers, content: 'Serie', delegates: { getIdFromParseResponse: - (parseRequestResult: IParsedRequestResult) => Number(parseRequestResult.data?.series?.id ?? -1), + (parseResponse: IParseResponse) => Number(parseResponse?.data?.series?.id ?? -1), buildRefreshResquestData: (id) => JSON.stringify({ name: 'RefreshSeries', seriesId: id }), }, }; args.jobLog('Going to force scan'); - args.jobLog(`Refreshing ${refreshType.appName}...`); + args.jobLog(`Refreshing ${arrApp.name}...`); - let id = await getId(args, arr, arrHost, headers, originalFileName, refreshType); + let id = await getId(args, arrApp, originalFileName); // Useful in some edge cases if (id === -1 && currentFileName !== originalFileName) { - id = await getId(args, arr, arrHost, headers, currentFileName, refreshType); + id = await getId(args, arrApp, currentFileName); } // Checking that the file has been found @@ -172,13 +174,13 @@ const plugin = async (args: IpluginInputArgs): Promise => { // Using command endpoint to queue a refresh task await args.deps.axios({ method: 'post', - url: `${arrHost}/api/v3/command`, + url: `${arrApp.host}/api/v3/command`, headers, - data: refreshType.delegates.buildRefreshResquestData(id), + data: arrApp.delegates.buildRefreshResquestData(id), }); refreshed = true; - args.jobLog(`✔ ${refreshType.content} ${id} refreshed in ${refreshType.appName}.`); + args.jobLog(`✔ ${arrApp.content} '${id}' refreshed in ${arrApp.name}.`); } return { From d89af168586c9c8dd78fd3675076aa5dc6fe9e45 Mon Sep 17 00:00:00 2001 From: "jeanchristophe.mqt@gmail.com" Date: Fri, 12 Apr 2024 10:17:05 +0200 Subject: [PATCH 16/18] Made imdb regex ungreedy --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 2 +- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 4d80235..2a1a6fa 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -106,7 +106,7 @@ var getId = function (args, arrApp, fileName) { return __awaiter(void 0, void 0, return __generator(this, function (_k) { switch (_k.label) { case 0: - imdbId = (_f = (_e = /\b(tt|nm|co|ev|ch|ni)\d{7,10}\b/i.exec(fileName)) === null || _e === void 0 ? void 0 : _e.at(0)) !== null && _f !== void 0 ? _f : ''; + imdbId = (_f = (_e = /\b(tt|nm|co|ev|ch|ni)\d{7,10}?\b/i.exec(fileName)) === null || _e === void 0 ? void 0 : _e.at(0)) !== null && _f !== void 0 ? _f : ''; if (!(imdbId !== '')) return [3 /*break*/, 2]; _b = Number; return [4 /*yield*/, args.deps.axios({ diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 241806d..8c9a31d 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -95,7 +95,7 @@ const getId = async ( fileName: string, ) : Promise => { - const imdbId = /\b(tt|nm|co|ev|ch|ni)\d{7,10}\b/i.exec(fileName)?.at(0) ?? ''; + const imdbId = /\b(tt|nm|co|ev|ch|ni)\d{7,10}?\b/i.exec(fileName)?.at(0) ?? ''; let id = (imdbId !== '') ? Number((await args.deps.axios({ method: 'get', From 2ae3c8ba6430131f2b1e09dd15e00dbda1dfb23a Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Wed, 8 May 2024 06:43:30 +0100 Subject: [PATCH 17/18] Fix Sonarr typo --- .../tools/notifyRadarrOrSonarr/2.0.0/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts index 8c9a31d..9629101 100644 --- a/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts +++ b/FlowPluginsTs/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.ts @@ -58,11 +58,11 @@ const details = (): IpluginDetails => ({ outputs: [ { number: 1, - tooltip: 'Radarr or Sonnar notified', + tooltip: 'Radarr or Sonarr notified', }, { number: 2, - tooltip: 'Radarr or Sonnar do not know this file', + tooltip: 'Radarr or Sonarr do not know this file', }, ], }); From cb22cde62d9cfa8ad63eee0120ca7dff10982af7 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Wed, 8 May 2024 06:50:43 +0100 Subject: [PATCH 18/18] Add compiled changes --- .../tools/notifyRadarrOrSonarr/2.0.0/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js index 2a1a6fa..8b0379f 100644 --- a/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js +++ b/FlowPlugins/CommunityFlowPlugins/tools/notifyRadarrOrSonarr/2.0.0/index.js @@ -91,11 +91,11 @@ var details = function () { return ({ outputs: [ { number: 1, - tooltip: 'Radarr or Sonnar notified', + tooltip: 'Radarr or Sonarr notified', }, { number: 2, - tooltip: 'Radarr or Sonnar do not know this file', + tooltip: 'Radarr or Sonarr do not know this file', }, ], }); };