存至私人影库增加下载方式

This commit is contained in:
mtvpls
2026-05-21 23:46:26 +08:00
parent e44f565112
commit a24de1346f
8 changed files with 159 additions and 16 deletions
+1
View File
@@ -343,6 +343,7 @@ export interface AdminConfig {
};
AnimeSubscriptionConfig?: {
Enabled: boolean; // 是否启用追番功能
DownloadTool?: 'aria2' | 'qBittorrent' | 'Transmission'; // 追番订阅全局下载方式
Subscriptions: Array<{
id: string;
title: string;
+13 -2
View File
@@ -6,7 +6,15 @@ import { getConfig, setCachedConfig } from '@/lib/config';
import { db, getStorage } from '@/lib/db';
import { EmailService } from '@/lib/email.service';
import { OpenListClient } from '@/lib/openlist.client';
import { AnimeSubscription } from '@/types/anime-subscription';
import { AnimeSubscription, AnimeSubscriptionDownloadTool } from '@/types/anime-subscription';
const downloadTools: AnimeSubscriptionDownloadTool[] = ['aria2', 'qBittorrent', 'Transmission'];
function getAnimeSubscriptionDownloadTool(tool: unknown): AnimeSubscriptionDownloadTool {
return typeof tool === 'string' && downloadTools.includes(tool as AnimeSubscriptionDownloadTool)
? tool as AnimeSubscriptionDownloadTool
: 'aria2';
}
/**
* 从标题中提取集数
@@ -121,6 +129,9 @@ export async function addOfflineDownload(
) {
const config = await getConfig();
const openlistConfig = config.OpenListConfig;
const downloadTool = getAnimeSubscriptionDownloadTool(
config.AnimeSubscriptionConfig?.DownloadTool
);
if (!openlistConfig?.Enabled) {
throw new Error('私人影库功能未启用');
@@ -152,7 +163,7 @@ export async function addOfflineDownload(
body: JSON.stringify({
path: downloadPath,
urls: [torrentUrl],
tool: 'aria2',
tool: downloadTool,
}),
});