Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide cmd on windows #62

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::error::Error as StdError;
use std::fmt;
#[cfg(target_os = "windows")]
use std::os::windows::process::CommandExt;
use std::path::{Path, PathBuf};
use std::process::ExitStatus;
use std::time::Duration;

#[cfg(target_os = "windows")]
const CREATE_NO_WINDOW: u32 = 0x08000000;

/// Exposes a function to download the latest version of youtube-dl/yt-dlp.
#[cfg(any(feature = "downloader-rustls-tls", feature = "downloader-native-tls"))]
pub mod downloader;
Expand Down Expand Up @@ -565,7 +570,15 @@ impl YoutubeDl {
use wait_timeout::ChildExt;

let path = self.path();
#[cfg(not(target_os = "windows"))]
let mut child = Command::new(path)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.args(args)
.spawn()?;
#[cfg(target_os = "windows")]
let mut child = Command::new(path)
.creation_flags(CREATE_NO_WINDOW)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.args(args)
Expand Down Expand Up @@ -609,7 +622,15 @@ impl YoutubeDl {
use tokio::time::timeout;

let path = self.path();
#[cfg(not(target_os = "windows"))]
let mut child = Command::new(path)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.args(args)
.spawn()?;
#[cfg(target_os = "windows")]
let mut child = Command::new(path)
.creation_flags(CREATE_NO_WINDOW)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.args(args)
Expand Down
Loading