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: implement HLS download functionality with ffmpeg and header support
Tonho1436d71943cc
diff --git a/src-tauri/src/core/media_processor.rs b/src-tauri/src/core/media_processor.rsindex 066faa6f..9661c894 100644--- a/src-tauri/src/core/media_processor.rs+++ b/src-tauri/src/core/media_processor.rs@@ -1,6 +1,45 @@+const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";+pub struct MediaProcessor;impl MediaProcessor {+ pub async fn download_hls_ffmpeg(+ m3u8_url: &str,+ output: &str,+ referer: &str,+ ) -> anyhow::Result<()> {+ if let Some(parent) = std::path::Path::new(output).parent() {+ tokio::fs::create_dir_all(parent).await?;+ }++ let headers = format!("Referer: {}\r\nUser-Agent: {}\r\n", referer, USER_AGENT);++ let status = tokio::process::Command::new("ffmpeg")+ .args([+ "-y",+ "-headers",+ &headers,+ "-i",+ m3u8_url,+ "-c",+ "copy",+ "-bsf:a",+ "aac_adtstoasc",+ output,+ ])+ .stdout(std::process::Stdio::null())+ .stderr(std::process::Stdio::piped())+ .status()+ .await?;++ if !status.success() {+ anyhow::bail!("FFmpeg HLS download falhou com status {}", status);+ }++ tracing::info!("HLS download completo: {}", output);+ Ok(())+ }+pub async fn remux(input: &str, output: &str) -> anyhow::Result<()> {let status = tokio::process::Command::new("ffmpeg").args(["-y", "-i", input, "-c", "copy", output])@@ -78,3 +117,13 @@ impl MediaProcessor {Ok(())}}++pub fn check_ffmpeg() -> bool {+ std::process::Command::new("ffmpeg")+ .arg("-version")+ .stdout(std::process::Stdio::null())+ .stderr(std::process::Stdio::null())+ .status()+ .map(|s| s.success())+ .unwrap_or(false)+}