change quickjs to upstream one
This commit is contained in:
@@ -53,19 +53,16 @@ pub struct LogEvent {
|
||||
pub level: String, // "info", "error"
|
||||
}
|
||||
|
||||
pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool) -> Result<MetadataResult> {
|
||||
let ytdlp_path = binary_manager::get_ytdlp_path(app)?; // Updated path call
|
||||
|
||||
// Inject PATH for QuickJS
|
||||
let bin_dir = binary_manager::get_bin_dir(app)?;
|
||||
let path_env = std::env::var("PATH").unwrap_or_default();
|
||||
let new_path_env = format!("{}{}{}", bin_dir.to_string_lossy(), if cfg!(windows) { ";" } else { ":" }, path_env);
|
||||
|
||||
|
||||
pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool) -> Result<MetadataResult> {
|
||||
let ytdlp_path = binary_manager::get_ytdlp_path(app)?;
|
||||
let qjs_path = binary_manager::get_qjs_path(app)?; // Get absolute path to quickjs
|
||||
|
||||
let mut cmd = Command::new(ytdlp_path);
|
||||
|
||||
// Environment injection
|
||||
cmd.env("PATH", new_path_env);
|
||||
cmd.arg("--js-runtime").arg("quickjs"); // Force QuickJS
|
||||
// Pass the runtime and its absolute path to --js-runtimes
|
||||
cmd.arg("--js-runtimes").arg(format!("quickjs:{}", qjs_path.to_string_lossy()));
|
||||
|
||||
cmd.arg("--dump-single-json")
|
||||
.arg("--flat-playlist")
|
||||
@@ -134,18 +131,14 @@ pub async fn download_video(
|
||||
url: String,
|
||||
options: DownloadOptions,
|
||||
) -> Result<String> {
|
||||
let ytdlp_path = binary_manager::get_ytdlp_path(&app)?; // Updated path call
|
||||
let ytdlp_path = binary_manager::get_ytdlp_path(&app)?;
|
||||
let qjs_path = binary_manager::get_qjs_path(&app)?; // Get absolute path to quickjs
|
||||
|
||||
// Inject PATH for QuickJS
|
||||
let bin_dir = binary_manager::get_bin_dir(&app)?;
|
||||
let path_env = std::env::var("PATH").unwrap_or_default();
|
||||
let new_path_env = format!("{}{}{}", bin_dir.to_string_lossy(), if cfg!(windows) { ";" } else { ":" }, path_env);
|
||||
|
||||
let mut args = Vec::new();
|
||||
|
||||
// JS Runtime args must be passed via .arg(), env is set on command builder
|
||||
args.push("--js-runtime".to_string());
|
||||
args.push("quickjs".to_string());
|
||||
// Pass the runtime and its absolute path to --js-runtimes
|
||||
args.push("--js-runtimes".to_string());
|
||||
args.push(format!("quickjs:{}", qjs_path.to_string_lossy()));
|
||||
|
||||
args.push(url);
|
||||
|
||||
@@ -158,7 +151,7 @@ pub async fn download_video(
|
||||
if options.is_audio_only {
|
||||
args.push("-x".to_string());
|
||||
args.push("--audio-format".to_string());
|
||||
args.push("mp3".to_string()); // Defaulting to mp3 for simplicity
|
||||
args.push("mp3".to_string());
|
||||
} else {
|
||||
let format_arg = if options.quality == "best" {
|
||||
"bestvideo+bestaudio/best".to_string()
|
||||
@@ -170,13 +163,14 @@ pub async fn download_video(
|
||||
}
|
||||
|
||||
// Progress output
|
||||
args.push("--newline".to_string()); // Easier parsing
|
||||
args.push("--newline".to_string());
|
||||
|
||||
let mut child = Command::new(ytdlp_path)
|
||||
.env("PATH", new_path_env) // Inject PATH
|
||||
let mut cmd = Command::new(ytdlp_path);
|
||||
|
||||
let mut child = cmd
|
||||
.args(&args)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped()) // Capture stderr for logs
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()?;
|
||||
|
||||
let stdout = child.stdout.take().ok_or(anyhow!("Failed to open stdout"))?;
|
||||
@@ -250,4 +244,4 @@ pub async fn download_video(
|
||||
}).ok();
|
||||
Err(anyhow!("Download process failed"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user