use enum type

This commit is contained in:
yggverse 2026-04-08 12:34:23 +03:00
parent 8dcd80b9fe
commit 6afac2f85f
2 changed files with 10 additions and 5 deletions

View file

@ -4,6 +4,12 @@ use channel::Channel;
use serde::Deserialize;
use std::{collections::HashMap, path::PathBuf};
#[derive(Deserialize)]
pub enum Provider {
Youtube,
Invidious,
}
#[derive(Deserialize)]
pub struct Command {
pub exec: String,
@ -15,7 +21,7 @@ pub struct Config {
/// Supported values:
/// * youtube
/// * invidious
pub provider: String,
pub provider: Provider,
/// Channels parsed from the config file
pub channel: HashMap<String, Channel>,
/// Persist processed entries between sessions

View file

@ -35,10 +35,9 @@ async fn main() {
let update = config.update.map(Duration::from_secs);
let sleep = config.sleep.map(Duration::from_secs);
let mut database = Database::new(&config.database).unwrap();
let client = if "youtube" == config.provider.to_lowercase() {
Provider::youtube()
} else {
Provider::invidious()
let client = match config.provider {
config::Provider::Youtube => Provider::youtube(),
config::Provider::Invidious => Provider::invidious(),
};
let channel_item_id_regex = Regex::new(r"^[A-z0-9_-]{11}$").unwrap();