diff --git a/src/dl/yt_dlp.rs b/src/dl/yt_dlp.rs index 87a859a..9731157 100644 --- a/src/dl/yt_dlp.rs +++ b/src/dl/yt_dlp.rs @@ -28,6 +28,34 @@ impl YtDlpFormat { self.vcodec = None } } + + fn str_option(opt: &Option) -> String + where + T: ToString, + { + if let Some(value) = opt { + value.to_string() + } else { + "None".to_string() + } + } +} + +impl fmt::Display for YtDlpFormat { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "id\t{}\text\t{}\tw\t{}\th\t{}\tvcodec\t{}\tvbr\t{}\tacodec\t{}\tabr\t{}", + self.format_id, + self.ext, + Self::str_option(&self.width), + Self::str_option(&self.height), + Self::str_option(&self.vcodec), + Self::str_option(&self.vbr), + Self::str_option(&self.acodec), + Self::str_option(&self.abr) + ) + } } #[derive(Deserialize, Debug)] diff --git a/src/main.rs b/src/main.rs index 6f1db97..3c1e848 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,9 @@ async fn main() -> anyhow::Result<()> { let info = YtDlp::load_info(env::var("TEST_URL")?.as_str()) .await .expect("load_info"); - dbg!(info); + for format in info.formats { + println!("{}", format); + } Ok(()) //bot_main().await