diff --git a/Cargo.toml b/Cargo.toml index 68b1c8d..7822b33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crunchyroll-rs" -version = "0.8.3" +version = "0.8.4" authors = ["Crunchy Labs Maintainers"] edition = "2021" description = "Pure Rust implementation of the crunchyroll api." @@ -29,26 +29,27 @@ __test_strict = [] [dependencies] async-trait = "0.1" -chrono = { version = "0.4", features = ["serde"] } +# chrono introduced the try_* methods in version 0.4.32 and deprecated all non try_* methods in version 0.4.35 +chrono = { version = ">=0.4.32", features = ["serde"] } futures-util = { version = "0.3", features = ["std"], default-features = false } jsonwebtoken = { version = "9.2", default-features = false } # the patch version number is necessary for the 'reqwest' and 'rustls' dependencies to prevent incompatability errors # (https://github.com/seanmonstar/reqwest/issues/1837) -reqwest = { version = "0.11.23", features = ["cookies", "json", "rustls-tls"], default-features = false } -rustls = { version = "0.21.6", features = ["dangerous_configuration"] } +reqwest = { version = "0.11.25", features = ["cookies", "json", "rustls-tls"], default-features = false } +rustls = "0.22.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_urlencoded = "0.7" smart-default = "0.7" -tokio = { version = "1.35", features = ["sync"] } +tokio = { version = "1.36", features = ["sync"] } webpki-roots = "0.26" -crunchyroll-rs-internal = { version = "0.8.3", path = "internal" } +crunchyroll-rs-internal = { version = "0.8.4", path = "internal" } # Optional / required from features aes = { version = "0.8", optional = true } cbc = { version = "0.1", optional = true } -dash-mpd = { version = "0.14", default-features = false, optional = true } +dash-mpd = { version = "0.15", default-features = false, optional = true } lazy_static = { version = "1.4", optional = true } m3u8-rs = { version = "6.0", optional = true } regex = { version = "1.10", default-features = false, features = ["std"], optional = true } @@ -58,7 +59,7 @@ tower-service = { version = "0.3", optional = true } anyhow = "1.0" once_cell = "1.19" rand = "0.8" -tokio = { version = "1.35", features = ["macros", "rt", "rt-multi-thread"] } +tokio = { version = "1.36", features = ["macros", "rt", "rt-multi-thread"] } [workspace] members = ["internal"] diff --git a/internal/Cargo.toml b/internal/Cargo.toml index 9e4eb06..0ad8c28 100644 --- a/internal/Cargo.toml +++ b/internal/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crunchyroll-rs-internal" -version = "0.8.3" +version = "0.8.4" authors = ["Crunchy Labs Maintainers"] edition = "2021" description = "Internal crate for crunchyroll-rs. Do not use." diff --git a/src/crunchyroll.rs b/src/crunchyroll.rs index b0c91eb..e49fce3 100644 --- a/src/crunchyroll.rs +++ b/src/crunchyroll.rs @@ -301,8 +301,8 @@ mod auth { } SessionToken::Anonymous => SessionToken::Anonymous, }; - new_config.session_expire = - Utc::now().add(Duration::seconds(login_response.expires_in as i64)); + new_config.session_expire = Utc::now() + .add(Duration::try_seconds(login_response.expires_in as i64).unwrap()); *config = new_config; } @@ -588,20 +588,25 @@ mod auth { /// to set your built client. pub fn predefined_client_builder() -> ClientBuilder { let mut root_store = rustls::RootCertStore::empty(); - root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| { - rustls::OwnedTrustAnchor::from_subject_spki_name_constraints( - ta.subject.to_vec(), - ta.subject_public_key_info.to_vec(), - ta.name_constraints.clone().map(|nc| nc.to_vec()), + root_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned()); + + let tls_config = rustls::ClientConfig::builder_with_protocol_versions(&[ + &rustls::version::TLS12, + &rustls::version::TLS13, + ]) + .with_webpki_verifier( + rustls::client::WebPkiServerVerifier::builder_with_provider( + root_store.into(), + rustls::crypto::CryptoProvider { + kx_groups: vec![rustls::crypto::ring::kx_group::X25519], + ..rustls::crypto::ring::default_provider() + } + .into(), ) - })); - let tls_config = rustls::ClientConfig::builder() - .with_cipher_suites(rustls::DEFAULT_CIPHER_SUITES) - .with_kx_groups(&[&rustls::kx_group::X25519]) - .with_protocol_versions(&[&rustls::version::TLS12, &rustls::version::TLS13]) - .unwrap() - .with_root_certificates(root_store) - .with_no_client_auth(); + .build() + .unwrap(), + ) + .with_no_client_auth(); Client::builder() .https_only(true) @@ -854,7 +859,7 @@ mod auth { access_token: login_response.access_token, session_token, session_expire: Utc::now() - .add(Duration::seconds(login_response.expires_in as i64)), + .add(Duration::try_seconds(login_response.expires_in as i64).unwrap()), }), details: ExecutorDetails { locale: self.locale, diff --git a/src/internal/serde.rs b/src/internal/serde.rs index cc49086..7540a6e 100644 --- a/src/internal/serde.rs +++ b/src/internal/serde.rs @@ -82,7 +82,7 @@ pub(crate) fn deserialize_millis_to_duration<'de, D>(deserializer: D) -> Result< where D: Deserializer<'de>, { - Ok(Duration::milliseconds(i64::deserialize(deserializer)?)) + Ok(Duration::try_milliseconds(i64::deserialize(deserializer)?).unwrap()) } pub(crate) fn serialize_duration_to_millis<S>( diff --git a/src/media/anime/episode.rs b/src/media/anime/episode.rs index 9a79e54..db3c558 100644 --- a/src/media/anime/episode.rs +++ b/src/media/anime/episode.rs @@ -90,7 +90,7 @@ pub struct Episode { #[serde(alias = "duration_ms")] #[serde(deserialize_with = "crate::internal::serde::deserialize_millis_to_duration")] #[serde(serialize_with = "crate::internal::serde::serialize_duration_to_millis")] - #[default(Duration::milliseconds(0))] + #[default(Duration::try_milliseconds(0).unwrap())] pub duration: Duration, #[default(DateTime::<Utc>::from(std::time::SystemTime::UNIX_EPOCH))] diff --git a/src/media/anime/movie.rs b/src/media/anime/movie.rs index 9ef3341..f342af3 100644 --- a/src/media/anime/movie.rs +++ b/src/media/anime/movie.rs @@ -36,7 +36,7 @@ pub struct Movie { #[serde(alias = "duration_ms")] #[serde(deserialize_with = "crate::internal::serde::deserialize_millis_to_duration")] #[serde(serialize_with = "crate::internal::serde::serialize_duration_to_millis")] - #[default(Duration::milliseconds(0))] + #[default(Duration::try_milliseconds(0).unwrap())] pub duration: Duration, pub images: ThumbnailImages, diff --git a/src/media/music/artist.rs b/src/media/music/artist.rs index 31635ba..594176e 100644 --- a/src/media/music/artist.rs +++ b/src/media/music/artist.rs @@ -81,12 +81,12 @@ pub struct Artist { #[serde(alias = "totalConcertDurationMs")] #[serde(deserialize_with = "crate::internal::serde::deserialize_millis_to_duration")] #[serde(serialize_with = "crate::internal::serde::serialize_duration_to_millis")] - #[default(Duration::milliseconds(0))] + #[default(Duration::try_milliseconds(0).unwrap())] pub total_concert_duration: Duration, #[serde(alias = "totalVideoDurationMs")] #[serde(deserialize_with = "crate::internal::serde::deserialize_millis_to_duration")] #[serde(serialize_with = "crate::internal::serde::serialize_duration_to_millis")] - #[default(Duration::milliseconds(0))] + #[default(Duration::try_milliseconds(0).unwrap())] pub total_video_duration: Duration, pub images: PosterImages, diff --git a/src/media/music/concert.rs b/src/media/music/concert.rs index 76a6e76..6ec95e2 100644 --- a/src/media/music/concert.rs +++ b/src/media/music/concert.rs @@ -51,7 +51,7 @@ pub struct Concert { #[serde(alias = "durationMs")] #[serde(deserialize_with = "crate::internal::serde::deserialize_millis_to_duration")] #[serde(serialize_with = "crate::internal::serde::serialize_duration_to_millis")] - #[default(Duration::milliseconds(0))] + #[default(Duration::try_milliseconds(0).unwrap())] pub duration: Duration, #[default(DateTime::<Utc>::from(std::time::SystemTime::UNIX_EPOCH))] pub original_release: DateTime<Utc>, diff --git a/src/media/music/music_video.rs b/src/media/music/music_video.rs index 07fcd56..c19f8a4 100644 --- a/src/media/music/music_video.rs +++ b/src/media/music/music_video.rs @@ -55,7 +55,7 @@ pub struct MusicVideo { #[serde(alias = "durationMs")] #[serde(deserialize_with = "crate::internal::serde::deserialize_millis_to_duration")] #[serde(serialize_with = "crate::internal::serde::serialize_duration_to_millis")] - #[default(Duration::milliseconds(0))] + #[default(Duration::try_milliseconds(0).unwrap())] pub duration: Duration, #[default(DateTime::<Utc>::from(std::time::SystemTime::UNIX_EPOCH))]