mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 23:45:48 +01:00
♻️ Move nzbget sdk to routers
This commit is contained in:
@@ -13,8 +13,8 @@ import { NextApiRequest, NextApiResponse } from 'next';
|
|||||||
|
|
||||||
import { Client } from 'sabnzbd-api';
|
import { Client } from 'sabnzbd-api';
|
||||||
|
|
||||||
import { NzbgetClient } from '../usenet/nzbget/nzbget-client';
|
import { NzbgetClient } from '../../../../server/api/routers/usenet/nzbget/nzbget-client';
|
||||||
import { NzbgetQueueItem, NzbgetStatus } from '../usenet/nzbget/types';
|
import { NzbgetQueueItem, NzbgetStatus } from '../../../../server/api/routers/usenet/nzbget/types';
|
||||||
import { ConfigAppType, IntegrationField } from '../../../../types/app';
|
import { ConfigAppType, IntegrationField } from '../../../../types/app';
|
||||||
import { getConfig } from '../../../../tools/config/getConfig';
|
import { getConfig } from '../../../../tools/config/getConfig';
|
||||||
import { UsenetQueueItem } from '../../../../widgets/useNet/types';
|
import { UsenetQueueItem } from '../../../../widgets/useNet/types';
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import dayjs from 'dayjs';
|
|||||||
import duration from 'dayjs/plugin/duration';
|
import duration from 'dayjs/plugin/duration';
|
||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import { Client } from 'sabnzbd-api';
|
import { Client } from 'sabnzbd-api';
|
||||||
import { NzbgetHistoryItem } from './nzbget/types';
|
import { NzbgetHistoryItem } from '../../../../server/api/routers/usenet/nzbget/types';
|
||||||
import { NzbgetClient } from './nzbget/nzbget-client';
|
import { NzbgetClient } from '../../../../server/api/routers/usenet/nzbget/nzbget-client';
|
||||||
import { getConfig } from '../../../../tools/config/getConfig';
|
import { getConfig } from '../../../../tools/config/getConfig';
|
||||||
import { UsenetHistoryItem } from '../../../../widgets/useNet/types';
|
import { UsenetHistoryItem } from '../../../../widgets/useNet/types';
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import duration from 'dayjs/plugin/duration';
|
|||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import { Client } from 'sabnzbd-api';
|
import { Client } from 'sabnzbd-api';
|
||||||
import { getConfig } from '../../../../tools/config/getConfig';
|
import { getConfig } from '../../../../tools/config/getConfig';
|
||||||
import { NzbgetClient } from './nzbget/nzbget-client';
|
import { NzbgetClient } from '../../../../server/api/routers/usenet/nzbget/nzbget-client';
|
||||||
import { NzbgetStatus } from './nzbget/types';
|
import { NzbgetStatus } from '../../../../server/api/routers/usenet/nzbget/types';
|
||||||
|
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
declare module 'nzbget-api';
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import NZBGet from 'nzbget-api';
|
|
||||||
import { NzbgetClientOptions } from './types';
|
|
||||||
|
|
||||||
export function NzbgetClient(options: NzbgetClientOptions) {
|
|
||||||
if (!options?.host) {
|
|
||||||
throw new Error('Cannot connect to NZBGet. Missing host in app config.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options?.port) {
|
|
||||||
throw new Error('Cannot connect to NZBGet. Missing port in app config.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options?.login) {
|
|
||||||
throw new Error('Cannot connect to NZBGet. Missing username in app config.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options?.hash) {
|
|
||||||
throw new Error('Cannot connect to NZBGet. Missing password in app config.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return new NZBGet(options);
|
|
||||||
}
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
export interface NzbgetHistoryItem {
|
|
||||||
NZBID: number;
|
|
||||||
Kind: 'NZB' | 'URL' | 'DUP';
|
|
||||||
NZBFilename: string;
|
|
||||||
Name: string;
|
|
||||||
URL: string;
|
|
||||||
HistoryTime: number;
|
|
||||||
DestDir: string;
|
|
||||||
FinalDir: string;
|
|
||||||
Category: string;
|
|
||||||
FileSizeLo: number;
|
|
||||||
FileSizeHi: number;
|
|
||||||
FileSizeMB: number;
|
|
||||||
FileCount: number;
|
|
||||||
RemainingFileCount: number;
|
|
||||||
MinPostTime: number;
|
|
||||||
MaxPostTime: number;
|
|
||||||
TotalArticles: number;
|
|
||||||
SuccessArticles: number;
|
|
||||||
FailedArticles: number;
|
|
||||||
Health: number;
|
|
||||||
DownloadedSizeLo: number;
|
|
||||||
DownloadedSizeHi: number;
|
|
||||||
DownloadedSizeMB: number;
|
|
||||||
DownloadTimeSec: number;
|
|
||||||
PostTotalTimeSec: number;
|
|
||||||
ParTimeSec: number;
|
|
||||||
RepairTimeSec: number;
|
|
||||||
UnpackTimeSec: number;
|
|
||||||
MessageCount: number;
|
|
||||||
DupeKey: string;
|
|
||||||
DupeScore: number;
|
|
||||||
DupeMode: 'SCORE' | 'ALL' | 'FORCE';
|
|
||||||
Status: string;
|
|
||||||
ParStatus: 'NONE' | 'FAILURE' | 'REPAIR_POSSIBLE' | 'SUCCESS' | 'MANUAL';
|
|
||||||
ExParStatus: 'RECIPIENT' | 'DONOR';
|
|
||||||
UnpackStatus: 'NONE' | 'FAILURE' | 'SPACE' | 'PASSWORD' | 'SUCCESS';
|
|
||||||
UrlStatus: 'NONE' | 'SUCCESS' | 'FAILURE' | 'SCAN_SKIPPED' | 'SCAN_FAILURE';
|
|
||||||
ScriptStatus: 'NONE' | 'FAILURE' | 'SUCCESS';
|
|
||||||
ScriptStatuses: [];
|
|
||||||
MoveStatus: 'NONE' | 'SUCCESS' | 'FAILURE';
|
|
||||||
DeleteStatus: 'NONE' | 'MANUAL' | 'HEALTH' | 'DUPE' | 'BAD' | 'SCAN' | 'COPY';
|
|
||||||
MarkStatus: 'NONE' | 'GOOD' | 'BAD';
|
|
||||||
ExtraParBlocks: number;
|
|
||||||
Parameters: [];
|
|
||||||
ServerStats: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NzbgetQueueItem {
|
|
||||||
NZBID: number;
|
|
||||||
NZBFilename: string;
|
|
||||||
NZBName: string;
|
|
||||||
Kind: 'NZB' | 'URL';
|
|
||||||
URL: string;
|
|
||||||
DestDir: string;
|
|
||||||
FinalDir: string;
|
|
||||||
Category: string;
|
|
||||||
FileSizeLo: number;
|
|
||||||
FileSizeHi: number;
|
|
||||||
FileSizeMB: number;
|
|
||||||
RemainingSizeLo: number;
|
|
||||||
RemainingSizeHi: number;
|
|
||||||
RemainingSizeMB: number;
|
|
||||||
PausedSizeLo: number;
|
|
||||||
PausedSizeHi: number;
|
|
||||||
PausedSizeMB: number;
|
|
||||||
FileCount: number;
|
|
||||||
RemainingFileCount: number;
|
|
||||||
RemainingParCount: number;
|
|
||||||
MinPostTime: number;
|
|
||||||
MaxPostTime: number;
|
|
||||||
MaxPriority: number;
|
|
||||||
ActiveDownloads: number;
|
|
||||||
Status:
|
|
||||||
| 'QUEUED'
|
|
||||||
| 'PAUSED'
|
|
||||||
| 'DOWNLOADING'
|
|
||||||
| 'FETCHING'
|
|
||||||
| 'PP_QUEUED'
|
|
||||||
| 'LOADING_PARS'
|
|
||||||
| 'VERIFYING_SOURCES'
|
|
||||||
| 'REPAIRING'
|
|
||||||
| 'VERIFYING_REPAIRED'
|
|
||||||
| 'RENAMING'
|
|
||||||
| 'UNPACKING'
|
|
||||||
| 'MOVING'
|
|
||||||
| 'EXECUTING_SCRIPT'
|
|
||||||
| 'PP_FINISHED';
|
|
||||||
TotalArticles: number;
|
|
||||||
SuccessArticles: number;
|
|
||||||
FailedArticles: number;
|
|
||||||
Health: number;
|
|
||||||
CriticalHealth: number;
|
|
||||||
DownloadedSizeLo: number;
|
|
||||||
DownloadedSizeHi: number;
|
|
||||||
DownloadedSizeMB: number;
|
|
||||||
DownloadTimeSec: number;
|
|
||||||
MessageCount: number;
|
|
||||||
DupeKey: string;
|
|
||||||
DupeScore: number;
|
|
||||||
DupeMode: string;
|
|
||||||
Parameters: [];
|
|
||||||
ServerStats: [];
|
|
||||||
PostInfoText: string;
|
|
||||||
PostStageProgress: number;
|
|
||||||
PostTotalTimeSec: number;
|
|
||||||
PostStageTimeSec: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NzbgetStatus {
|
|
||||||
RemainingSizeLo: number;
|
|
||||||
RemainingSizeHi: number;
|
|
||||||
RemainingSizeMB: number;
|
|
||||||
ForcedSizeLo: number;
|
|
||||||
ForcedSizeHi: number;
|
|
||||||
ForcedSizeMB: number;
|
|
||||||
DownloadedSizeLo: number;
|
|
||||||
DownloadedSizeHi: number;
|
|
||||||
DownloadedSizeMB: number;
|
|
||||||
ArticleCacheLo: number;
|
|
||||||
ArticleCacheHi: number;
|
|
||||||
ArticleCacheMB: number;
|
|
||||||
DownloadRate: number;
|
|
||||||
AverageDownloadRate: number;
|
|
||||||
DownloadLimit: number;
|
|
||||||
ThreadCount: number;
|
|
||||||
PostJobCount: number;
|
|
||||||
UrlCount: number;
|
|
||||||
UpTimeSec: number;
|
|
||||||
DownloadTimeSec: number;
|
|
||||||
ServerStandBy: boolean;
|
|
||||||
DownloadPaused: boolean;
|
|
||||||
PostPaused: boolean;
|
|
||||||
ScanPaused: boolean;
|
|
||||||
ServerTime: number;
|
|
||||||
ResumeTime: number;
|
|
||||||
FeedActive: boolean;
|
|
||||||
FreeDiskSpaceLo: number;
|
|
||||||
FreeDiskSpaceHi: number;
|
|
||||||
FreeDiskSpaceMB: number;
|
|
||||||
NewsServers: [];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NzbgetClientOptions {
|
|
||||||
host: string;
|
|
||||||
port: string;
|
|
||||||
login: string | undefined;
|
|
||||||
hash: string | undefined;
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ import duration from 'dayjs/plugin/duration';
|
|||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import { Client } from 'sabnzbd-api';
|
import { Client } from 'sabnzbd-api';
|
||||||
import { getConfig } from '../../../../tools/config/getConfig';
|
import { getConfig } from '../../../../tools/config/getConfig';
|
||||||
import { NzbgetClient } from './nzbget/nzbget-client';
|
import { NzbgetClient } from '../../../../server/api/routers/usenet/nzbget/nzbget-client';
|
||||||
|
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import { NextApiRequest, NextApiResponse } from 'next';
|
|||||||
import { Client } from 'sabnzbd-api';
|
import { Client } from 'sabnzbd-api';
|
||||||
import { getConfig } from '../../../../tools/config/getConfig';
|
import { getConfig } from '../../../../tools/config/getConfig';
|
||||||
import { UsenetQueueItem } from '../../../../widgets/useNet/types';
|
import { UsenetQueueItem } from '../../../../widgets/useNet/types';
|
||||||
import { NzbgetClient } from './nzbget/nzbget-client';
|
import { NzbgetClient } from '../../../../server/api/routers/usenet/nzbget/nzbget-client';
|
||||||
import { NzbgetQueueItem, NzbgetStatus } from './nzbget/types';
|
import { NzbgetQueueItem, NzbgetStatus } from '../../../../server/api/routers/usenet/nzbget/types';
|
||||||
|
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import duration from 'dayjs/plugin/duration';
|
|||||||
import { NextApiRequest, NextApiResponse } from 'next';
|
import { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import { Client } from 'sabnzbd-api';
|
import { Client } from 'sabnzbd-api';
|
||||||
import { getConfig } from '../../../../tools/config/getConfig';
|
import { getConfig } from '../../../../tools/config/getConfig';
|
||||||
import { NzbgetClient } from './nzbget/nzbget-client';
|
import { NzbgetClient } from '../../../../server/api/routers/usenet/nzbget/nzbget-client';
|
||||||
|
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user