mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-18 03:36:26 -07:00
Little more refactoring
This commit is contained in:
parent
09ba9b5dc6
commit
5c2d2814a6
2 changed files with 10 additions and 10 deletions
|
|
@ -172,7 +172,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
_a.label = 5;
|
_a.label = 5;
|
||||||
case 5: return [3 /*break*/, 7];
|
case 5: return [3 /*break*/, 7];
|
||||||
case 6:
|
case 6:
|
||||||
args.jobLog("\u2714 No ".concat(arr === 'radarr' ? 'movie' : 'serie', " with a file named '").concat(fileName, "'."));
|
args.jobLog("No ".concat(arr === 'radarr' ? 'movie' : 'serie', " with a file named '").concat(fileName, "'."));
|
||||||
_a.label = 7;
|
_a.label = 7;
|
||||||
case 7: return [2 /*return*/, pathWithNewName];
|
case 7: return [2 /*return*/, pathWithNewName];
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +205,7 @@ var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function
|
||||||
getFileToRename: function (previewRenameRequestResult) {
|
getFileToRename: function (previewRenameRequestResult) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
return (((_b = (_a = previewRenameRequestResult.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) ?
|
return (((_b = (_a = previewRenameRequestResult.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) ?
|
||||||
previewRenameRequestResult.data.find(function (episFile) { var _a, _b; return (((_b = (_a = episFile.episodeNumbers) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) ? episFile.episodeNumbers[0] === episodeNumber_1 : false; })
|
previewRenameRequestResult.data.find(function (episodeFile) { var _a, _b; return (((_b = (_a = episodeFile.episodeNumbers) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) ? episodeFile.episodeNumbers[0] === episodeNumber_1 : false; })
|
||||||
: undefined;
|
: undefined;
|
||||||
}
|
}
|
||||||
})];
|
})];
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,12 @@ const details = (): IpluginDetails => ({
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface IGetNewPathDelegates {
|
||||||
|
getId: (parseRequestResult: any) => string,
|
||||||
|
getPreviewRenameResquestUrl: (id: string, parseRequestResult: any) => string,
|
||||||
|
getFileToRename: (previewRenameRequestResult: any) => any
|
||||||
|
}
|
||||||
|
|
||||||
const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
const lib = require('../../../../../methods/lib')();
|
const 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
|
||||||
|
|
@ -76,12 +82,6 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
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 fileName = getFileName(args.inputFileObj._id);
|
const fileName = getFileName(args.inputFileObj._id);
|
||||||
|
|
||||||
interface IGetNewPathDelegates {
|
|
||||||
getId: (parseRequestResult: any) => string,
|
|
||||||
getPreviewRenameResquestUrl: (id: string, parseRequestResult: any) => string,
|
|
||||||
getFileToRename: (previewRenameRequestResult: any) => any
|
|
||||||
}
|
|
||||||
|
|
||||||
const getNewPath = async (delegates: IGetNewPathDelegates)
|
const getNewPath = async (delegates: IGetNewPathDelegates)
|
||||||
: Promise<string> => {
|
: Promise<string> => {
|
||||||
let pathWithNewName = '';
|
let pathWithNewName = '';
|
||||||
|
|
@ -130,7 +130,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
} else
|
} else
|
||||||
args.jobLog('✔ No rename necessary.');
|
args.jobLog('✔ No rename necessary.');
|
||||||
} else
|
} else
|
||||||
args.jobLog(`✔ No ${arr === 'radarr' ? 'movie' : 'serie'} with a file named '${fileName}'.`);
|
args.jobLog(`No ${arr === 'radarr' ? 'movie' : 'serie'} with a file named '${fileName}'.`);
|
||||||
|
|
||||||
return pathWithNewName;
|
return pathWithNewName;
|
||||||
};
|
};
|
||||||
|
|
@ -155,7 +155,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
},
|
},
|
||||||
getFileToRename: (previewRenameRequestResult) =>
|
getFileToRename: (previewRenameRequestResult) =>
|
||||||
((previewRenameRequestResult.data?.length ?? 0) > 0) ?
|
((previewRenameRequestResult.data?.length ?? 0) > 0) ?
|
||||||
previewRenameRequestResult.data.find((episFile: { episodeNumbers: number[]; }) => ((episFile.episodeNumbers?.length ?? 0) > 0) ? episFile.episodeNumbers[0] === episodeNumber : false)
|
previewRenameRequestResult.data.find((episodeFile: { episodeNumbers: number[]; }) => ((episodeFile.episodeNumbers?.length ?? 0) > 0) ? episodeFile.episodeNumbers[0] === episodeNumber : false)
|
||||||
: undefined
|
: undefined
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue