mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-15 02:05:54 -07:00
Merge pull request #557 from HaveAGitGat/filename
Use original library file
This commit is contained in:
commit
3d717fd866
2 changed files with 16 additions and 14 deletions
|
|
@ -96,16 +96,17 @@ var details = function () { return ({
|
||||||
}); };
|
}); };
|
||||||
exports.details = details;
|
exports.details = details;
|
||||||
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, _a, arr, arr_api_key, arr_host, meta, arrHost, headers, requestConfig, res, movieId, requestConfig2, requestConfig, res, seriesId, requestConfig2;
|
var lib, _a, arr, arr_api_key, arr_host, fileName, arrHost, headers, requestConfig, res, movieId, requestConfig2, requestConfig, res, seriesId, requestConfig2;
|
||||||
return __generator(this, function (_b) {
|
var _b, _c;
|
||||||
switch (_b.label) {
|
return __generator(this, function (_d) {
|
||||||
|
switch (_d.label) {
|
||||||
case 0:
|
case 0:
|
||||||
lib = require('../../../../../methods/lib')();
|
lib = require('../../../../../methods/lib')();
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
||||||
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
||||||
_a = args.inputs, arr = _a.arr, arr_api_key = _a.arr_api_key;
|
_a = args.inputs, arr = _a.arr, arr_api_key = _a.arr_api_key;
|
||||||
arr_host = String(args.inputs.arr_host).trim();
|
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;
|
arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host;
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
@ -117,12 +118,12 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
args.jobLog('Refreshing Radarr...');
|
args.jobLog('Refreshing Radarr...');
|
||||||
requestConfig = {
|
requestConfig = {
|
||||||
method: 'get',
|
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,
|
headers: headers,
|
||||||
};
|
};
|
||||||
return [4 /*yield*/, args.deps.axios(requestConfig)];
|
return [4 /*yield*/, args.deps.axios(requestConfig)];
|
||||||
case 1:
|
case 1:
|
||||||
res = _b.sent();
|
res = _d.sent();
|
||||||
movieId = res.data.movie.movieFile.movieId;
|
movieId = res.data.movie.movieFile.movieId;
|
||||||
requestConfig2 = {
|
requestConfig2 = {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|
@ -135,7 +136,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
};
|
};
|
||||||
return [4 /*yield*/, args.deps.axios(requestConfig2)];
|
return [4 /*yield*/, args.deps.axios(requestConfig2)];
|
||||||
case 2:
|
case 2:
|
||||||
_b.sent();
|
_d.sent();
|
||||||
args.jobLog("\u2714 Refreshed movie ".concat(movieId, " in Radarr."));
|
args.jobLog("\u2714 Refreshed movie ".concat(movieId, " in Radarr."));
|
||||||
return [3 /*break*/, 7];
|
return [3 /*break*/, 7];
|
||||||
case 3:
|
case 3:
|
||||||
|
|
@ -143,12 +144,12 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
args.jobLog('Refreshing Sonarr...');
|
args.jobLog('Refreshing Sonarr...');
|
||||||
requestConfig = {
|
requestConfig = {
|
||||||
method: 'get',
|
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,
|
headers: headers,
|
||||||
};
|
};
|
||||||
return [4 /*yield*/, args.deps.axios(requestConfig)];
|
return [4 /*yield*/, args.deps.axios(requestConfig)];
|
||||||
case 4:
|
case 4:
|
||||||
res = _b.sent();
|
res = _d.sent();
|
||||||
seriesId = res.data.series.id;
|
seriesId = res.data.series.id;
|
||||||
requestConfig2 = {
|
requestConfig2 = {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|
@ -161,12 +162,12 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
};
|
};
|
||||||
return [4 /*yield*/, args.deps.axios(requestConfig2)];
|
return [4 /*yield*/, args.deps.axios(requestConfig2)];
|
||||||
case 5:
|
case 5:
|
||||||
_b.sent();
|
_d.sent();
|
||||||
args.jobLog("\u2714 Refreshed series ".concat(seriesId, " in Sonarr."));
|
args.jobLog("\u2714 Refreshed series ".concat(seriesId, " in Sonarr."));
|
||||||
return [3 /*break*/, 7];
|
return [3 /*break*/, 7];
|
||||||
case 6:
|
case 6:
|
||||||
args.jobLog('No arr specified in plugin inputs.');
|
args.jobLog('No arr specified in plugin inputs.');
|
||||||
_b.label = 7;
|
_d.label = 7;
|
||||||
case 7: return [2 /*return*/, {
|
case 7: return [2 /*return*/, {
|
||||||
outputFileObj: args.inputFileObj,
|
outputFileObj: args.inputFileObj,
|
||||||
outputNumber: 1,
|
outputNumber: 1,
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ 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 { meta } = args.inputFileObj;
|
const fileName = args.originalLibraryFile?.meta?.FileName || '';
|
||||||
|
|
||||||
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 headers = {
|
const headers = {
|
||||||
|
|
@ -86,7 +87,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
|
|
||||||
const requestConfig = {
|
const requestConfig = {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(meta?.FileName || '')}`,
|
url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(fileName)}`,
|
||||||
headers,
|
headers,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -111,7 +112,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
|
|
||||||
const requestConfig = {
|
const requestConfig = {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(meta?.FileName || '')}`,
|
url: `${arrHost}/api/v3/parse?title=${encodeURIComponent(fileName)}`,
|
||||||
headers,
|
headers,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue