mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-11 00:10:29 -07:00
Fix eslint warnings and errors
This commit is contained in:
parent
e581a90864
commit
142134a192
2 changed files with 30 additions and 29 deletions
|
|
@ -1,7 +1,4 @@
|
|||
import { get } from 'http';
|
||||
import {
|
||||
getContainer, getFileAbosluteDir, getFileName,
|
||||
} from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
import { getFileName } from '../../../../FlowHelpers/1.0.0/fileUtils';
|
||||
import {
|
||||
IpluginDetails,
|
||||
IpluginInputArgs,
|
||||
|
|
@ -72,7 +69,7 @@ const details = (): IpluginDetails => ({
|
|||
|
||||
interface IFileNames {
|
||||
originalFileName: string,
|
||||
currentFileName : string
|
||||
currentFileName: string
|
||||
}
|
||||
interface IRefreshDelegates {
|
||||
getIdFromParseRequestResult: (parseRequestResult: any) => number,
|
||||
|
|
@ -96,9 +93,9 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
const { arr, arr_api_key } = args.inputs;
|
||||
const arr_host = String(args.inputs.arr_host).trim();
|
||||
const arrHost = arr_host.endsWith('/') ? arr_host.slice(0, -1) : arr_host;
|
||||
const fileNames : IFileNames = {
|
||||
originalFileName : getFileName(args.originalLibraryFile?._id ?? ''),
|
||||
currentFileName: getFileName(args.inputFileObj?._id ?? '')
|
||||
const fileNames: IFileNames = {
|
||||
originalFileName: getFileName(args.originalLibraryFile?._id ?? ''),
|
||||
currentFileName: getFileName(args.inputFileObj?._id ?? ''),
|
||||
};
|
||||
|
||||
const refresh = async (refreshType: IRefreshType)
|
||||
|
|
@ -113,8 +110,8 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
Accept: 'application/json',
|
||||
};
|
||||
|
||||
const getId = async (fileName : string)
|
||||
: Promise<number> => {
|
||||
const getId = async (fileName: string)
|
||||
: Promise<number> => {
|
||||
// Using parse endpoint to get the movie/serie's id.
|
||||
const parseRequestConfig = {
|
||||
method: 'get',
|
||||
|
|
@ -123,16 +120,16 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
};
|
||||
const parseRequestResult = await args.deps.axios(parseRequestConfig);
|
||||
const id = refreshType.delegates.getIdFromParseRequestResult(parseRequestResult);
|
||||
args.jobLog(id !== -1 ?
|
||||
`Found ${refreshType.contentName} ${id} with a file named '${fileName}'`
|
||||
args.jobLog(id !== -1
|
||||
? `Found ${refreshType.contentName} ${id} with a file named '${fileName}'`
|
||||
: `Didn't find ${refreshType.contentName} with a file named '${fileName}' in ${arrHost}.`);
|
||||
return id;
|
||||
}
|
||||
};
|
||||
|
||||
let fileName = fileNames.originalFileName;
|
||||
let id = await getId(fileName);
|
||||
// In case there has been a name change and the arr app already noticed it.
|
||||
if(id == -1 && fileNames.currentFileName !== fileNames.originalFileName) {
|
||||
if (id === -1 && fileNames.currentFileName !== fileNames.originalFileName) {
|
||||
fileName = fileNames.currentFileName;
|
||||
id = await getId(fileName);
|
||||
}
|
||||
|
|
@ -144,7 +141,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
method: 'post',
|
||||
url: `${arrHost}/api/v3/command`,
|
||||
headers,
|
||||
data: refreshType.delegates.buildRefreshResquestData(id)
|
||||
data: refreshType.delegates.buildRefreshResquestData(id),
|
||||
};
|
||||
await args.deps.axios(refreshResquestConfig);
|
||||
|
||||
|
|
@ -160,16 +157,20 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
appName: 'Radarr',
|
||||
contentName: 'movie',
|
||||
delegates: {
|
||||
getIdFromParseRequestResult: (parseRequestResult) => Number(parseRequestResult.data?.movie?.movieFile?.movieId ?? -1),
|
||||
buildRefreshResquestData: id => JSON.stringify({ name: 'RefreshMovie', movieIds: [id] })
|
||||
}
|
||||
getIdFromParseRequestResult:
|
||||
(parseRequestResult) => Number(parseRequestResult.data?.movie?.movieFile?.movieId ?? -1),
|
||||
buildRefreshResquestData:
|
||||
(id) => JSON.stringify({ name: 'RefreshMovie', movieIds: [id] }),
|
||||
},
|
||||
},
|
||||
sonarr: {
|
||||
appName: 'Sonarr',
|
||||
contentName: 'serie',
|
||||
delegates: {
|
||||
getIdFromParseRequestResult: (parseRequestResult) => Number(parseRequestResult.data?.series?.id ?? -1),
|
||||
buildRefreshResquestData: id => JSON.stringify({ name: 'RefreshSeries', seriesId: id })
|
||||
getIdFromParseRequestResult:
|
||||
(parseRequestResult) => Number(parseRequestResult.data?.series?.id ?? -1),
|
||||
buildRefreshResquestData:
|
||||
(id) => JSON.stringify({ name: 'RefreshSeries', seriesId: id }),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -186,4 +187,4 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
|||
export {
|
||||
details,
|
||||
plugin,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue