update config format

This commit is contained in:
yggverse 2026-04-08 13:49:31 +03:00
parent 93586d740f
commit a61f29de6d
5 changed files with 14 additions and 20 deletions

2
Cargo.lock generated
View file

@ -2029,6 +2029,7 @@ dependencies = [
"idna",
"percent-encoding",
"serde",
"serde_derive",
]
[[package]]
@ -2501,6 +2502,7 @@ dependencies = [
"tokio",
"toml",
"tracing-subscriber",
"url",
]
[[package]]

View file

@ -24,3 +24,4 @@ serde_regex = "1.1.0"
tokio = { version = "1.51.0", features = ["rt-multi-thread"] }
toml = "1.1.2"
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
url = { version = "2.5.8", features = ["serde"] }

View file

@ -21,11 +21,9 @@ sleep = 1
# exec = ""
# stdout_contains = [""]
# Video instance provider, Youtube by default
# Invidious provider, Youtube by default
# provider = "Youtube"
# provider = "Invidious"
# provider = { Invidious = "https://tux.rs" }
# provider = "https://tux.rs"
# Channels queue config

View file

@ -3,13 +3,7 @@ mod channel;
use channel::Channel;
use serde::Deserialize;
use std::{collections::HashMap, path::PathBuf};
#[derive(Deserialize, Default)]
pub enum Provider {
#[default]
Youtube,
Invidious(Option<String>),
}
use url::Url;
#[derive(Deserialize)]
pub struct Command {
@ -19,10 +13,8 @@ pub struct Command {
#[derive(Deserialize)]
pub struct Config {
/// Supported values:
/// * youtube
/// * invidious
pub provider: Provider,
/// Invidious provider, Youtube by default
pub provider: Option<Url>,
/// Channels parsed from the config file
pub channel: HashMap<String, Channel>,
/// Persist processed entries between sessions

View file

@ -36,14 +36,15 @@ async fn main() {
let sleep = config.sleep.map(Duration::from_secs);
let mut database = Database::new(&config.database).unwrap();
let provider = match config.provider {
config::Provider::Youtube => {
Some(invidious_url) => {
let url = invidious_url.to_string();
debug!("Init Invidious {url} provider");
Provider::invidious(Some(url))
}
None => {
debug!("Init Youtube provider");
Provider::youtube()
}
config::Provider::Invidious(instance) => {
debug!("Init Invidious {instance:?} provider");
Provider::invidious(instance)
}
};
let channel_item_id_regex = Regex::new(r"^[A-z0-9_-]{11}$").unwrap();