add yt_dlp module + db
This commit is contained in:
parent
5941f61c8c
commit
1f32c21363
8 changed files with 447 additions and 159 deletions
26
src/main.rs
26
src/main.rs
|
@ -3,9 +3,12 @@ use std::path::PathBuf;
|
|||
mod config;
|
||||
mod db;
|
||||
mod youtube;
|
||||
mod yt_dlp;
|
||||
|
||||
use config::GlobalConfig;
|
||||
|
||||
use crate::yt_dlp::YtDlpModule;
|
||||
|
||||
// todo : migrate to async code?
|
||||
// todo : better log options
|
||||
|
||||
|
@ -38,18 +41,33 @@ fn main() {
|
|||
|
||||
log::info!("Starting hoard");
|
||||
|
||||
let db = db::Database::new("download.db");
|
||||
let db = db::DatabaseBackend::new("download.db");
|
||||
let config: GlobalConfig =
|
||||
toml::from_str(&std::fs::read_to_string("config.toml").unwrap()).unwrap();
|
||||
|
||||
ensure_dir_exists(&config.hoard.data_dir);
|
||||
|
||||
let modules: Vec<Box<dyn Module>> = vec![Box::new(youtube::YouTubeModule::new(
|
||||
let mut modules: Vec<Box<dyn Module>> = vec![Box::new(youtube::YouTubeModule::new(
|
||||
config.youtube.unwrap(),
|
||||
db,
|
||||
db.take_db(),
|
||||
config.hoard.data_dir.join("youtube"),
|
||||
))];
|
||||
|
||||
for yt_dlp_mod in config.yt_dlp.unwrap_or_default() {
|
||||
let mod_name = yt_dlp_mod
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_else(|| "yt_dlp".to_string());
|
||||
modules.push(Box::new(YtDlpModule::new(
|
||||
yt_dlp_mod,
|
||||
db.take_db(),
|
||||
config.hoard.data_dir.join(mod_name),
|
||||
)));
|
||||
}
|
||||
|
||||
let _db_thread = std::thread::spawn(move || {
|
||||
db.run();
|
||||
});
|
||||
|
||||
let threads: Vec<_> = modules
|
||||
.into_iter()
|
||||
.map(|x| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue