crunchyroll-rs

A Rust library for the undocumented Crunchyroll api.

crates.io Docs CI License Discord

We are in no way affiliated with, maintained, authorized, sponsored, or officially associated with Crunchyroll LLC or any of its subsidiaries or affiliates. The official Crunchyroll website can be found at https://crunchyroll.com/.

Documentation

The documentation is available at docs.rs.

Example

You need this crate and tokio as dependency in your Cargo.toml in order to start working: toml [dependencies] crunchyroll-rs = "0.4" tokio = { version = "1.29", features = ["full"] }

The following code prints the data of the episode behind the given url:

```rust use crunchyrollrs::{Crunchyroll, MediaCollection}; use crunchyrollrs::parse::UrlType;

[tokio::main]

async fn main() -> Result<(), Box> { // log in to crunchyroll with your username and password let crunchyroll = Crunchyroll::builder() .loginwithcredentials("", "") .await?;

let url = crunchyroll_rs::parse_url("https://www.crunchyroll.com/watch/GRDQPM1ZY/alone-and-lonesome").expect("url is not valid");
if let UrlType::EpisodeOrMovie(media_id) = url {
    if let MediaCollection::Episode(episode) = crunchyroll.media_collection_from_id(media_id).await? {
        println!(
            "Url is episode {} ({}) of {} season {}",
            episode.episode_number,
            episode.title,
            episode.series_title,
            episode.season_number
        )
    }
} else {
    panic!("Url is not a episode")
}

Ok(())

} ```

More examples can be found in the examples/ directory.

Api Coverage

Crunchyroll regularly updates their api but does not provide any documentation for it. Because we do not monitor the api constantly, so we cannot immediately say when a new endpoint is added or something has changed on already existing and implemented endpoints (which is semi-covered by the __test-strict feature, at least). If you find an endpoint which is not implemented or has changes feel free to open a new issue and tell us, or fork the library and implement it yourself.

Cloudflare

Crunchyroll uses the cloudflare bot protection to detect if requests are made by a human. Obviously this library makes automated requests and thus, cloudflare sometimes blocks requests. You'll notice this either when the library errors with could not bypass cloudflare bot protection or a big html message. There are internal ways which are trying to bypass the protection, but they don't always work. The CrunchyrollBuilder::client and CrunchyrollBuilder::client_builder methods can be used to pass a custom reqwest http client which might have configurations to bypass cloudflare, implemented by you.

License

This project is licensed under either of the following licenses, at your option: