mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Take closed_captions api field for subtitles into account (#297)
This commit is contained in:
parent
3b9fc52890
commit
7cf7a8e71c
2 changed files with 15 additions and 4 deletions
|
|
@ -301,8 +301,8 @@ async fn get_format(
|
||||||
let subtitles: Vec<(Subtitle, bool)> = archive
|
let subtitles: Vec<(Subtitle, bool)> = archive
|
||||||
.subtitle
|
.subtitle
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|s| {
|
.flat_map(|s| {
|
||||||
stream
|
let subtitles = stream
|
||||||
.subtitles
|
.subtitles
|
||||||
.get(s)
|
.get(s)
|
||||||
.cloned()
|
.cloned()
|
||||||
|
|
@ -313,7 +313,13 @@ async fn get_format(
|
||||||
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.closed_captions.get(s).cloned().map(|l| (l, false));
|
||||||
|
|
||||||
|
subtitles
|
||||||
|
.into_iter()
|
||||||
|
.chain(cc.into_iter())
|
||||||
|
.collect::<Vec<(Subtitle, bool)>>()
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,12 @@ async fn get_format(
|
||||||
let subtitle = if contains_hardsub {
|
let subtitle = if contains_hardsub {
|
||||||
None
|
None
|
||||||
} else if let Some(subtitle_locale) = &download.subtitle {
|
} else if let Some(subtitle_locale) = &download.subtitle {
|
||||||
stream.subtitles.get(subtitle_locale).cloned()
|
stream
|
||||||
|
.subtitles
|
||||||
|
.get(subtitle_locale)
|
||||||
|
.cloned()
|
||||||
|
// use closed captions as fallback if no actual subtitles are found
|
||||||
|
.or_else(|| stream.closed_captions.get(subtitle_locale).cloned())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue