This commit is contained in:
nvrl committed 2026-03-22 12:37:30 +01:00
1 parent 1c701d1e61
commit 5c5dffc144
2 files changed
+17 -10

No files matched your search

+1 -4
View File
@@ -9,8 +9,5 @@ pub enum YtDlpError {
#[error("failed to parse JSON: {0}")]
JsonError(#[from] serde_json::Error),
#[error("yt-dlp exited with status {code:?}: {stderr}")]
Failure {
code: Option<i32>,
stderr: String,
},
Failure { code: Option<i32>, stderr: String },
}
+16 -6
View File
@@ -329,7 +329,10 @@ impl YtDlp {
clone = clone.arg("--newline");
let mut child = clone.spawn_yt_dlp(false).await?;
let stdout = child.stdout.take().map(|stdout| BufReader::new(stdout).lines());
let stdout = child
.stdout
.take()
.map(|stdout| BufReader::new(stdout).lines());
Ok(YtDlpChild { child, stdout })
}
@@ -337,7 +340,10 @@ impl YtDlp {
/// Executes yt-dlp and streams the raw media binary data to standard output.
/// This automatically sets `--output -` and gives you access to the async stdout reader.
pub async fn download_to_stream(&self) -> Result<YtDlpStream> {
info!("Starting binary stream download for links: {:?}", self.links);
info!(
"Starting binary stream download for links: {:?}",
self.links
);
let mut clone = self.clone();
clone = clone.arg_with("--output", "-");
let mut child = clone.spawn_yt_dlp(false).await?;
@@ -426,9 +432,11 @@ mod tests {
async fn test_version() -> Result<()> {
let ytd = YtDlp::new("").arg("--version");
let result = ytd.download().await?;
assert!(regex::Regex::new(r"\d{4}\.\d{2}\.\d{2}")
assert!(
regex::Regex::new(r"\d{4}\.\d{2}\.\d{2}")
.unwrap()
.is_match(result.output()));
.is_match(result.output())
);
Ok(())
}
@@ -452,9 +460,11 @@ mod tests {
process.wait().await?;
assert!(!lines.is_empty());
assert!(regex::Regex::new(r"\d{4}\.\d{2}\.\d{2}")
assert!(
regex::Regex::new(r"\d{4}\.\d{2}\.\d{2}")
.unwrap()
.is_match(&lines[0]));
.is_match(&lines[0])
);
Ok(())
}
}