mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-15 10:15:54 -07:00
Fix eslint warnings and errors
This commit is contained in:
parent
e581a90864
commit
142134a192
2 changed files with 30 additions and 29 deletions
|
|
@ -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;
|
arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host;
|
||||||
fileNames = {
|
fileNames = {
|
||||||
originalFileName: (0, fileUtils_1.getFileName)((_c = (_b = args.originalLibraryFile) === null || _b === void 0 ? void 0 : _b._id) !== null && _c !== void 0 ? _c : ''),
|
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 () {
|
refresh = function (refreshType) { return __awaiter(void 0, void 0, void 0, function () {
|
||||||
var refreshed, headers, getId, fileName, id, refreshResquestConfig;
|
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:
|
case 1:
|
||||||
parseRequestResult = _a.sent();
|
parseRequestResult = _a.sent();
|
||||||
id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult);
|
id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult);
|
||||||
args.jobLog(id !== -1 ?
|
args.jobLog(id !== -1
|
||||||
"Found ".concat(refreshType.contentName, " ").concat(id, " with a file named '").concat(fileName, "'")
|
? "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, "."));
|
: "Didn't find ".concat(refreshType.contentName, " with a file named '").concat(fileName, "' in ").concat(arrHost, "."));
|
||||||
return [2 /*return*/, id];
|
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)];
|
return [4 /*yield*/, getId(fileName)];
|
||||||
case 1:
|
case 1:
|
||||||
id = _a.sent();
|
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;
|
fileName = fileNames.currentFileName;
|
||||||
return [4 /*yield*/, getId(fileName)];
|
return [4 /*yield*/, getId(fileName)];
|
||||||
case 2:
|
case 2:
|
||||||
|
|
@ -166,7 +166,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: "".concat(arrHost, "/api/v3/command"),
|
url: "".concat(arrHost, "/api/v3/command"),
|
||||||
headers: headers,
|
headers: headers,
|
||||||
data: refreshType.delegates.buildRefreshResquestData(id)
|
data: refreshType.delegates.buildRefreshResquestData(id),
|
||||||
};
|
};
|
||||||
return [4 /*yield*/, args.deps.axios(refreshResquestConfig)];
|
return [4 /*yield*/, args.deps.axios(refreshResquestConfig)];
|
||||||
case 4:
|
case 4:
|
||||||
|
|
@ -184,15 +184,15 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
contentName: 'movie',
|
contentName: 'movie',
|
||||||
delegates: {
|
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); },
|
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: {
|
sonarr: {
|
||||||
appName: 'Sonarr',
|
appName: 'Sonarr',
|
||||||
contentName: 'serie',
|
contentName: 'serie',
|
||||||
delegates: {
|
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); },
|
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 }); },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
import { get } from 'http';
|
import { getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||||
import {
|
|
||||||
getContainer, getFileAbosluteDir, getFileName,
|
|
||||||
} from '../../../../FlowHelpers/1.0.0/fileUtils';
|
|
||||||
import {
|
import {
|
||||||
IpluginDetails,
|
IpluginDetails,
|
||||||
IpluginInputArgs,
|
IpluginInputArgs,
|
||||||
|
|
@ -72,7 +69,7 @@ const details = (): IpluginDetails => ({
|
||||||
|
|
||||||
interface IFileNames {
|
interface IFileNames {
|
||||||
originalFileName: string,
|
originalFileName: string,
|
||||||
currentFileName : string
|
currentFileName: string
|
||||||
}
|
}
|
||||||
interface IRefreshDelegates {
|
interface IRefreshDelegates {
|
||||||
getIdFromParseRequestResult: (parseRequestResult: any) => number,
|
getIdFromParseRequestResult: (parseRequestResult: any) => number,
|
||||||
|
|
@ -96,9 +93,9 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
const { arr, arr_api_key } = args.inputs;
|
const { arr, arr_api_key } = args.inputs;
|
||||||
const arr_host = String(args.inputs.arr_host).trim();
|
const arr_host = String(args.inputs.arr_host).trim();
|
||||||
const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host;
|
const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host;
|
||||||
const fileNames : IFileNames = {
|
const fileNames: IFileNames = {
|
||||||
originalFileName : getFileName(args.originalLibraryFile?._id ?? ''),
|
originalFileName: getFileName(args.originalLibraryFile?._id ?? ''),
|
||||||
currentFileName: getFileName(args.inputFileObj?._id ?? '')
|
currentFileName: getFileName(args.inputFileObj?._id ?? ''),
|
||||||
};
|
};
|
||||||
|
|
||||||
const refresh = async (refreshType: IRefreshType)
|
const refresh = async (refreshType: IRefreshType)
|
||||||
|
|
@ -113,8 +110,8 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
};
|
};
|
||||||
|
|
||||||
const getId = async (fileName : string)
|
const getId = async (fileName: string)
|
||||||
: Promise<number> => {
|
: Promise<number> => {
|
||||||
// Using parse endpoint to get the movie/serie's id.
|
// Using parse endpoint to get the movie/serie's id.
|
||||||
const parseRequestConfig = {
|
const parseRequestConfig = {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|
@ -123,16 +120,16 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
};
|
};
|
||||||
const parseRequestResult = await args.deps.axios(parseRequestConfig);
|
const parseRequestResult = await args.deps.axios(parseRequestConfig);
|
||||||
const id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult);
|
const id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult);
|
||||||
args.jobLog(id !== -1 ?
|
args.jobLog(id !== -1
|
||||||
`Found ${refreshType.contentName} ${id} with a file named '${fileName}'`
|
? `Found ${refreshType.contentName} ${id} with a file named '${fileName}'`
|
||||||
: `Didn't find ${refreshType.contentName} with a file named '${fileName}' in ${arrHost}.`);
|
: `Didn't find ${refreshType.contentName} with a file named '${fileName}' in ${arrHost}.`);
|
||||||
return id;
|
return id;
|
||||||
}
|
};
|
||||||
|
|
||||||
let fileName = fileNames.originalFileName;
|
let fileName = fileNames.originalFileName;
|
||||||
let id = await getId(fileName);
|
let id = await getId(fileName);
|
||||||
// In case there has been a name change and the arr app already noticed it.
|
// 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;
|
fileName = fileNames.currentFileName;
|
||||||
id = await getId(fileName);
|
id = await getId(fileName);
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +141,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: `${arrHost}/api/v3/command`,
|
url: `${arrHost}/api/v3/command`,
|
||||||
headers,
|
headers,
|
||||||
data: refreshType.delegates.buildRefreshResquestData(id)
|
data: refreshType.delegates.buildRefreshResquestData(id),
|
||||||
};
|
};
|
||||||
await args.deps.axios(refreshResquestConfig);
|
await args.deps.axios(refreshResquestConfig);
|
||||||
|
|
||||||
|
|
@ -160,16 +157,20 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
appName: 'Radarr',
|
appName: 'Radarr',
|
||||||
contentName: 'movie',
|
contentName: 'movie',
|
||||||
delegates: {
|
delegates: {
|
||||||
getIdFromParseRequestResult: (parseRequestResult) => Number(parseRequestResult.data?.movie?.movieFile?.movieId ?? -1),
|
getIdFromParseRequestResult:
|
||||||
buildRefreshResquestData: id => JSON.stringify({ name: 'RefreshMovie', movieIds: [id] })
|
(parseRequestResult) => Number(parseRequestResult.data?.movie?.movieFile?.movieId ?? -1),
|
||||||
}
|
buildRefreshResquestData:
|
||||||
|
(id) => JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
sonarr: {
|
sonarr: {
|
||||||
appName: 'Sonarr',
|
appName: 'Sonarr',
|
||||||
contentName: 'serie',
|
contentName: 'serie',
|
||||||
delegates: {
|
delegates: {
|
||||||
getIdFromParseRequestResult: (parseRequestResult) => Number(parseRequestResult.data?.series?.id ?? -1),
|
getIdFromParseRequestResult:
|
||||||
buildRefreshResquestData: id => JSON.stringify({ name: 'RefreshSeries', seriesId: id })
|
(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<IpluginOutputArgs> => {
|
||||||
export {
|
export {
|
||||||
details,
|
details,
|
||||||
plugin,
|
plugin,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue