mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Remove internal jwt error retry
This commit is contained in:
parent
5593046aae
commit
7d2ae719c8
1 changed files with 13 additions and 22 deletions
|
|
@ -166,29 +166,20 @@ impl SingleFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn stream(&self) -> Result<Stream> {
|
pub async fn stream(&self) -> Result<Stream> {
|
||||||
let mut i = 0;
|
let stream = match &self.source {
|
||||||
loop {
|
MediaCollection::Episode(e) => e.stream_maybe_without_drm().await,
|
||||||
let stream = match &self.source {
|
MediaCollection::Movie(m) => m.stream_maybe_without_drm().await,
|
||||||
MediaCollection::Episode(e) => e.stream_maybe_without_drm().await,
|
MediaCollection::MusicVideo(mv) => mv.stream_maybe_without_drm().await,
|
||||||
MediaCollection::Movie(m) => m.stream_maybe_without_drm().await,
|
MediaCollection::Concert(c) => c.stream_maybe_without_drm().await,
|
||||||
MediaCollection::MusicVideo(mv) => mv.stream_maybe_without_drm().await,
|
_ => unreachable!(),
|
||||||
MediaCollection::Concert(c) => c.stream_maybe_without_drm().await,
|
};
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(crunchyroll_rs::error::Error::Request { message, .. }) = &stream {
|
if let Err(crunchyroll_rs::error::Error::Request { message, .. }) = &stream {
|
||||||
// sometimes the request to get streams fails with an 403 and the message
|
if message.starts_with("TOO_MANY_ACTIVE_STREAMS") {
|
||||||
// "JWT error", even if the jwt (i guess the auth bearer token is meant by that) is
|
bail!("Too many active/parallel streams. Please close at least one stream you're watching and try again")
|
||||||
// perfectly valid. it's retried the request 3 times if this specific error occurs
|
}
|
||||||
if message == "JWT error" && i < 3 {
|
};
|
||||||
i += 1;
|
Ok(stream?)
|
||||||
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?);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn skip_events(&self) -> Result<Option<SkipEvents>> {
|
pub async fn skip_events(&self) -> Result<Option<SkipEvents>> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue