From 455924cca11c709ff20f9c4e5c3a5298d62a712b Mon Sep 17 00:00:00 2001 From: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com> Date: Tue, 13 Sep 2022 20:52:41 +0200 Subject: [PATCH] docs: Clean up comments --- src/main.rs | 7 +++++-- src/state/video/mod.rs | 8 ++++++-- src/ui/mod.rs | 1 + src/util.rs | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 04125ac..19ba38d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -106,12 +106,14 @@ async fn process_simple_embeds(page_body: &str, referer: &str, state: Arc let video = video.clone(); tokio::spawn(async move { let url = video.url(); - info!("Download simple embed '{url}'...", ); + info!("Download simple embed '{url}'..."); video.clone().download().await?; + // TODO: Make audio extraction depend on argument info!("Extract opus audio for simple embed '{url}'..."); video.clone().extract_audio("opus").await?; + // TODO: Make audio extraction depend on argument info!("Extract mp3 audio for simple embed '{url}'..."); video.extract_audio("mp3").await?; @@ -273,10 +275,11 @@ async fn process_showcase_clip(clip: &Value, referer: &str, state: Arc) - info!("Download showcase clip '{embed_url}'..."); video.clone().download().await?; + // TODO: Make audio extraction depend on argument info!("Extract opus audio for showcase clip '{embed_url}'..."); video.clone().extract_audio("opus").await?; - + // TODO: Make audio extraction depend on argument info!("Extract mp3 audio for showcase clip '{embed_url}'..."); video.extract_audio("mp3").await?; } diff --git a/src/state/video/mod.rs b/src/state/video/mod.rs index 3e13253..31cdca2 100644 --- a/src/state/video/mod.rs +++ b/src/state/video/mod.rs @@ -227,11 +227,17 @@ impl Video { debug!("Spawn: {cmd}"); self.clone() + // TODO: Need a different read strategy. `-progress pipe:1` gives multi-line progress reports each second. + // These need to be parsed or appended somehow to form a line. + // Alternatively, if we work without .child_read_to_end( Command::new("ffmpeg") .kill_on_drop(true) .stdout(Stdio::piped()) .stderr(Stdio::piped()) + .arg("-nostdin") + // TODO: Make audio extraction overwriting of existing files depend on argument + .arg("-y") .arg("-i") .arg(&source) .arg(&destination) @@ -241,8 +247,6 @@ impl Video { .await?; self.set_stage_finished().await; - - // TODO: Set stage finished } Ok(()) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 9f38b2c..de469dd 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -365,6 +365,7 @@ impl Ui { // When a video is already present before starting the app, // then this video will be finished without `video.percent_done` // ever having been set. In that case, display 100 % right away. + VideoStage::ExtractingAudio => 100.0, VideoStage::Finished => 100.0, _ => 0.0, } diff --git a/src/util.rs b/src/util.rs index 592e062..78ec8e8 100644 --- a/src/util.rs +++ b/src/util.rs @@ -5,6 +5,7 @@ use reqwest::{header::HeaderValue, Client, Url}; use tokio::task::JoinHandle; use tracing::debug; +// Fetch a URL, applying a referer header pub async fn fetch_with_referer(url: &str, referer: &str) -> Result { let referer_header_value = HeaderValue::from_str(referer)?; let url = Url::from_str(url)?; @@ -28,6 +29,7 @@ pub async fn fetch_with_referer(url: &str, referer: &str) -> Result { .await? } +// Await the `JoinHandle` if the given `Option` is `Some(_)` #[inline] pub async fn maybe_join(maybe_spawned: Option>>) -> Result<()> { maybe_spawned.map(|join: JoinHandle>| async { join.await? });