Add multi-download-client support and UI management

Implements support for configuring both qBittorrent and SABnzbd simultaneously, including migration from legacy config, protocol-aware routing, and protocol filtering. Adds new CRUD API routes for download clients, new UI management components, and updates setup and settings flows to use the new multi-client architecture. Updates documentation to describe the new structure and usage.
This commit is contained in:
kikootwo
2026-01-29 09:21:33 -05:00
parent 3290ebbc9d
commit 2cda6decbe
26 changed files with 3452 additions and 924 deletions
+28 -12
View File
@@ -589,27 +589,43 @@ export async function getSABnzbdService(): Promise<SABnzbdService> {
return sabnzbdServiceInstance;
}
// Load configuration from database
// Load configuration from download client manager (uses new multi-client config format)
const { getConfigService } = await import('../services/config.service');
const config = await getConfigService();
const { getDownloadClientManager } = await import('../services/download-client-manager.service');
const configService = await getConfigService();
const manager = getDownloadClientManager(configService);
const url = await config.get('download_client_url');
const apiKey = await config.get('download_client_password'); // Reuse password field for API key
const category = (await config.get('sabnzbd_category')) || 'readmeabook';
const disableSSL = ((await config.get('download_client_disable_ssl_verify')) || 'false') === 'true';
logger.info('Loading configuration from download client manager...');
const clientConfig = await manager.getClientForProtocol('usenet');
if (!url) {
throw new Error('SABnzbd URL not configured. Please configure download client settings.');
if (!clientConfig) {
throw new Error('SABnzbd is not configured. Please configure a SABnzbd client in the admin settings.');
}
if (!apiKey) {
throw new Error('SABnzbd API key not configured. Please configure download client settings.');
if (clientConfig.type !== 'sabnzbd') {
throw new Error(`Expected SABnzbd client but found ${clientConfig.type}`);
}
sabnzbdServiceInstance = new SABnzbdService(url, apiKey, category, disableSSL);
logger.info('Config loaded:', {
name: clientConfig.name,
hasUrl: !!clientConfig.url,
hasApiKey: !!clientConfig.password,
disableSSLVerify: clientConfig.disableSSLVerify,
});
if (!clientConfig.url || !clientConfig.password) {
throw new Error('SABnzbd is not fully configured. Please check your configuration in admin settings.');
}
sabnzbdServiceInstance = new SABnzbdService(
clientConfig.url,
clientConfig.password, // API key stored in password field
clientConfig.category || 'readmeabook',
clientConfig.disableSSLVerify
);
// Ensure category exists
const downloadDir = await config.get('download_dir');
const downloadDir = await configService.get('download_dir');
await sabnzbdServiceInstance.ensureCategory(downloadDir || undefined);
return sabnzbdServiceInstance;