mirror of
https://codeberg.org/YGGverse/ytd.git
synced 2026-04-09 13:25:30 +00:00
use enum type
This commit is contained in:
parent
8dcd80b9fe
commit
6afac2f85f
2 changed files with 10 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue