Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Add custom error message if too many streams are active
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed May 21, 2024
1 parent cbe57e2 commit f8bd092
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crunchy-cli-core/src/utils/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils::filter::real_dedup_vec;
use crate::utils::locale::LanguageTagging;
use crate::utils::log::tab_info;
use crate::utils::os::{is_special_file, sanitize};
use anyhow::Result;
use anyhow::{bail, Result};
use chrono::{Datelike, Duration};
use crunchyroll_rs::media::{Resolution, SkipEvents, Stream, StreamData, Subtitle};
use crunchyroll_rs::{Concert, Episode, Locale, MediaCollection, Movie, MusicVideo};
Expand Down Expand Up @@ -176,13 +176,15 @@ impl SingleFormat {
_ => unreachable!(),
};

// sometimes the request to get streams fails with an 403 and the message "JWT error",
// even if the jwt (i guess the auth bearer token is meant by that) is perfectly valid.
// it's retried the request 3 times if this specific error occurs
if let Err(crunchyroll_rs::error::Error::Request { message, .. }) = &stream {
// sometimes the request to get streams fails with an 403 and the message
// "JWT error", even if the jwt (i guess the auth bearer token is meant by that) is
// perfectly valid. it's retried the request 3 times if this specific error occurs
if message == "JWT error" && i < 3 {
i += 1;
continue;
} else if message.starts_with("TOO_MANY_ACTIVE_STREAMS") {
bail!("Too many active/parallel streams. Please close at least one stream you're watching and try again")
}
};
return Ok(stream?);
Expand Down

0 comments on commit f8bd092

Please sign in to comment.