mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Respect debug output when showing subtitle download spinner
This commit is contained in:
parent
49de7bbba9
commit
513353890d
1 changed files with 39 additions and 22 deletions
|
|
@ -205,8 +205,8 @@ 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!(
|
||||||
|
|
@ -219,29 +219,46 @@ impl Downloader {
|
||||||
.tick_strings(&["—", "\\", "|", "/", ""]),
|
.tick_strings(&["—", "\\", "|", "/", ""]),
|
||||||
)
|
)
|
||||||
.with_finish(ProgressFinish::Abandon);
|
.with_finish(ProgressFinish::Abandon);
|
||||||
pb.enable_steady_tick(Duration::from_millis(100));
|
progress_spinner.enable_steady_tick(Duration::from_millis(100));
|
||||||
|
Some(progress_spinner)
|
||||||
|
} else {
|
||||||
|
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() {
|
||||||
|
if let Some(pb) = &progress_spinner {
|
||||||
let mut progress_message = pb.message();
|
let mut progress_message = pb.message();
|
||||||
if !progress_message.is_empty() {
|
if !progress_message.is_empty() {
|
||||||
progress_message += ", "
|
progress_message += ", "
|
||||||
}
|
}
|
||||||
progress_message += &subtitle.locale.to_string();
|
progress_message += &subtitle.locale.to_string();
|
||||||
let mut subtitle_title = subtitle.locale.to_human_readable();
|
|
||||||
|
|
||||||
if !not_cc {
|
if !not_cc {
|
||||||
progress_message += " (CC)";
|
progress_message += " (CC)";
|
||||||
subtitle_title += " (CC)"
|
|
||||||
}
|
}
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
progress_message += &format!(" [Video: #{}]", i + 1);
|
progress_message += &format!(" [Video: #{}]", i + 1);
|
||||||
|
}
|
||||||
|
pb.set_message(progress_message)
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut subtitle_title = subtitle.locale.to_human_readable();
|
||||||
|
if !not_cc {
|
||||||
|
subtitle_title += " (CC)"
|
||||||
|
}
|
||||||
|
if i != 0 {
|
||||||
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(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue