|
|
|
@ -100,7 +100,7 @@ var details = function () { return ({
|
|
|
|
],
|
|
|
|
],
|
|
|
|
}); };
|
|
|
|
}); };
|
|
|
|
exports.details = details;
|
|
|
|
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 imdbId, id, _a, _b, _c, _d;
|
|
|
|
var _e, _f, _g, _h, _j;
|
|
|
|
var _e, _f, _g, _h, _j;
|
|
|
|
return __generator(this, function (_k) {
|
|
|
|
return __generator(this, function (_k) {
|
|
|
|
@ -111,8 +111,8 @@ var getId = function (args, arr, arrHost, headers, fileName, refreshType) { retu
|
|
|
|
_b = Number;
|
|
|
|
_b = Number;
|
|
|
|
return [4 /*yield*/, args.deps.axios({
|
|
|
|
return [4 /*yield*/, args.deps.axios({
|
|
|
|
method: 'get',
|
|
|
|
method: 'get',
|
|
|
|
url: "".concat(arrHost, "/api/v3/").concat(arr === 'radarr' ? 'movie' : 'series', "/lookup?term=imdb:").concat(imdbId),
|
|
|
|
url: "".concat(arrApp.host, "/api/v3/").concat(arrApp.name === 'radarr' ? 'movie' : 'series', "/lookup?term=imdb:").concat(imdbId),
|
|
|
|
headers: headers,
|
|
|
|
headers: arrApp.headers,
|
|
|
|
})];
|
|
|
|
})];
|
|
|
|
case 1:
|
|
|
|
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]);
|
|
|
|
_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;
|
|
|
|
_k.label = 3;
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
id = _a;
|
|
|
|
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];
|
|
|
|
if (!(id === -1)) return [3 /*break*/, 5];
|
|
|
|
_d = (_c = refreshType.delegates).getIdFromParseResponse;
|
|
|
|
_d = (_c = arrApp.delegates).getIdFromParseResponse;
|
|
|
|
return [4 /*yield*/, args.deps.axios({
|
|
|
|
return [4 /*yield*/, args.deps.axios({
|
|
|
|
method: 'get',
|
|
|
|
method: 'get',
|
|
|
|
url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent((0, fileUtils_1.getFileName)(fileName))),
|
|
|
|
url: "".concat(arrApp.host, "/api/v3/parse?title=").concat(encodeURIComponent((0, fileUtils_1.getFileName)(fileName))),
|
|
|
|
headers: headers,
|
|
|
|
headers: arrApp.headers,
|
|
|
|
})];
|
|
|
|
})];
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
id = _d.apply(_c, [(_k.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), "'"));
|
|
|
|
args.jobLog("".concat(arrApp.content, " ").concat(id !== -1 ? "'".concat(id, "' found") : 'not found', " for '").concat((0, fileUtils_1.getFileName)(fileName), "'"));
|
|
|
|
_k.label = 5;
|
|
|
|
_k.label = 5;
|
|
|
|
case 5: return [2 /*return*/, id];
|
|
|
|
case 5: return [2 /*return*/, id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}); };
|
|
|
|
}); };
|
|
|
|
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
|
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;
|
|
|
|
var _a, _b, _c, _d;
|
|
|
|
return __generator(this, function (_e) {
|
|
|
|
return __generator(this, function (_e) {
|
|
|
|
switch (_e.label) {
|
|
|
|
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),
|
|
|
|
'X-Api-Key': String(args.inputs.arr_api_key),
|
|
|
|
Accept: 'application/json',
|
|
|
|
Accept: 'application/json',
|
|
|
|
};
|
|
|
|
};
|
|
|
|
refreshType = arr === 'radarr'
|
|
|
|
arrApp = arr === 'radarr'
|
|
|
|
? {
|
|
|
|
? {
|
|
|
|
appName: 'Radarr',
|
|
|
|
name: arr,
|
|
|
|
|
|
|
|
host: arrHost,
|
|
|
|
|
|
|
|
headers: headers,
|
|
|
|
content: 'Movie',
|
|
|
|
content: 'Movie',
|
|
|
|
delegates: {
|
|
|
|
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] }); },
|
|
|
|
buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }); },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
: {
|
|
|
|
: {
|
|
|
|
appName: 'Sonarr',
|
|
|
|
name: arr,
|
|
|
|
|
|
|
|
host: arrHost,
|
|
|
|
|
|
|
|
headers: headers,
|
|
|
|
content: 'Serie',
|
|
|
|
content: 'Serie',
|
|
|
|
delegates: {
|
|
|
|
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 }); },
|
|
|
|
buildRefreshResquestData: function (id) { return JSON.stringify({ name: 'RefreshSeries', seriesId: id }); },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
args.jobLog('Going to force scan');
|
|
|
|
args.jobLog('Going to force scan');
|
|
|
|
args.jobLog("Refreshing ".concat(refreshType.appName, "..."));
|
|
|
|
args.jobLog("Refreshing ".concat(arrApp.name, "..."));
|
|
|
|
return [4 /*yield*/, getId(args, arr, arrHost, headers, originalFileName, refreshType)];
|
|
|
|
return [4 /*yield*/, getId(args, arrApp, originalFileName)];
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
id = _e.sent();
|
|
|
|
id = _e.sent();
|
|
|
|
if (!(id === -1 && currentFileName !== originalFileName)) return [3 /*break*/, 3];
|
|
|
|
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:
|
|
|
|
case 2:
|
|
|
|
id = _e.sent();
|
|
|
|
id = _e.sent();
|
|
|
|
_e.label = 3;
|
|
|
|
_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
|
|
|
|
// Using command endpoint to queue a refresh task
|
|
|
|
return [4 /*yield*/, args.deps.axios({
|
|
|
|
return [4 /*yield*/, args.deps.axios({
|
|
|
|
method: 'post',
|
|
|
|
method: 'post',
|
|
|
|
url: "".concat(arrHost, "/api/v3/command"),
|
|
|
|
url: "".concat(arrApp.host, "/api/v3/command"),
|
|
|
|
headers: headers,
|
|
|
|
headers: headers,
|
|
|
|
data: refreshType.delegates.buildRefreshResquestData(id),
|
|
|
|
data: arrApp.delegates.buildRefreshResquestData(id),
|
|
|
|
})];
|
|
|
|
})];
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
// Using command endpoint to queue a refresh task
|
|
|
|
// Using command endpoint to queue a refresh task
|
|
|
|
_e.sent();
|
|
|
|
_e.sent();
|
|
|
|
refreshed = true;
|
|
|
|
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;
|
|
|
|
_e.label = 5;
|
|
|
|
case 5: return [2 /*return*/, {
|
|
|
|
case 5: return [2 /*return*/, {
|
|
|
|
outputFileObj: args.inputFileObj,
|
|
|
|
outputFileObj: args.inputFileObj,
|
|
|
|
|