mirror of
https://codeberg.org/YGGverse/ytd.git
synced 2026-04-09 13:25:30 +00:00
update config format
This commit is contained in:
parent
93586d740f
commit
a61f29de6d
5 changed files with 14 additions and 20 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -2029,6 +2029,7 @@ dependencies = [
|
||||||
"idna",
|
"idna",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -2501,6 +2502,7 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml",
|
"toml",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,4 @@ serde_regex = "1.1.0"
|
||||||
tokio = { version = "1.51.0", features = ["rt-multi-thread"] }
|
tokio = { version = "1.51.0", features = ["rt-multi-thread"] }
|
||||||
toml = "1.1.2"
|
toml = "1.1.2"
|
||||||
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
|
||||||
|
url = { version = "2.5.8", features = ["serde"] }
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,9 @@ sleep = 1
|
||||||
# exec = ""
|
# exec = ""
|
||||||
# stdout_contains = [""]
|
# stdout_contains = [""]
|
||||||
|
|
||||||
# Video instance provider, Youtube by default
|
# Invidious provider, Youtube by default
|
||||||
|
|
||||||
# provider = "Youtube"
|
# provider = "https://tux.rs"
|
||||||
# provider = "Invidious"
|
|
||||||
# provider = { Invidious = "https://tux.rs" }
|
|
||||||
|
|
||||||
# Channels queue config
|
# Channels queue config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,7 @@ mod channel;
|
||||||
use channel::Channel;
|
use channel::Channel;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{collections::HashMap, path::PathBuf};
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
use url::Url;
|
||||||
#[derive(Deserialize, Default)]
|
|
||||||
pub enum Provider {
|
|
||||||
#[default]
|
|
||||||
Youtube,
|
|
||||||
Invidious(Option<String>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Command {
|
pub struct Command {
|
||||||
|
|
@ -19,10 +13,8 @@ pub struct Command {
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// Supported values:
|
/// Invidious provider, Youtube by default
|
||||||
/// * youtube
|
pub provider: Option<Url>,
|
||||||
/// * invidious
|
|
||||||
pub provider: Provider,
|
|
||||||
/// Channels parsed from the config file
|
/// Channels parsed from the config file
|
||||||
pub channel: HashMap<String, Channel>,
|
pub channel: HashMap<String, Channel>,
|
||||||
/// Persist processed entries between sessions
|
/// Persist processed entries between sessions
|
||||||
|
|
|
||||||
11
src/main.rs
11
src/main.rs
|
|
@ -36,14 +36,15 @@ async fn main() {
|
||||||
let sleep = config.sleep.map(Duration::from_secs);
|
let sleep = config.sleep.map(Duration::from_secs);
|
||||||
let mut database = Database::new(&config.database).unwrap();
|
let mut database = Database::new(&config.database).unwrap();
|
||||||
let provider = match config.provider {
|
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");
|
debug!("Init Youtube provider");
|
||||||
Provider::youtube()
|
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();
|
let channel_item_id_regex = Regex::new(r"^[A-z0-9_-]{11}$").unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue