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 download_subtitles option to download_video function

Tonho9da0b7192294
diff --git a/src-tauri/src/core/ytdlp.rs b/src-tauri/src/core/ytdlp.rs
index 8f35bbad..259c8541 100644
--- a/src-tauri/src/core/ytdlp.rs
+++ b/src-tauri/src/core/ytdlp.rs
@@ -578,6 +578,7 @@ pub async fn download_video(
cancel_token: CancellationToken,
cookie_file: Option<&Path>,
concurrent_fragments: u32,
+ download_subtitles: bool,
) -> anyhow::Result<DownloadResult> {
let _timer_start = std::time::Instant::now();
let mode = download_mode.unwrap_or("auto");
@@ -735,6 +736,17 @@ pub async fn download_video(
base_args.push("--restrict-filenames".to_string());
}
+ if download_subtitles {
+ base_args.push("--write-sub".to_string());
+ base_args.push("--write-auto-sub".to_string());
+ base_args.push("--sub-lang".to_string());
+ base_args.push("en,pt,es".to_string());
+ base_args.push("--sub-format".to_string());
+ base_args.push("best".to_string());
+ base_args.push("--convert-subs".to_string());
+ base_args.push("srt".to_string());
+ }
+
let max_attempts: usize = 3;
let mut extra_args: Vec<String> = Vec::new();
let mut last_error = String::new();