Use original library file

make-only-subtitle-default
HaveAGitGat 2 years ago
parent 107161ebfb
commit f87bad2549

@ -96,16 +96,17 @@ var details = function () { return ({
}); };
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, meta, arrHost, headers, requestConfig, res, movieId, requestConfig2, requestConfig, res, seriesId, requestConfig2;
return __generator(this, function (_b) {
switch (_b.label) {
var lib, _a, arr, arr_api_key, arr_host, fileName, arrHost, headers, requestConfig, res, movieId, requestConfig2, requestConfig, res, seriesId, requestConfig2;
var _b, _c;
return __generator(this, function (_d) {
switch (_d.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();
meta = args.inputFileObj.meta;
fileName = ((_c = (_b = args.originalLibraryFile) === null || _b === void 0 ? void 0 : _b.meta) === null || _c === void 0 ? void 0 : _c.FileName) || '';
arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host;
headers = {
'Content-Type': 'application/json',
@ -117,12 +118,13 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
args.jobLog('Refreshing Radarr...');
requestConfig = {
method: 'get',
url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent((meta === null || meta === void 0 ? void 0 : meta.FileName) || '')),
url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent(fileName)),
headers: headers,
};
return [4 /*yield*/, args.deps.axios(requestConfig)];
case 1:
res = _b.sent();
res = _d.sent();
console.log(res.data);
movieId = res.data.movie.movieFile.movieId;
requestConfig2 = {
method: 'post',
@ -135,7 +137,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
};
return [4 /*yield*/, args.deps.axios(requestConfig2)];
case 2:
_b.sent();
_d.sent();
args.jobLog("\u2714 Refreshed movie ".concat(movieId, " in Radarr."));
return [3 /*break*/, 7];
case 3:
@ -143,12 +145,12 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
args.jobLog('Refreshing Sonarr...');
requestConfig = {
method: 'get',
url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent((meta === null || meta === void 0 ? void 0 : meta.FileName) || '')),
url: "".concat(arrHost, "/api/v3/parse?title=").concat(encodeURIComponent(fileName)),
headers: headers,
};
return [4 /*yield*/, args.deps.axios(requestConfig)];
case 4:
res = _b.sent();
res = _d.sent();
seriesId = res.data.series.id;
requestConfig2 = {
method: 'post',
@ -161,12 +163,12 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
};
return [4 /*yield*/, args.deps.axios(requestConfig2)];
case 5:
_b.sent();
_d.sent();
args.jobLog("\u2714 Refreshed series ".concat(seriesId, " in Sonarr."));
return [3 /*break*/, 7];
case 6:
args.jobLog('No arr specified in plugin inputs.');
_b.label = 7;
_d.label = 7;
case 7: return [2 /*return*/, {
outputFileObj: args.inputFileObj,
outputNumber: 1,

@ -70,7 +70,8 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
const { arr, arr_api_key } = args.inputs;
const arr_host = String(args.inputs.arr_host).trim();
const { meta } = args.inputFileObj;
const fileName = args.originalLibraryFile?.meta?.FileName || '';
const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host;
const headers = {
@ -86,7 +87,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
const requestConfig = {
method: 'get',
url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(meta?.FileName || '')}`,
url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(fileName)}`,
headers,
};
@ -111,7 +112,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
const requestConfig = {
method: 'get',
url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(meta?.FileName || '')}`,
url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(fileName)}`,
headers,
};

Loading…
Cancel
Save