mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Fix video containing hardsub if not requested (#415)
This commit is contained in:
parent
48bb7a5ef6
commit
817963af4f
2 changed files with 18 additions and 26 deletions
|
|
@ -5,28 +5,12 @@ use crunchyroll_rs::Locale;
|
|||
pub async fn stream_data_from_stream(
|
||||
stream: &Stream,
|
||||
resolution: &Resolution,
|
||||
subtitle: Option<Locale>,
|
||||
hardsub_subtitle: Option<Locale>,
|
||||
) -> Result<Option<(StreamData, StreamData, bool)>> {
|
||||
// sometimes Crunchyroll marks episodes without real subtitles that they have subtitles and
|
||||
// reports that only hardsub episode are existing. the following lines are trying to prevent
|
||||
// potential errors which might get caused by this incorrect reporting
|
||||
// (https://github.com/crunchy-labs/crunchy-cli/issues/231)
|
||||
let mut hardsub_locales: Vec<Locale> = stream.hard_subs.keys().cloned().collect();
|
||||
let (hardsub_locale, mut contains_hardsub) = if !hardsub_locales
|
||||
.contains(&Locale::Custom("".to_string()))
|
||||
&& !hardsub_locales.contains(&Locale::Custom(":".to_string()))
|
||||
{
|
||||
// if only one hardsub locale exists, assume that this stream doesn't really contains hardsubs
|
||||
if hardsub_locales.len() == 1 {
|
||||
(Some(hardsub_locales.remove(0)), false)
|
||||
} else {
|
||||
// fallback to `None`. this should trigger an error message in `stream.dash_streaming_data`
|
||||
// that the requested stream is not available
|
||||
(None, false)
|
||||
}
|
||||
let (hardsub_locale, mut contains_hardsub) = if hardsub_subtitle.is_some() {
|
||||
(hardsub_subtitle, true)
|
||||
} else {
|
||||
let hardsubs_requested = subtitle.is_some();
|
||||
(subtitle, hardsubs_requested)
|
||||
(None, false)
|
||||
};
|
||||
|
||||
let (mut videos, mut audios) = match stream.stream_data(hardsub_locale).await {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue