Skip to content

Commit

Permalink
docs: Clean up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoniePhiline committed Sep 13, 2022
1 parent e473bfb commit 455924c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,14 @@ async fn process_simple_embeds(page_body: &str, referer: &str, state: Arc<State>
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?;

Expand Down Expand Up @@ -273,10 +275,11 @@ async fn process_showcase_clip(clip: &Value, referer: &str, state: Arc<State>) -
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?;
}
Expand Down
8 changes: 6 additions & 2 deletions src/state/video/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -241,8 +247,6 @@ impl Video {
.await?;

self.set_stage_finished().await;

// TODO: Set stage finished
}

Ok(())
Expand Down
1 change: 1 addition & 0 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 2 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
let referer_header_value = HeaderValue::from_str(referer)?;
let url = Url::from_str(url)?;
Expand All @@ -28,6 +29,7 @@ pub async fn fetch_with_referer(url: &str, referer: &str) -> Result<String> {
.await?
}

// Await the `JoinHandle` if the given `Option` is `Some(_)`
#[inline]
pub async fn maybe_join(maybe_spawned: Option<JoinHandle<Result<()>>>) -> Result<()> {
maybe_spawned.map(|join: JoinHandle<Result<()>>| async { join.await? });
Expand Down

0 comments on commit 455924c

Please sign in to comment.