mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Add workaround for incorrect hardsub labeling (#231)
This commit is contained in:
parent
4c396a9e4a
commit
84c70f2bee
4 changed files with 37 additions and 22 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
|
@ -412,9 +412,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crunchyroll-rs"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1fc76ad1ab97992a987dd2a5fadfa4e90fc69d337704f42b7eeb30f7fda1eb1"
|
||||
checksum = "a0b33d2464e990dec5d3e6265cc892a88ab89971cfd177b7d7c7d0e9f8cde817"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"async-trait",
|
||||
|
|
@ -434,14 +434,14 @@ dependencies = [
|
|||
"serde_urlencoded",
|
||||
"smart-default",
|
||||
"tokio",
|
||||
"webpki-roots 0.24.0",
|
||||
"webpki-roots 0.25.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crunchyroll-rs-internal"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f9581dc7276f1c327dcaa91fa6d3b3f09c46018dc5a0d7815be3f8027780a07"
|
||||
checksum = "cab3e4af975066a3dc3dd0bb50b1a29c4a3cdee5365e8b6559d21aa15d9ace6a"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"quote",
|
||||
|
|
@ -2088,12 +2088,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.24.0"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888"
|
||||
dependencies = [
|
||||
"rustls-webpki",
|
||||
]
|
||||
checksum = "1a4ac452058d835c2b7ff6d74f0ad9f40e172bb1ce661b1444f397eeb1d19e6d"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
|
|
|
|||
17
crunchy-cli-core/Cargo.lock
generated
17
crunchy-cli-core/Cargo.lock
generated
|
|
@ -381,9 +381,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crunchyroll-rs"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1fc76ad1ab97992a987dd2a5fadfa4e90fc69d337704f42b7eeb30f7fda1eb1"
|
||||
checksum = "a0b33d2464e990dec5d3e6265cc892a88ab89971cfd177b7d7c7d0e9f8cde817"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"async-trait",
|
||||
|
|
@ -403,14 +403,14 @@ dependencies = [
|
|||
"serde_urlencoded",
|
||||
"smart-default",
|
||||
"tokio",
|
||||
"webpki-roots 0.24.0",
|
||||
"webpki-roots 0.25.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crunchyroll-rs-internal"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f9581dc7276f1c327dcaa91fa6d3b3f09c46018dc5a0d7815be3f8027780a07"
|
||||
checksum = "cab3e4af975066a3dc3dd0bb50b1a29c4a3cdee5365e8b6559d21aa15d9ace6a"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"quote",
|
||||
|
|
@ -2051,12 +2051,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.24.0"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888"
|
||||
dependencies = [
|
||||
"rustls-webpki",
|
||||
]
|
||||
checksum = "1a4ac452058d835c2b7ff6d74f0ad9f40e172bb1ce661b1444f397eeb1d19e6d"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ anyhow = "1.0"
|
|||
async-trait = "0.1"
|
||||
clap = { version = "4.3", features = ["derive", "string"] }
|
||||
chrono = "0.4"
|
||||
crunchyroll-rs = { version = "0.5.0", features = ["dash-stream"] }
|
||||
crunchyroll-rs = { version = "0.5.1", features = ["dash-stream"] }
|
||||
ctrlc = "3.4"
|
||||
dialoguer = { version = "0.10", default-features = false }
|
||||
dirs = "5.0"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,32 @@
|
|||
use anyhow::Result;
|
||||
use crunchyroll_rs::media::{Resolution, Stream, VariantData};
|
||||
use crunchyroll_rs::Locale;
|
||||
|
||||
pub async fn variant_data_from_stream(
|
||||
stream: &Stream,
|
||||
resolution: &Resolution,
|
||||
) -> Result<Option<(VariantData, VariantData)>> {
|
||||
let mut streaming_data = stream.dash_streaming_data(None).await?;
|
||||
// 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 = stream.streaming_hardsub_locales();
|
||||
let hardsub_locale = 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))
|
||||
} else {
|
||||
// fallback to `None`. this should trigger an error message in `stream.dash_streaming_data`
|
||||
// that the requested stream is not available
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mut streaming_data = stream.dash_streaming_data(hardsub_locale).await?;
|
||||
streaming_data
|
||||
.0
|
||||
.sort_by(|a, b| a.bandwidth.cmp(&b.bandwidth).reverse());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue