Fix cms rate limiting error for episodes and movies (#180)

This commit is contained in:
bytedream 2023-04-13 19:17:55 +02:00 committed by ByteDream
parent c4c15f9b11
commit bfc50653b1
4 changed files with 25 additions and 10 deletions

8
Cargo.lock generated
View file

@ -375,9 +375,9 @@ dependencies = [
[[package]]
name = "crunchyroll-rs"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be975d4a27439853f6e80311b497e910fc49fd24525afdc12ca27ace18b84eeb"
checksum = "b75b403a64b4cc8ed9a96cb16588475a93cb5c8643cf960907a54ae6f6ac3f0d"
dependencies = [
"aes",
"async-trait",
@ -402,9 +402,9 @@ dependencies = [
[[package]]
name = "crunchyroll-rs-internal"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8d71a343838c462ace0531b2f5556fd1ea6b677d7a3e61ac28251e87d158c47"
checksum = "d91a9978a505750f606a1fcf1efd5970d20521310e886839f2ad95c31354e54e"
dependencies = [
"darling 0.14.4",
"quote",

View file

@ -9,7 +9,7 @@ anyhow = "1.0"
async-trait = "0.1"
clap = { version = "4.2", features = ["derive", "string"] }
chrono = "0.4"
crunchyroll-rs = { version = "0.3.3", features = ["dash-stream"] }
crunchyroll-rs = { version = "0.3.4", features = ["dash-stream"] }
ctrlc = "3.2"
dirs = "5.0"
derive_setters = "0.1"

View file

@ -54,8 +54,7 @@ pub struct Cli {
#[arg(help = "Use a proxy to route all traffic through")]
#[arg(long_help = "Use a proxy to route all traffic through. \
Make sure that the proxy can either forward TLS requests, which is needed to bypass the (cloudflare) bot protection, or that it is configured so that the proxy can bypass the protection itself"
)]
Make sure that the proxy can either forward TLS requests, which is needed to bypass the (cloudflare) bot protection, or that it is configured so that the proxy can bypass the protection itself")]
#[clap(long)]
#[arg(value_parser = crate::utils::clap::clap_parse_proxy)]
proxy: Option<Proxy>,

View file

@ -5,7 +5,7 @@ use anyhow::Result;
use chrono::Duration;
use crunchyroll_rs::media::{Resolution, Stream, Subtitle, VariantData};
use crunchyroll_rs::{Concert, Episode, Locale, MediaCollection, Movie, MusicVideo};
use log::{debug, info};
use log::{debug, info, warn};
use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
@ -126,8 +126,24 @@ impl SingleFormat {
pub async fn stream(&self) -> Result<Stream> {
let stream = match &self.source {
MediaCollection::Episode(e) => e.streams().await?,
MediaCollection::Movie(m) => m.streams().await?,
MediaCollection::Episode(e) => {
if let Ok(stream) = e.legacy_streams().await {
stream
} else {
let stream = e.streams().await?;
warn!("Failed to get stream via legacy endpoint");
stream
}
}
MediaCollection::Movie(m) => {
if let Ok(stream) = m.legacy_streams().await {
stream
} else {
let stream = m.streams().await?;
warn!("Failed to get stream via legacy endpoint");
stream
}
}
MediaCollection::MusicVideo(mv) => mv.streams().await?,
MediaCollection::Concert(c) => c.streams().await?,
_ => unreachable!(),