mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 07:29:04 -07:00
Addded lookup url for Sonarr
This commit is contained in:
parent
12f61a34c9
commit
3511cc2276
2 changed files with 12 additions and 9 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<IpluginOutputArgs> => {
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue