Respect debug output when showing subtitle download spinner

This commit is contained in:
bytedream 2023-07-12 21:34:49 +02:00
parent 49de7bbba9
commit 513353890d

View file

@ -205,43 +205,60 @@ impl Downloader {
}) })
} }
if !format.subtitles.is_empty() { if !format.subtitles.is_empty() {
#[cfg(not(windows))] let progress_spinner = if log::max_level() == LevelFilter::Info {
let pb = ProgressBar::new_spinner() let progress_spinner = ProgressBar::new_spinner()
.with_style( .with_style(
ProgressStyle::with_template( ProgressStyle::with_template(
format!( format!(
":: {:<1$} {{msg}} {{spinner}}", ":: {:<1$} {{msg}} {{spinner}}",
"Downloading subtitles", fmt_space "Downloading subtitles", fmt_space
)
.as_str(),
) )
.as_str(), .unwrap()
.tick_strings(&["", "\\", "|", "/", ""]),
) )
.unwrap() .with_finish(ProgressFinish::Abandon);
.tick_strings(&["", "\\", "|", "/", ""]), progress_spinner.enable_steady_tick(Duration::from_millis(100));
) Some(progress_spinner)
.with_finish(ProgressFinish::Abandon); } else {
pb.enable_steady_tick(Duration::from_millis(100)); None
};
let len = get_video_length(&video_path)?; let len = get_video_length(&video_path)?;
for (subtitle, not_cc) in format.subtitles.iter() { for (subtitle, not_cc) in format.subtitles.iter() {
let mut progress_message = pb.message(); if let Some(pb) = &progress_spinner {
if !progress_message.is_empty() { let mut progress_message = pb.message();
progress_message += ", " if !progress_message.is_empty() {
progress_message += ", "
}
progress_message += &subtitle.locale.to_string();
if !not_cc {
progress_message += " (CC)";
}
if i != 0 {
progress_message += &format!(" [Video: #{}]", i + 1);
}
pb.set_message(progress_message)
} }
progress_message += &subtitle.locale.to_string();
let mut subtitle_title = subtitle.locale.to_human_readable();
let mut subtitle_title = subtitle.locale.to_human_readable();
if !not_cc { if !not_cc {
progress_message += " (CC)";
subtitle_title += " (CC)" subtitle_title += " (CC)"
} }
if i != 0 { if i != 0 {
progress_message += &format!(" [Video: #{}]", i + 1);
subtitle_title += &format!(" [Video: #{}]", i + 1) subtitle_title += &format!(" [Video: #{}]", i + 1)
} }
pb.set_message(progress_message);
let subtitle_path = self.download_subtitle(subtitle.clone(), len).await?; let subtitle_path = self.download_subtitle(subtitle.clone(), len).await?;
debug!(
"Downloaded {} subtitles{}{}",
subtitle.locale,
(!not_cc).then_some(" (cc)").unwrap_or_default(),
(i != 0)
.then_some(format!(" for video {}", i))
.unwrap_or_default()
);
subtitles.push(FFmpegMeta { subtitles.push(FFmpegMeta {
path: subtitle_path, path: subtitle_path,
language: subtitle.locale.clone(), language: subtitle.locale.clone(),