Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use original library file #557

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -117,12 +118,12 @@ 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();
movieId = res.data.movie.movieFile.movieId;
requestConfig2 = {
method: 'post',
Expand All @@ -135,20 +136,20 @@ 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:
if (!(arr === 'sonarr')) return [3 /*break*/, 6];
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',
Expand All @@ -161,12 +162,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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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,
};

Expand All @@ -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,
};

Expand Down