mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Prettify negated subtitle cc boolean
This commit is contained in:
parent
72c574c883
commit
173292ff32
3 changed files with 12 additions and 12 deletions
|
|
@ -501,15 +501,15 @@ async fn get_format(
|
||||||
.subtitles
|
.subtitles
|
||||||
.get(s)
|
.get(s)
|
||||||
.cloned()
|
.cloned()
|
||||||
// the subtitle is probably not cc if the audio is japanese or more than one
|
// the subtitle is probably cc if the audio is not japanese or only one
|
||||||
// subtitle exists for this stream
|
// subtitle exists for this stream
|
||||||
.map(|l| {
|
.map(|l| {
|
||||||
(
|
(
|
||||||
l,
|
l,
|
||||||
single_format.audio == Locale::ja_JP || stream.subtitles.len() > 1,
|
single_format.audio != Locale::ja_JP && stream.subtitles.len() == 1,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let cc = stream.captions.get(s).cloned().map(|l| (l, false));
|
let cc = stream.captions.get(s).cloned().map(|l| (l, true));
|
||||||
|
|
||||||
subtitles
|
subtitles
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
||||||
|
|
@ -400,7 +400,7 @@ async fn get_format(
|
||||||
subtitles: subtitle.clone().map_or(vec![], |s| {
|
subtitles: subtitle.clone().map_or(vec![], |s| {
|
||||||
vec![(
|
vec![(
|
||||||
s,
|
s,
|
||||||
single_format.audio == Locale::ja_JP || stream.subtitles.len() > 1,
|
single_format.audio != Locale::ja_JP && stream.subtitles.len() == 1,
|
||||||
)]
|
)]
|
||||||
}),
|
}),
|
||||||
metadata: DownloadFormatMetadata {
|
metadata: DownloadFormatMetadata {
|
||||||
|
|
@ -417,7 +417,7 @@ async fn get_format(
|
||||||
subtitle.map_or(vec![], |s| {
|
subtitle.map_or(vec![], |s| {
|
||||||
vec![(
|
vec![(
|
||||||
s,
|
s,
|
||||||
single_format.audio == Locale::ja_JP || stream.subtitles.len() > 1,
|
single_format.audio != Locale::ja_JP && stream.subtitles.len() == 1,
|
||||||
)]
|
)]
|
||||||
}),
|
}),
|
||||||
)]);
|
)]);
|
||||||
|
|
|
||||||
|
|
@ -232,13 +232,13 @@ impl Downloader {
|
||||||
if let Some(subtitle_sort) = &self.subtitle_sort {
|
if let Some(subtitle_sort) = &self.subtitle_sort {
|
||||||
format
|
format
|
||||||
.subtitles
|
.subtitles
|
||||||
.sort_by(|(a_subtitle, a_not_cc), (b_subtitle, b_not_cc)| {
|
.sort_by(|(a_subtitle, a_cc), (b_subtitle, b_cc)| {
|
||||||
let ordering = subtitle_sort
|
let ordering = subtitle_sort
|
||||||
.iter()
|
.iter()
|
||||||
.position(|l| l == &a_subtitle.locale)
|
.position(|l| l == &a_subtitle.locale)
|
||||||
.cmp(&subtitle_sort.iter().position(|l| l == &b_subtitle.locale));
|
.cmp(&subtitle_sort.iter().position(|l| l == &b_subtitle.locale));
|
||||||
if matches!(ordering, Ordering::Equal) {
|
if matches!(ordering, Ordering::Equal) {
|
||||||
a_not_cc.cmp(b_not_cc).reverse()
|
a_cc.cmp(b_cc).reverse()
|
||||||
} else {
|
} else {
|
||||||
ordering
|
ordering
|
||||||
}
|
}
|
||||||
|
|
@ -451,8 +451,8 @@ impl Downloader {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
for (j, (subtitle, not_cc)) in format.subtitles.iter().enumerate() {
|
for (j, (subtitle, cc)) in format.subtitles.iter().enumerate() {
|
||||||
if !not_cc && self.no_closed_caption {
|
if *cc && self.no_closed_caption {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -462,7 +462,7 @@ impl Downloader {
|
||||||
progress_message += ", "
|
progress_message += ", "
|
||||||
}
|
}
|
||||||
progress_message += &subtitle.locale.to_string();
|
progress_message += &subtitle.locale.to_string();
|
||||||
if !not_cc {
|
if *cc {
|
||||||
progress_message += " (CC)";
|
progress_message += " (CC)";
|
||||||
}
|
}
|
||||||
if i.min(videos.len() - 1) != 0 {
|
if i.min(videos.len() - 1) != 0 {
|
||||||
|
|
@ -477,12 +477,12 @@ impl Downloader {
|
||||||
debug!(
|
debug!(
|
||||||
"Downloaded {} subtitles{}",
|
"Downloaded {} subtitles{}",
|
||||||
subtitle.locale,
|
subtitle.locale,
|
||||||
(!not_cc).then_some(" (cc)").unwrap_or_default(),
|
cc.then_some(" (cc)").unwrap_or_default(),
|
||||||
);
|
);
|
||||||
subtitles.push(FFmpegSubtitleMeta {
|
subtitles.push(FFmpegSubtitleMeta {
|
||||||
path,
|
path,
|
||||||
locale: subtitle.locale.clone(),
|
locale: subtitle.locale.clone(),
|
||||||
cc: !not_cc,
|
cc: *cc,
|
||||||
start_time: subtitle_offsets.get(&j).cloned(),
|
start_time: subtitle_offsets.get(&j).cloned(),
|
||||||
video_idx: i,
|
video_idx: i,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue