make download_format use spawn_pipe because of yt-dlp's undefined behavior related to file naming
This commit is contained in:
parent
d229e184dc
commit
bcbdd4729b
1 changed files with 4 additions and 15 deletions
|
|
@ -4,7 +4,6 @@ use core::fmt;
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use std::fs;
|
|
||||||
use tracing::{event, Level};
|
use tracing::{event, Level};
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
|
|
@ -21,6 +20,7 @@ pub struct YtDlpFormat {
|
||||||
pub abr: Option<f32>,
|
pub abr: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
struct VideoFormat<'a> {
|
struct VideoFormat<'a> {
|
||||||
pub format: &'a YtDlpFormat,
|
pub format: &'a YtDlpFormat,
|
||||||
pub format_note: &'a String,
|
pub format_note: &'a String,
|
||||||
|
|
@ -103,18 +103,6 @@ impl YtDlpInfo {
|
||||||
Ok(info)
|
Ok(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_format(&self) -> Option<&YtDlpFormat> {
|
|
||||||
match self
|
|
||||||
.formats
|
|
||||||
.iter()
|
|
||||||
.filter(|f| f.height.is_some_and(|h| h <= Self::H_LIMIT))
|
|
||||||
.last()
|
|
||||||
{
|
|
||||||
Some(format) => Some(format),
|
|
||||||
None => self.formats.last(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn best_audio_format(&self) -> Option<&YtDlpFormat> {
|
pub fn best_audio_format(&self) -> Option<&YtDlpFormat> {
|
||||||
let format = self
|
let format = self
|
||||||
.formats
|
.formats
|
||||||
|
|
@ -257,7 +245,7 @@ impl YtDlp {
|
||||||
let file =
|
let file =
|
||||||
TmpFile::new(format!("{}_{}.{}", info.id, format.format_id, format.ext).as_str())?;
|
TmpFile::new(format!("{}_{}.{}", info.id, format.format_id, format.ext).as_str())?;
|
||||||
|
|
||||||
spawn(
|
spawn_pipe(
|
||||||
"python",
|
"python",
|
||||||
&[
|
&[
|
||||||
"-m",
|
"-m",
|
||||||
|
|
@ -266,10 +254,11 @@ impl YtDlp {
|
||||||
"-f",
|
"-f",
|
||||||
&format.format_id,
|
&format.format_id,
|
||||||
"-o",
|
"-o",
|
||||||
&file.path,
|
"-",
|
||||||
"--force-overwrites",
|
"--force-overwrites",
|
||||||
"--no-exec",
|
"--no-exec",
|
||||||
],
|
],
|
||||||
|
&file
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue