First version of youtube-backup, a tool to backup your YouTube channel.

This commit is contained in:
Luna 2026-05-11 02:33:52 -07:00
parent acf188738a
commit abf3af5768
13 changed files with 1612 additions and 20 deletions

31
src/config.rs Normal file
View file

@ -0,0 +1,31 @@
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Config {
pub backup: BackupSection,
#[serde(default)]
pub player: PlayerSection,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct BackupSection {
pub directory: PathBuf,
}
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct PlayerSection {
#[serde(default = "default_player")]
pub command: String,
}
fn default_player() -> String {
"mpv".to_string()
}
impl Config {
pub fn load(path: &Path) -> Result<Self, Box<dyn std::error::Error>> {
let contents = std::fs::read_to_string(path)?;
toml::from_str(&contents).map_err(|e| e.into())
}
}