feat: add CLI args, health endpoint, and fix torznab search
- Add clap for CLI argument parsing (-c config, -p port)
- Add health endpoint showing service status at /api/health
- Add IndexerType enum for auto URL construction (jackett/prowlarr/torznab)
- Fix Axum 0.8 route syntax ({param} instead of :param)
- Fix torznab search to use 'q' param instead of artist/album (Jackett only supports q)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::config::IndexerConfig;
|
||||
use crate::config::{IndexerConfig, IndexerType};
|
||||
use crate::indexer::{Indexer, IndexerError, MusicSearchCriteria, SearchResult, TorznabIndexer};
|
||||
|
||||
pub struct IndexerService {
|
||||
@@ -19,13 +19,23 @@ impl IndexerService {
|
||||
let mut service = Self::new();
|
||||
|
||||
for config in configs {
|
||||
let indexer = TorznabIndexer::new(&config.name, &config.url, &config.api_key)?;
|
||||
let torznab_url = Self::build_torznab_url(&config.url, config.indexer_type);
|
||||
let indexer = TorznabIndexer::new(&config.name, &torznab_url, &config.api_key)?;
|
||||
service.add_indexer(Arc::new(indexer));
|
||||
}
|
||||
|
||||
Ok(service)
|
||||
}
|
||||
|
||||
fn build_torznab_url(base_url: &str, indexer_type: IndexerType) -> String {
|
||||
let base = base_url.trim_end_matches('/');
|
||||
match indexer_type {
|
||||
IndexerType::Jackett => format!("{}/api/v2.0/indexers/all/results/torznab/", base),
|
||||
IndexerType::Prowlarr => format!("{}/api/v1/indexer/all/torznab", base),
|
||||
IndexerType::Torznab => base_url.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_indexer(&mut self, indexer: Arc<dyn Indexer>) {
|
||||
self.indexers.insert(indexer.name().to_string(), indexer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user