106 lines
2.6 KiB
Rust
106 lines
2.6 KiB
Rust
|
|
use serde::{Deserialize, Serialize};
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
#[serde(rename_all = "camelCase")]
|
||
|
|
pub struct VideoMetadata {
|
||
|
|
pub url: String,
|
||
|
|
pub title: String,
|
||
|
|
pub duration: f64,
|
||
|
|
pub fps: f64,
|
||
|
|
pub thumbnail_url: Option<String>,
|
||
|
|
pub stream_url: String,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
#[serde(rename_all = "camelCase")]
|
||
|
|
pub struct Clip {
|
||
|
|
pub id: String,
|
||
|
|
pub start_time: f64,
|
||
|
|
pub end_time: f64,
|
||
|
|
pub label: String,
|
||
|
|
pub color: String,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
#[serde(rename_all = "camelCase")]
|
||
|
|
pub struct ThumbnailSpritesheet {
|
||
|
|
pub file_path: String,
|
||
|
|
pub start_index: usize,
|
||
|
|
pub count: usize,
|
||
|
|
pub thumb_width: u32,
|
||
|
|
pub thumb_height: u32,
|
||
|
|
pub columns: u32,
|
||
|
|
pub interval_seconds: f64,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
#[serde(rename_all = "camelCase", tag = "type")]
|
||
|
|
pub enum CookieSource {
|
||
|
|
#[serde(rename = "browser")]
|
||
|
|
Browser { browser: String },
|
||
|
|
#[serde(rename = "file")]
|
||
|
|
File { path: String },
|
||
|
|
#[serde(rename = "none")]
|
||
|
|
None,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl CookieSource {
|
||
|
|
pub fn to_ytdlp_args(&self) -> Vec<String> {
|
||
|
|
match self {
|
||
|
|
CookieSource::Browser { browser } => {
|
||
|
|
vec!["--cookies-from-browser".to_string(), browser.clone()]
|
||
|
|
}
|
||
|
|
CookieSource::File { path } => {
|
||
|
|
vec!["--cookies".to_string(), path.clone()]
|
||
|
|
}
|
||
|
|
CookieSource::None => vec![],
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Default for CookieSource {
|
||
|
|
fn default() -> Self {
|
||
|
|
CookieSource::Browser {
|
||
|
|
browser: "firefox".to_string(),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
#[serde(rename_all = "camelCase", tag = "mode")]
|
||
|
|
pub enum CutMode {
|
||
|
|
#[serde(rename = "lossless")]
|
||
|
|
Lossless,
|
||
|
|
#[serde(rename = "precise")]
|
||
|
|
Precise { format: String },
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
#[serde(rename_all = "camelCase", tag = "scope")]
|
||
|
|
pub enum ExportScope {
|
||
|
|
#[serde(rename = "individual")]
|
||
|
|
Individual,
|
||
|
|
#[serde(rename = "merged")]
|
||
|
|
Merged,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
#[serde(rename_all = "camelCase")]
|
||
|
|
pub struct ExportConfig {
|
||
|
|
pub clips: Vec<Clip>,
|
||
|
|
pub cut_mode: CutMode,
|
||
|
|
pub export_scope: ExportScope,
|
||
|
|
pub output_directory: String,
|
||
|
|
pub video_title: String,
|
||
|
|
pub source_file_path: String,
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
#[serde(rename_all = "camelCase")]
|
||
|
|
pub struct DependencyStatus {
|
||
|
|
pub name: String,
|
||
|
|
pub installed: bool,
|
||
|
|
pub version: Option<String>,
|
||
|
|
pub install_command: String,
|
||
|
|
}
|