fix: address Task 2 review findings (stderr + cookie flags)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::models::DependencyStatus;
|
||||
use crate::models::{CookieSource, DependencyStatus};
|
||||
use std::process::Command;
|
||||
|
||||
pub fn check_tool_exists(name: &str) -> Option<String> {
|
||||
@@ -22,10 +22,14 @@ pub fn check_js_runtime() -> Option<String> {
|
||||
check_tool_exists("deno").or_else(|| check_tool_exists("node"))
|
||||
}
|
||||
|
||||
pub fn check_pot_plugin() -> bool {
|
||||
let output = Command::new("yt-dlp")
|
||||
.args(["-v", "--simulate", "https://www.youtube.com/watch?v=dQw4w9WgXcQ"])
|
||||
.output();
|
||||
pub fn check_pot_plugin(cookie_source: &CookieSource) -> bool {
|
||||
let mut command = Command::new("yt-dlp");
|
||||
command
|
||||
.arg("-v")
|
||||
.arg("--simulate")
|
||||
.args(cookie_source.to_ytdlp_args())
|
||||
.arg("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
|
||||
let output = command.output();
|
||||
|
||||
match output {
|
||||
Ok(out) => {
|
||||
@@ -36,12 +40,12 @@ pub fn check_pot_plugin() -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_all_dependency_statuses() -> Vec<DependencyStatus> {
|
||||
pub fn get_all_dependency_statuses(cookie_source: &CookieSource) -> Vec<DependencyStatus> {
|
||||
let ffmpeg = check_tool_exists("ffmpeg");
|
||||
let ytdlp = check_tool_exists("yt-dlp");
|
||||
let js_runtime = check_js_runtime();
|
||||
let pot_plugin = if ytdlp.is_some() {
|
||||
check_pot_plugin()
|
||||
check_pot_plugin(cookie_source)
|
||||
} else {
|
||||
false
|
||||
};
|
||||
@@ -95,6 +99,7 @@ pub fn get_install_args(dep_name: &str) -> Result<Vec<String>, String> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::models::CookieSource;
|
||||
|
||||
#[test]
|
||||
fn test_get_install_args_ffmpeg() {
|
||||
@@ -121,7 +126,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_dependency_statuses_has_four_entries() {
|
||||
let statuses = get_all_dependency_statuses();
|
||||
let statuses = get_all_dependency_statuses(&CookieSource::default());
|
||||
assert_eq!(statuses.len(), 4);
|
||||
assert_eq!(statuses[0].name, "ffmpeg");
|
||||
assert_eq!(statuses[1].name, "yt-dlp");
|
||||
|
||||
Reference in New Issue
Block a user