feat: 支持前端编辑、提交 Config (#370)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2025-06-18 16:50:16 +08:00
committed by GitHub
parent 28971c3ff3
commit e50318870e
27 changed files with 963 additions and 311 deletions

View File

@@ -2,4 +2,4 @@ mod http_server;
mod video_downloader;
pub use http_server::http_server;
pub use video_downloader::video_downloader;
pub use video_downloader::{DOWNLOADER_TASK_RUNNING, video_downloader};

View File

@@ -4,16 +4,18 @@ use sea_orm::DatabaseConnection;
use tokio::time;
use crate::bilibili::{self, BiliClient};
use crate::config::{DOWNLOADER_RUNNING, VersionedConfig};
use crate::config::VersionedConfig;
use crate::utils::model::get_enabled_video_sources;
use crate::workflow::process_video_source;
pub static DOWNLOADER_TASK_RUNNING: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
/// 启动周期下载视频的任务
pub async fn video_downloader(connection: Arc<DatabaseConnection>, bili_client: Arc<BiliClient>) {
let mut anchor = chrono::Local::now().date_naive();
loop {
info!("开始执行本轮视频下载任务..");
DOWNLOADER_RUNNING.store(true, std::sync::atomic::Ordering::Relaxed);
let _lock = DOWNLOADER_TASK_RUNNING.lock().await;
let config = VersionedConfig::get().load_full();
'inner: {
if let Err(e) = config.check() {
@@ -53,7 +55,7 @@ pub async fn video_downloader(connection: Arc<DatabaseConnection>, bili_client:
}
info!("本轮任务执行完毕,等待下一轮执行");
}
DOWNLOADER_RUNNING.store(false, std::sync::atomic::Ordering::Relaxed);
drop(_lock);
time::sleep(time::Duration::from_secs(config.interval)).await;
}
}