Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Only include one CC subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed May 14, 2024
1 parent 5902427 commit a98e31f
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions crunchy-cli-core/src/archive/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,24 +501,21 @@ async fn get_format(
.subtitle
.iter()
.flat_map(|s| {
let subtitles = stream
.subtitles
.get(s)
.cloned()
// the subtitle is probably cc if the audio is not japanese or only one
// subtitle exists for this stream
.map(|l| {
(
l,
single_format.audio != Locale::ja_JP && stream.subtitles.len() == 1,
)
});
let cc = stream.captions.get(s).cloned().map(|l| (l, true));

let mut subtitles = vec![];
if let Some(caption) = stream.captions.get(s) {
subtitles.push((caption.clone(), true))
}
if let Some(subtitle) = stream.subtitles.get(s) {
// the subtitle is probably cc if the audio is not japanese or only one subtitle
// exists for this stream
let cc = single_format.audio != Locale::ja_JP && stream.subtitles.len() == 1;
// only include the subtitles if no cc subtitle is already present or if it's
// not cc
if subtitles.is_empty() || !cc {
subtitles.push((subtitle.clone(), cc))
}
}
subtitles
.into_iter()
.chain(cc.into_iter())
.collect::<Vec<(Subtitle, bool)>>()
})
.collect();

Expand Down

0 comments on commit a98e31f

Please sign in to comment.