Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: add media module with structures for media handling and download options

Tonhoba546e08fd98
diff --git a/src-tauri/omniget-core/src/models/media.rs b/src-tauri/omniget-core/src/models/media.rs
new file mode 100644
index 00000000..85f0f6ce
--- /dev/null
+++ b/src-tauri/omniget-core/src/models/media.rs
@@ -0,0 +1,101 @@
+use serde::{Deserialize, Serialize};
+use std::path::PathBuf;
+
+use crate::platform::Platform;
+use tokio_util::sync::CancellationToken;
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct MediaInfo {
+ pub title: String,
+ pub author: String,
+ pub platform: String,
+ pub duration_seconds: Option<f64>,
+ pub thumbnail_url: Option<String>,
+ pub available_qualities: Vec<VideoQuality>,
+ pub media_type: MediaType,
+ pub file_size_bytes: Option<u64>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
+pub enum MediaType {
+ Video,
+ Audio,
+ Photo,
+ Gif,
+ Carousel,
+ Playlist,
+ Course,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct VideoQuality {
+ pub label: String,
+ pub width: u32,
+ pub height: u32,
+ pub url: String,
+ pub format: String,
+}
+
+#[derive(Clone)]
+pub struct DownloadOptions {
+ pub quality: Option<String>,
+ pub output_dir: PathBuf,
+ pub filename_template: Option<String>,
+ pub download_subtitles: bool,
+ pub download_mode: Option<String>,
+ pub format_id: Option<String>,
+ pub referer: Option<String>,
+ pub cancel_token: CancellationToken,
+ pub concurrent_fragments: u32,
+ pub ytdlp_path: Option<PathBuf>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct FormatInfo {
+ pub format_id: String,
+ pub ext: String,
+ pub resolution: Option<String>,
+ pub width: Option<u32>,
+ pub height: Option<u32>,
+ pub fps: Option<f64>,
+ pub vcodec: Option<String>,
+ pub acodec: Option<String>,
+ pub filesize: Option<u64>,
+ pub tbr: Option<f64>,
+ pub has_video: bool,
+ pub has_audio: bool,
+ pub format_note: Option<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct DownloadResult {
+ pub file_path: PathBuf,
+ pub file_size_bytes: u64,
+ pub duration_seconds: f64,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct MediaItem {
+ pub url: String,
+ pub media_type: MediaType,
+ pub thumbnail_url: Option<String>,
+ pub width: Option<u32>,
+ pub height: Option<u32>,
+ pub duration_seconds: Option<f64>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct GenericDownloadResult {
+ pub platform: Platform,
+ pub title: String,
+ pub author: String,
+ pub files: Vec<DownloadedFile>,
+ pub total_bytes: u64,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct DownloadedFile {
+ pub path: PathBuf,
+ pub media_type: MediaType,
+ pub size_bytes: u64,
+}