MCPcopy Index your code
hub / github.com/crunchy-labs/crunchyroll-rs

github.com/crunchy-labs/crunchyroll-rs @v0.18.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.18.0 ↗ · + Follow
444 symbols 967 edges 82 files 93 documented · 21%

Browse by type

Functions 309 Types & classes 135
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

crunchyroll-rs

<strong>A <a href="https://www.rust-lang.org/">Rust</a> library for the undocumented <a href="https://www.crunchyroll.com/">Crunchyroll</a> api.</strong>

crates.io crates.io downloads 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:

[dependencies]
crunchyroll-rs = "0.18"
tokio = { version = "1", features = ["full"] }

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

use crunchyroll_rs::{Crunchyroll, MediaCollection};
use crunchyroll_rs::parse::UrlType;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Log in to Crunchyroll with your email and password.
    // Support for username login was dropped by Crunchyroll on December 6th, 2023
    let crunchyroll = Crunchyroll::builder()
        .login_with_credentials("<email>", "<password>", Default::default())
        .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 crate makes automated requests and thus, Cloudflare sometimes blocks requests. The crate catches these errors with the error::CrunchyrollError::Block enum field. The block occurs depending on different factors like your location. If such a block occurs you can try to create a custom reqwest::Client which has the needed configuration to bypass this check, like other user agents or tls backends (note that reqwest currently only supports native-tls besides rustls as tls backend, which is confirmed to work with openssl on Linux only, on Windows the blocks are even more aggressive). The configurations may vary on the factors addressed so there is no 100% right way to do it.

Disclaimer

This library is unofficial and not affiliated with Crunchyroll in any way.

You are entirely responsible for what happens when you use crunchyroll-rs.

License

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

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 196
Class 120
Function 113
Enum 12
Interface 3

Languages

Rust100%

Modules by API surface

src/crunchyroll.rs64 symbols
src/media/stream.rs30 symbols
src/search.rs18 symbols
src/profile.rs17 symbols
src/common.rs17 symbols
src/internal/serde.rs16 symbols
src/feed.rs16 symbols
src/error.rs15 symbols
src/list/crunchylist.rs12 symbols
tests/test_episode.rs11 symbols
src/media/anime/episode.rs11 symbols
src/media/anime/shared.rs10 symbols

For agents

$ claude mcp add crunchyroll-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page