Async API wrapper for Crunchyroll
Project description
Crunpyroll 2.0 is HERE!
- Fully async (httpx)
- Python 3.11 support
- Clean and modern code
- Updated to latest Crunchyroll API
Installation ⚙️
pip install git+https://github.com/stefanodvx/crunpyroll@main
Example Code ❓
import crunpyroll
import asyncio
client = crunpyroll.Client(
email="email",
password="password",
locale="it-IT"
)
async def main():
# Start client and login
await client.start()
# Search for Attack on Titan
query = await client.search("Attack On Titan")
series_id = query.items[0].id
print(series_id)
# Retrieve all seasons of the series
seasons = await client.get_seasons(series_id)
print(seasons)
with asyncio.Runner() as runner:
runner.run(main())
Downloading content 🔑
Crunchyroll has recently integrated the Widevine Digital Rights Management (DRM) system, resulting in challenges for certain users attempting to download content from the platform. Subsequently, the following provides an illustrative example of obtaining decryption keys through the utilities of the pywidevine library and an L3 Content Decryption Module (CDM).
from pywidevine.cdm import Cdm
from pywidevine.pssh import PSSH
from pywidevine.device import Device
...
device = Device.load("l3cdm.wvd")
cdm = Cdm.from_device(device)
# Get streams of the episode/movie
streams = await client.get_streams("GRVDQ1G4R")
# Get manifest of the format you prefer
manifest = await client.get_manifest(streams.hardsubs[0].url)
# print(manifest)
# Get Widevine PSSH from manifest
pssh = PSSH("AAAAoXBzc2gAAAAA7e.........")
session_id = cdm.open()
challenge = cdm.get_license_challenge(session_id, pssh)
license = await client.get_license(
streams.media_id,
challenge=challenge,
token=streams.token
)
cdm.parse_license(session_id, license)
for key in cdm.get_keys(session_id, "CONTENT"):
print(f"{key.kid.hex}:{key.key.hex()}")
cdm.close(session_id)
Output:
056ec1ca849e350181753cacc9bd404b:2307a188ecd8de3859b71b30791f171d
Decryption keys are universally applicable to both video and audio streams, maintaining consistency across all available formats.
TODO 📄
- Add support for token login
- Add support for visitor view (authless)
- Add support for Music
- Add missing documentation
- Add missing API methods
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
crunpyroll-2.0.tar.gz
(11.2 kB
view hashes)
Built Distribution
crunpyroll-2.0-py3-none-any.whl
(18.9 kB
view hashes)