Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
Feat: direct file downloads for plain URLs, douyin share links, subtitle language selection and download output validation (#142, #136, #141, #125, #127)
Tonhoe710917efd6a
diff --git a/src-tauri/omniget-core/src/core/ytdlp.rs b/src-tauri/omniget-core/src/core/ytdlp.rsindex 68b9684c..29ff43c3 100644--- a/src-tauri/omniget-core/src/core/ytdlp.rs+++ b/src-tauri/omniget-core/src/core/ytdlp.rs@@ -861,6 +861,17 @@ pub async fn ensure_ytdlp() -> anyhow::Result<PathBuf> {Ok(path)}+pub async fn update_ytdlp() -> anyhow::Result<PathBuf> {+ if crate::core::dependencies::is_flatpak() {+ return Err(anyhow!(+ "yt-dlp is provided by the Flatpak runtime and cannot be updated from inside the app"+ ));+ }+ let path = download_ytdlp_binary().await?;+ reset_ytdlp_cache();+ Ok(path)+}+#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum YtdlpChannel {Stable,@@ -976,11 +987,20 @@ async fn download_ytdlp_binary() -> anyhow::Result<PathBuf> {_ => tracing::warn!("[ytdlp] could not fetch SHA2-256SUMS — skipping verification"),}- let target_clone = target.clone();- tokio::task::spawn_blocking(move || std::fs::write(&target_clone, &bytes))+ let temp = target.with_file_name(format!(+ "{}.new",+ target+ .file_name()+ .and_then(|n| n.to_str())+ .unwrap_or("yt-dlp")+ ));+ let temp_clone = temp.clone();+ tokio::task::spawn_blocking(move || std::fs::write(&temp_clone, &bytes)).await.map_err(|e| anyhow!("spawn_blocking failed: {}", e))??;+ crate::core::dependencies::replace_managed_binary(&temp, &target)?;+#[cfg(unix)]{use std::os::unix::fs::PermissionsExt;@@ -2573,6 +2593,10 @@ pub async fn download_video(}}+ if use_subtitles && keep_vtt_setting() {+ convert_vtt_sidecars_to_srt(&file_path).await;+ }+let meta = std::fs::metadata(&file_path)?;tracing::debug!("[perf] download_video took {:?}", _timer_start.elapsed());return Ok(DownloadResult {@@ -2778,6 +2802,52 @@ pub async fn download_video(Err(translate_ytdlp_error(&last_error))}+async fn convert_vtt_sidecars_to_srt(video_path: &Path) {+ let dir = match video_path.parent() {+ Some(d) => d.to_path_buf(),+ None => return,+ };+ let stem = match video_path.file_stem().and_then(|s| s.to_str()) {+ Some(s) => s.to_string(),+ None => return,+ };+ let ffmpeg = match crate::core::dependencies::find_tool("ffmpeg").await {+ Some(p) => p,+ None => return,+ };+ let entries = match std::fs::read_dir(&dir) {+ Ok(e) => e,+ Err(_) => return,+ };+ for entry in entries.flatten() {+ let name = entry.file_name().to_string_lossy().to_string();+ if !name.starts_with(&stem) || !name.to_lowercase().ends_with(".vtt") {+ continue;+ }+ let vtt_path = entry.path();+ let srt_path = vtt_path.with_extension("srt");+ if srt_path.exists() {+ continue;+ }+ let result = crate::core::process::command(&ffmpeg)+ .arg("-y")+ .arg("-i")+ .arg(&vtt_path)+ .arg(&srt_path)+ .output()+ .await;+ match result {+ Ok(out) if out.status.success() => {+ tracing::info!("[yt-dlp] converted subtitle sidecar {} to srt (vtt kept)", name);+ }+ _ => {+ tracing::warn!("[yt-dlp] failed to convert subtitle sidecar {} to srt", name);+ let _ = std::fs::remove_file(&srt_path);+ }+ }+ }+}+async fn cleanup_part_files(dir: &Path) {if let Ok(entries) = std::fs::read_dir(dir) {for entry in entries.flatten() {diff --git a/src-tauri/omniget-core/src/models/media.rs b/src-tauri/omniget-core/src/models/media.rsindex 552380aa..c15d4e8a 100644--- a/src-tauri/omniget-core/src/models/media.rs+++ b/src-tauri/omniget-core/src/models/media.rs@@ -26,6 +26,7 @@ pub enum MediaType {Carousel,Playlist,Course,+ File,}#[derive(Debug, Clone, Serialize, Deserialize)]diff --git a/src-tauri/omniget-core/src/platforms/mod.rs b/src-tauri/omniget-core/src/platforms/mod.rsindex 4bf47da4..9eb8c891 100644--- a/src-tauri/omniget-core/src/platforms/mod.rs+++ b/src-tauri/omniget-core/src/platforms/mod.rs@@ -4,6 +4,30 @@ use serde::{Deserialize, Serialize};use std::fmt;use std::str::FromStr;+const DIRECT_FILE_EXTENSIONS: &[&str] = &[+ "zip", "rar", "7z", "tar", "gz", "tgz", "bz2", "xz", "zst", "exe", "msi", "dmg", "pkg", "deb",+ "rpm", "appimage", "apk", "iso", "pdf", "epub", "mobi", "doc", "docx", "xls", "xlsx", "ppt",+ "pptx", "odt", "ods", "odp", "rtf", "txt", "csv", "jpg", "jpeg", "png", "gif", "webp", "bmp",+ "tiff", "svg", "heic", "avif",+];++pub fn is_direct_file_url(url_str: &str) -> bool {+ let Ok(parsed) = url::Url::parse(url_str) else {+ return false;+ };+ if parsed.scheme() != "http" && parsed.scheme() != "https" {+ return false;+ }+ let path = parsed.path().to_lowercase();+ let Some(last) = path.rsplit('/').next() else {+ return false;+ };+ let Some((name, ext)) = last.rsplit_once('.') else {+ return false;+ };+ !name.is_empty() && DIRECT_FILE_EXTENSIONS.contains(&ext)+}+#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]#[serde(rename_all = "lowercase")]pub enum Platform {@@ -133,7 +157,7 @@ impl Platform {Some(Platform::Other("thinkific".to_string()))} else if matches("rocketseat.com.br") {Some(Platform::Other("rocketseat".to_string()))- } else if matches("douyin.com") || matches("iesdouyin.com") {+ } else if matches("douyin.com") || matches("iesdouyin.com") || matches("amemv.com") {Some(Platform::Other("douyin".to_string()))} else if matches("kuaishou.com") {Some(Platform::Other("kuaishou".to_string()))@@ -147,6 +171,8 @@ impl Platform {Some(Platform::Other("mgtv".to_string()))} else if matches("youku.com") {Some(Platform::Other("youku".to_string()))+ } else if is_direct_file_url(url_str) {+ Some(Platform::Other("direct_file".to_string()))} else {None}diff --git a/src-tauri/src/commands/downloads.rs b/src-tauri/src/commands/downloads.rsindex 0dc70324..d3f2983a 100644--- a/src-tauri/src/commands/downloads.rs+++ b/src-tauri/src/commands/downloads.rs@@ -62,11 +62,19 @@ pub async fn detect_platform(url: String) -> Result<PlatformInfo, String> {match Platform::from_url(&url) {Some(platform) => {let parsed = url_parser::parse_url(&url);+ let platform_name = platform.to_string();+ let content_type = if platform_name == "direct_file" {+ Some("file".to_string())+ } else {+ parsed+ .as_ref()+ .map(|p| format!("{:?}", p.content_type).to_lowercase())+ };let result = Ok(PlatformInfo {- platform: platform.to_string(),+ platform: platform_name,supported: true,content_id: parsed.as_ref().and_then(|p| p.content_id.clone()),- content_type: parsed.map(|p| format!("{:?}", p.content_type).to_lowercase()),+ content_type,});tracing::debug!("[perf] detect_platform took {:?}", _timer_start.elapsed());resultdiff --git a/src-tauri/src/core/queue.rs b/src-tauri/src/core/queue.rsindex fb99d5fb..1465db52 100644--- a/src-tauri/src/core/queue.rs+++ b/src-tauri/src/core/queue.rs@@ -1552,6 +1552,33 @@ async fn spawn_download_inner(dl.file_size_bytes),);+ let is_seeding = platform_name == "magnet" && dl.torrent_id.is_some();+ if !is_seeding {+ if let Err(msg) = validate_download_output(&dl.file_path).await {+ tracing::error!(+ "[queue] download {} reported success but output is missing or empty: {:?}",+ item_id,+ dl.file_path+ );+ append_download_log(+ &app,+ item_id,+ format!(+ "[omniget] download reported success but output missing or empty: {}",+ dl.file_path.to_string_lossy()+ ),+ );+ let state = {+ let mut q = queue.lock().await;+ q.mark_complete(item_id, false, Some(msg), None, None);+ q.get_state()+ };+ emit_queue_state_from_state(&app, state);+ try_start_next(app, queue).await;+ return;+ }+ }+if settings.download.embed_metadata&& platform_name != "magnet"&& ffmpeg::is_ffmpeg_available().await@@ -1702,6 +1729,33 @@ fn is_retryable_category(category: &str) -> bool {matches!(category, "unknown" | "rate_limited")}+const OUTPUT_MISSING_ERROR: &str =+ "Download reported success but the file is missing or empty. Check disk space and antivirus exclusions, then retry.";++async fn validate_download_output(path: &std::path::Path) -> Result<(), String> {+ if path.as_os_str().is_empty() {+ return Err(OUTPUT_MISSING_ERROR.to_string());+ }+ let meta = match tokio::fs::metadata(path).await {+ Ok(m) => m,+ Err(_) => return Err(OUTPUT_MISSING_ERROR.to_string()),+ };+ if meta.is_dir() {+ let mut entries = match tokio::fs::read_dir(path).await {+ Ok(e) => e,+ Err(_) => return Err(OUTPUT_MISSING_ERROR.to_string()),+ };+ match entries.next_entry().await {+ Ok(Some(_)) => Ok(()),+ _ => Err(OUTPUT_MISSING_ERROR.to_string()),+ }+ } else if meta.len() > 0 {+ Ok(())+ } else {+ Err(OUTPUT_MISSING_ERROR.to_string())+ }+}+async fn fetch_and_cache_info(url: &str,downloader: &dyn PlatformDownloader,diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 6972e806..61ffbc9f 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -60,6 +60,7 @@ pub fn run() {)));registry.register(Arc::new(platforms::p2p::P2pDownloader::new()));registry.register(Arc::new(platforms::gallerydl::GalleryDlDownloader::new()));+ registry.register(Arc::new(platforms::direct_file::DirectFileDownloader::new()));registry.register(Arc::new(platforms::generic_ytdlp::GenericYtdlpDownloader::new(),));@@ -186,14 +187,21 @@ pub fn run() {.include_auto_subtitles});core::ytdlp::set_caption_locale_fn(|| {- storage::config::load_settings_standalone()- .download- .caption_locale+ let s = storage::config::load_settings_standalone();+ let locale = s.download.caption_locale.trim().to_string();+ if locale.is_empty() || locale.eq_ignore_ascii_case("auto") {+ let lang = s.appearance.language.trim().to_string();+ if lang.is_empty() {+ "en".to_string()+ } else {+ lang+ }+ } else {+ locale+ }});core::ytdlp::set_keep_vtt_fn(|| {- storage::config::load_settings_standalone()- .download- .keep_vtt+ storage::config::load_settings_standalone().download.keep_vtt});core::ytdlp::set_translate_metadata_fn(|| {let s = storage::config::load_settings_standalone();diff --git a/src-tauri/src/platforms/direct_file/mod.rs b/src-tauri/src/platforms/direct_file/mod.rsnew file mode 100644index 00000000..b2375f8d--- /dev/null+++ b/src-tauri/src/platforms/direct_file/mod.rs@@ -0,0 +1,169 @@+use anyhow::anyhow;+use async_trait::async_trait;+use tokio::sync::mpsc;++use omniget_core::models::progress::ProgressUpdate;++use crate::core::direct_downloader;+use crate::core::http_client;+use crate::models::media::{+ DownloadOptions, DownloadResult, MediaInfo, MediaType, VideoQuality,+};+use crate::platforms::traits::PlatformDownloader;++pub struct DirectFileDownloader;++impl Default for DirectFileDownloader {+ fn default() -> Self {+ Self::new()+ }+}++impl DirectFileDownloader {+ pub fn new() -> Self {+ Self+ }+}++fn filename_from_url(url: &str) -> String {+ url::Url::parse(url)+ .ok()+ .and_then(|u| {+ let last = u.path().rsplit('/').next()?.to_string();+ if last.is_empty() || !last.contains('.') {+ return None;+ }+ Some(+ urlencoding::decode(&last)+ .map(|d| d.to_string())+ .unwrap_or(last),+ )+ })+ .map(|name| sanitize_filename::sanitize(&name))+ .filter(|name| !name.is_empty())+ .unwrap_or_else(|| "download".to_string())+}++async fn probe_file_size(url: &str) -> Option<u64> {+ let client = http_client::apply_global_proxy(reqwest::Client::builder())+ .timeout(std::time::Duration::from_secs(10))+ .build()+ .ok()?;+ let resp = client.head(url).send().await.ok()?;+ if !resp.status().is_success() {+ return None;+ }+ resp.content_length().filter(|len| *len > 0)+}++#[async_trait]+impl PlatformDownloader for DirectFileDownloader {+ fn name(&self) -> &str {+ "direct_file"+ }++ fn can_handle(&self, url: &str) -> bool {+ omniget_core::platforms::is_direct_file_url(url)+ }++ async fn get_media_info(&self, url: &str) -> anyhow::Result<MediaInfo> {+ let title = filename_from_url(url);+ let file_size_bytes = probe_file_size(url).await;++ Ok(MediaInfo {+ title,+ author: String::new(),+ platform: "direct_file".to_string(),+ duration_seconds: None,+ thumbnail_url: None,+ available_qualities: vec![VideoQuality {+ label: "original".to_string(),+ width: 0,+ height: 0,+ url: url.to_string(),+ format: "direct_file".to_string(),+ }],+ media_type: MediaType::File,+ file_size_bytes,+ })+ }++ async fn download(+ &self,+ info: &MediaInfo,+ opts: &DownloadOptions,+ progress: mpsc::Sender<ProgressUpdate>,+ ) -> anyhow::Result<DownloadResult> {+ let _ = progress.send(ProgressUpdate::percent(0.0)).await;++ let file_url = info+ .available_qualities+ .first()+ .map(|q| q.url.as_str())+ .filter(|u| !u.is_empty())+ .ok_or_else(|| anyhow!("No URL available"))?;++ let filename = sanitize_filename::sanitize(&info.title);+ let filename = if filename.is_empty() {+ filename_from_url(file_url)+ } else {+ filename+ };+ let output_path = opts.output_dir.join(&filename);++ let mut builder = http_client::apply_global_proxy(reqwest::Client::builder())+ .connect_timeout(std::time::Duration::from_secs(30));++ if let Some(ua) = opts.user_agent.as_deref() {+ builder = builder.user_agent(ua);+ }++ let jar = crate::core::cookie_parser::load_extension_cookies_for_url(file_url).or_else(|| {+ opts.referer+ .as_deref()+ .and_then(crate::core::cookie_parser::load_extension_cookies_for_url)+ });+ if let Some(jar) = jar {+ builder = builder.cookie_provider(jar);+ }++ let client = builder+ .build()+ .map_err(|e| anyhow!("Failed to build HTTP client: {}", e))?;++ let mut headers = reqwest::header::HeaderMap::new();+ if let Some(ref r) = opts.referer {+ if let Ok(val) = reqwest::header::HeaderValue::from_str(r) {+ headers.insert(reqwest::header::REFERER, val);+ }+ }+ if let Some(ref hdrs) = opts.extra_headers {+ for (name, value) in hdrs {+ if let (Ok(hname), Ok(hval)) = (+ reqwest::header::HeaderName::from_bytes(name.as_bytes()),+ reqwest::header::HeaderValue::from_str(value),+ ) {+ headers.insert(hname, hval);+ }+ }+ }+ http_client::inject_ua_header(&mut headers, opts.user_agent.as_deref());++ let bytes = direct_downloader::download_direct_with_headers(+ &client,+ file_url,+ &output_path,+ progress,+ Some(headers),+ Some(&opts.cancel_token),+ )+ .await?;++ Ok(DownloadResult {+ file_path: output_path,+ file_size_bytes: bytes,+ duration_seconds: 0.0,+ torrent_id: None,+ })+ }+}diff --git a/src-tauri/src/platforms/douyin/mod.rs b/src-tauri/src/platforms/douyin/mod.rsindex ce6350ea..1ed396e5 100644--- a/src-tauri/src/platforms/douyin/mod.rs+++ b/src-tauri/src/platforms/douyin/mod.rs@@ -44,7 +44,8 @@ impl DouyinDownloader {|| host.ends_with(".douyin.com")|| host == "iesdouyin.com"|| host.ends_with(".iesdouyin.com")- || host == "webcast.amemv.com"+ || host == "amemv.com"+ || host.ends_with(".amemv.com")}fn is_short_link(url: &str) -> bool {@@ -52,16 +53,53 @@ impl DouyinDownloader {if let Some(host) = parsed.host_str() {let host = host.to_lowercase();return host == "v.douyin.com"- || host == "webcast.amemv.com"- || (host == "iesdouyin.com" || host.ends_with(".iesdouyin.com"));+ || host == "amemv.com"+ || host.ends_with(".amemv.com")+ || host == "iesdouyin.com"+ || host.ends_with(".iesdouyin.com");}}false}+ fn canonicalize(url: &str) -> String {+ let Ok(parsed) = url::Url::parse(url) else {+ return url.to_string();+ };+ let host = parsed.host_str().unwrap_or("").to_lowercase();+ if !Self::host_matches(&host) {+ return url.to_string();+ }++ let segments: Vec<&str> = parsed.path().split('/').filter(|s| !s.is_empty()).collect();+ let target = match segments.as_slice() {+ ["share", kind @ ("video" | "note" | "slides"), id, ..] => Some((*kind, *id)),+ [kind @ ("video" | "note"), id, ..] => Some((*kind, *id)),+ _ => None,+ };+ if let Some((kind, id)) = target {+ if !id.is_empty() && id.chars().all(|c| c.is_ascii_digit()) {+ let kind = if kind == "slides" { "note" } else { kind };+ return format!("https://www.douyin.com/{}/{}", kind, id);+ }+ }++ if let Some(id) = parsed+ .query_pairs()+ .find(|(k, _)| k == "modal_id")+ .map(|(_, v)| v.to_string())+ {+ if !id.is_empty() && id.chars().all(|c| c.is_ascii_digit()) {+ return format!("https://www.douyin.com/video/{}", id);+ }+ }++ url.to_string()+ }+async fn resolve_url(url: &str) -> String {if !Self::is_short_link(url) {- return url.to_string();+ return Self::canonicalize(url);}let builder = reqwest::Client::builder().timeout(Duration::from_secs(10))@@ -69,13 +107,13 @@ impl DouyinDownloader {.user_agent(DOUYIN_UA);let client = match http_client::apply_global_proxy(builder).build() {Ok(c) => c,- Err(_) => return url.to_string(),+ Err(_) => return Self::canonicalize(url),};match client.get(url).send().await {- Ok(resp) => resp.url().to_string(),+ Ok(resp) => Self::canonicalize(resp.url().as_str()),Err(e) => {tracing::warn!("[douyin] short-link resolve failed: {}", e);- url.to_string()+ Self::canonicalize(url)}}}@@ -225,6 +263,7 @@ impl PlatformDownloader for DouyinDownloader {if canonical.is_empty() {return Err(anyhow!("No URL available"));}+ let canonical = Self::resolve_url(canonical).await;let quality_height = opts.quality@@ -235,7 +274,7 @@ impl PlatformDownloader for DouyinDownloader {ytdlp::download_video(&ytdlp_path,- canonical,+ &canonical,&opts.output_dir,quality_height,progress,diff --git a/src-tauri/src/platforms/mod.rs b/src-tauri/src/platforms/mod.rsindex 7de9ebc9..68598391 100644--- a/src-tauri/src/platforms/mod.rs+++ b/src-tauri/src/platforms/mod.rs@@ -2,6 +2,7 @@ pub use omniget_core::platforms::traits;pub use omniget_core::platforms::Platform;pub mod bluesky;+pub mod direct_file;pub mod noop;pub mod pinterest;pub mod tiktok;diff --git a/src-tauri/src/platforms/youtube/mod.rs b/src-tauri/src/platforms/youtube/mod.rsindex 96f6ec18..64792c33 100644--- a/src-tauri/src/platforms/youtube/mod.rs+++ b/src-tauri/src/platforms/youtube/mod.rs@@ -393,7 +393,7 @@ impl YouTubeDownloader {let mut total_bytes = 0u64;let mut last_path = playlist_dir.clone();let mut success_count = 0usize;- let mut last_error: Option<String> = None;+ let mut last_err: Option<anyhow::Error> = None;for (i, entry) in info.available_qualities.iter().enumerate() {if opts.cancel_token.is_cancelled() {@@ -447,23 +447,25 @@ impl YouTubeDownloader {last_path = result.file_path;}Err(e) => {- last_error = Some(e.to_string());tracing::warn!("Playlist video {} falhou: {}", i + 1, e);+ last_err = Some(e);}}let _ = forwarder.await;}- let _ = progress.send(ProgressUpdate::percent(100.0)).await;-if success_count == 0 {- anyhow::bail!(- "Playlist download failed: {}",- last_error.unwrap_or_else(|| "no entries were downloaded".to_string())- );+ return Err(last_err+ .unwrap_or_else(|| anyhow!("Playlist download finished without any files")));+ }++ if success_count > 1 {+ last_path = playlist_dir.clone();}+ let _ = progress.send(ProgressUpdate::percent(100.0)).await;+Ok(DownloadResult {file_path: last_path,file_size_bytes: total_bytes,diff --git a/src/lib/error-translate.ts b/src/lib/error-translate.tsindex 26be97b3..a48e4b66 100644--- a/src/lib/error-translate.ts+++ b/src/lib/error-translate.ts@@ -37,6 +37,8 @@ const BACKEND_ERROR_MAP: Record<string, string> = {"errors.console_encoding","yt-dlp extractor is broken for this site. Update yt-dlp in Settings → Dependencies, then retry.":"errors.extractor_broken",+ "Download reported success but the file is missing or empty. Check disk space and antivirus exclusions, then retry.":+ "errors.output_missing",};/**diff --git a/src/lib/platform-display-names.ts b/src/lib/platform-display-names.tsindex 4d5127ce..4bda6423 100644--- a/src/lib/platform-display-names.ts+++ b/src/lib/platform-display-names.ts@@ -21,6 +21,7 @@ export const PLATFORM_DISPLAY_NAMES: Record<string, string> = {udemy: "Udemy",magnet: "BitTorrent",p2p: "P2P",+ direct_file: "Direct file",};export function platformDisplayName(s: string): string {diff --git a/src/routes/+page.svelte b/src/routes/+page.svelteindex a207cbee..6a19051e 100644--- a/src/routes/+page.svelte+++ b/src/routes/+page.svelte@@ -1059,12 +1059,13 @@{@const playlistBlocked = omniState.info.content_type === "playlist" && playlistEntries.length > 0 && selectedPlaylistItems.size === 0}{@const torrentBlocked = torrentEntries.length > 0 && selectedTorrentFiles.size === 0}{#if omniState.info.platform === "bilibili"}- <BilibiliPreviewExtras {url} accountSlug={selectedCookieSlug} />+ <BilibiliPreviewExtras {url} accountSlug={selectedCookieSlug && selectedCookieSlug !== "_anonymous" ? selectedCookieSlug : null} />{/if}<button class="download-primary-btn" disabled={playlistBlocked || torrentBlocked} onclick={handleAction}>{$t('omnibox.download')}</button>+ {#if omniState.info.platform !== "direct_file"}<details class="options-panel"><summary class="options-toggle">{$t('omnibox.options')}</summary><div class="options-content">@@ -1164,6 +1165,7 @@</details></div></details>+ {/if}{/if}{:else if omniState.kind === "batch"}diff --git a/src/routes/downloads/+page.svelte b/src/routes/downloads/+page.svelteindex 0d7fd04c..d1a03b58 100644--- a/src/routes/downloads/+page.svelte+++ b/src/routes/downloads/+page.svelte@@ -48,12 +48,33 @@}});+ const VIDEO_EXTENSIONS = new Set([+ "mp4", "mkv", "webm", "mov", "avi", "ts", "m4v", "flv", "wmv", "mpg", "mpeg", "3gp", "ogv", "m2ts", "mts",+ ]);++ function fileExtension(path: string): string | null {+ const name = path.replace(/\\/g, "/").split("/").pop() ?? "";+ const dot = name.lastIndexOf(".");+ if (dot <= 0 || dot === name.length - 1) return null;+ return name.slice(dot + 1).toLowerCase();+ }++ function isVideoItem(item: GenericDownloadItem): boolean {+ if (item.filePath && (item.fileCount ?? 1) <= 1) {+ const ext = fileExtension(item.filePath);+ if (ext) return VIDEO_EXTENSIONS.has(ext);+ }+ if (item.downloadMode === "video") return true;+ return item.queueKind === "video";+ }+function qualityChip(item: GenericDownloadItem): string | null {if (item.downloadMode === "audio") return $t('omnibox.quality_audio') as string;if (!item.quality) return null;const q = item.quality.toLowerCase();- if (q === "best" || q === "highest") return $t('omnibox.quality_best_short') as string;if (q === "audio") return $t('omnibox.quality_audio') as string;+ if (!isVideoItem(item)) return null;+ if (q === "best" || q === "highest") return $t('omnibox.quality_best_short') as string;return item.quality;}