remove deprecated best_av_format since it useless for youtube now

This commit is contained in:
mykola2312 2024-03-31 19:19:51 +03:00
parent 39726c281f
commit 1b9770235d

View file

@ -115,38 +115,6 @@ impl YtDlpInfo {
} }
} }
#[deprecated(
since = "0.1.1",
note = "for YouTube download audio and video separately"
)]
pub fn best_av_format(&self) -> Option<&YtDlpFormat> {
let format = self
.formats
.iter()
.filter_map(|f| {
if f.vcodec.is_some() && f.acodec.is_some() {
Some(VideoFormat {
format: &f,
format_note: f.format_note.as_ref()?,
width: f.width?,
height: f.height?,
vbr: f.vbr?,
})
} else {
None
}
})
.max_by_key(|f| (f.width, f.height));
match format {
Some(vf) => Some(vf.format),
None => {
event!(Level::ERROR, "no av format for {}", self.id);
None
}
}
}
pub fn best_audio_format(&self) -> Option<&YtDlpFormat> { pub fn best_audio_format(&self) -> Option<&YtDlpFormat> {
let format = self let format = self
.formats .formats
@ -317,16 +285,6 @@ mod tests {
use super::YtDlp; use super::YtDlp;
use std::env; use std::env;
#[tokio::test]
async fn best_av_format() {
dotenv::from_filename(".env.test").unwrap();
let info = YtDlp::load_info(env::var("TEST_URL").unwrap().as_str())
.await
.unwrap();
let video = info.best_av_format().unwrap();
assert_eq!(video.format_id, "22");
}
#[tokio::test] #[tokio::test]
async fn best_audio_format() { async fn best_audio_format() {
dotenv::from_filename(".env.test").unwrap(); dotenv::from_filename(".env.test").unwrap();