Code Monkey home page Code Monkey logo

crunchy-cli's Introduction

crunchy-cli

๐Ÿ‘‡ A Command-line downloader for Crunchyroll.

Code size Download Badge License Release Discord CI

Usage ๐Ÿ–ฅ๏ธ โ€ข Disclaimer ๐Ÿ“œ โ€ข License โš–

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 www.crunchyroll.com.

โœจ Features

  • Download single videos and entire series from Crunchyroll.
  • Archive episodes or seasons in an .mkv file with multiple subtitles and audios.
  • Specify a range of episodes to download from an anime.
  • Search through the Crunchyroll collection and return metadata (title, duration, direct stream link, ...) of all media types.

๐Ÿ’พ Get the executable

๐Ÿ“ฅ Download the latest binaries

Check out the releases tab and get the binary from the latest (pre-)release.

๐Ÿ“ฆ Get it via a package manager

  • AUR

    If you're using Arch or an Arch based Linux distribution you are able to install our AUR package. You need an AUR helper like yay to install it.

    # this package builds crunchy-cli manually (recommended)
    $ yay -S crunchy-cli
    # this package installs the latest pre-compiled release binary
    $ yay -S crunchy-cli-bin
  • Nix

    This requires nix and you'll probably need --extra-experimental-features "nix-command flakes", depending on your configurations.

    $ nix <run|shell|develop> github:crunchy-labs/crunchy-cli
  • Scoop

    For Windows users, we support the scoop command-line installer.

    $ scoop bucket add extras
    $ scoop install extras/crunchy-cli

๐Ÿ›  Build it yourself

Since we do not support every platform and architecture you may have to build the project yourself. This requires git and Cargo.

$ git clone https://github.com/crunchy-labs/crunchy-cli
$ cd crunchy-cli
# either just build it (will be available in ./target/release/crunchy-cli)...
$ cargo build --release
# ... or install it globally
$ cargo install --force --path .

๐Ÿ–ฅ๏ธ Usage

All shown commands are examples ๐Ÿง‘๐Ÿผโ€๐Ÿณ

crunchy-cli requires you to log in. Though you can use a non-premium account, you will not have access to premium content without a subscription. You can authenticate with your credentials (user:password) or by using a refresh token.

  • Credentials

    $ crunchy-cli --credentials "user:password"
  • Refresh Token

    To obtain a refresh token, you have to log in at crunchyroll.com and extract the etp_rt cookie. The easiest way to get it is via a browser extension which lets you export your cookies, like Cookie-Editor (Firefox / Chrome). When installed, look for the etp_rt entry and extract its value.

    $ crunchy-cli --etp-rt "4ebf1690-53a4-491a-a2ac-488309120f5d"
  • Stay Anonymous

    Login without an account (you won't be able to access premium content):

    $ crunchy-cli --anonymous

Global settings

You can set specific settings which will be

  • Verbose output

    If you want to include debug information in the output, use the -v / --verbose flag to show it.

    $ crunchy-cli -v

    This flag can't be used with -q / --quiet.

  • Quiet output

    If you want to hide all output, use the -q / --quiet flag to do so. This is especially useful if you want to pipe the output video to an external program (like a video player).

    $ crunchy-cli -q
  • Language

    By default, the resulting metadata like title or description are shown in your system language (if Crunchyroll supports it, else in English). If you want to show the results in another language, use the --lang flag to set it.

    $ crunchy-cli --lang de-DE
  • Experimental fixes

    Crunchyroll constantly changes and breaks its services or just delivers incorrect answers. The --experimental-fixes flag tries to fix some of those issues. As the experimental in --experimental-fixes states, these fixes may or may not break other functionality.

    $ crunchy-cli --experimental-fixes

    For an overview which parts this flag affects, see the documentation of the underlying Crunchyroll library, all functions beginning with stabilization_ are applied.

  • Proxy

    The --proxy flag supports https and socks5 proxies to route all your traffic through. This may be helpful to bypass the geo-restrictions Crunchyroll has on certain series.

    $ crunchy-cli --proxy socks5://127.0.0.1:8080

    Make sure that proxy can either forward TLS requests, which is needed to bypass the (cloudflare) bot protection, or that it is configured so that the proxy can bypass the protection itself.

Login

The login command can store your session, so you don't have to authenticate every time you execute a command.

# save the refresh token which gets generated when login with credentials.
# your username/email and password won't be stored at any time on disk
$ crunchy-cli login --credentials "user:password"
# save etp-rt cookie
$ crunchy-cli login --etp-rt "4ebf1690-53a4-491a-a2ac-488309120f5d"

With the session stored, you do not need to pass --credentials / --etp-rt / --anonymous anymore when you want to execute a command.

Download

The download command lets you download episodes with a specific audio language and optional subtitles.

Supported urls

  • Single episode (with episode filtering)
    $ crunchy-cli download https://www.crunchyroll.com/watch/GRDQPM1ZY/alone-and-lonesome
  • Series (with episode filtering)
    $ crunchy-cli download https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

Options

  • Audio language

    Set the audio language with the -a / --audio flag. This only works if the url points to a series since episode urls are language specific.

    $ crunchy-cli download -a de-DE https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is your system locale. If not supported by Crunchyroll, en-US (American English) is the default.

  • Subtitle language

    Besides the audio, you can specify the subtitle language by using the -s / --subtitle flag. The subtitles will be burned into the video track (cf. hardsub) and thus can not be turned off.

    $ crunchy-cli download -s de-DE https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is none.

  • Output template

    Define an output template by using the -o / --output flag.

    $ crunchy-cli download -o "ditf.mp4" https://www.crunchyroll.com/watch/GRDQPM1ZY/alone-and-lonesome

    Default is {title}.mp4. See the Template Options section below for more options.

  • Resolution

    The resolution for videos can be set via the -r / --resolution flag.

    $ crunchy-cli download -r worst https://www.crunchyroll.com/watch/GRDQPM1ZY/alone-and-lonesome

    Default is best.

  • FFmpeg Preset

    You can specify specific built-in presets with the --ffmpeg-preset flag to convert videos to a specific coding while downloading. Multiple predefined presets how videos should be encoded (h264, h265, av1, ...) are available, you can see them with crunchy-cli download --help. If you need more specific ffmpeg customizations you could either convert the output file manually or use ffmpeg output arguments as value for this flag.

    $ crunchy-cli downlaod --ffmpeg-preset av1-lossless https://www.crunchyroll.com/watch/GRDQPM1ZY/alone-and-lonesome
  • Skip existing

    If you re-download a series but want to skip episodes you've already downloaded, the --skip-existing flag skips the already existing/downloaded files.

    $ crunchy-cli download --skip-existing https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx
  • Yes

    Sometimes different seasons have the same season number (e.g. Sword Art Online Alicization and Alicization War of Underworld are both marked as season 3), in such cases an interactive prompt is shown which needs user further user input to decide which season to download. The --yes flag suppresses this interactive prompt and just downloads all seasons.

    $ crunchy-cli download --yes https://www.crunchyroll.com/series/GR49G9VP6/sword-art-online

    If you've passed the -q / --quiet global flag, this flag is automatically set.

  • Force hardsub

    If you want to burn-in the subtitles, even if the output format/container supports soft-subs (e.g. .mp4), use the --force-hardsub flag to do so.

    $ crunchy-cli download --force-hardsub -s en-US https://www.crunchyroll.com/watch/GRDQPM1ZY/alone-and-lonesome

Archive

The archive command lets you download episodes with multiple audios and subtitles and merges it into a .mkv file.

Supported urls

  • Single episode (with episode filtering)
    $ crunchy-cli archive https://www.crunchyroll.com/watch/GRDQPM1ZY/alone-and-lonesome
  • Series (with episode filtering)
    $ crunchy-cli archive https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

Options

  • Audio languages

    Set the audio language with the -a / --audio flag. Can be used multiple times.

    $ crunchy-cli archive -a ja-JP -a de-DE https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is your system locale (if not supported by Crunchyroll, en-US (American English) and ja-JP (Japanese) are used).

  • Subtitle languages

    Besides the audio, you can specify the subtitle language by using the -s / --subtitle flag.

    $ crunchy-cli archive -s de-DE https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is all subtitles.

  • Output template

    Define an output template by using the -o / --output flag. crunchy-cli uses the .mkv container format, because of it's ability to store multiple audio, video and subtitle tracks at once.

    $ crunchy-cli archive -o "{title}.mkv" https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is {title}.mkv. See the Template Options section below for more options.

  • Resolution

    The resolution for videos can be set via the -r / --resolution flag.

    $ crunchy-cli archive -r worst https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is best.

  • Merge behavior

    Due to censorship, some episodes have multiple lengths for different languages. In the best case, when multiple audio & subtitle tracks are used, there is only one video track and all other languages can be stored as audio-only. But, as said, this is not always the case. With the -m / --merge flag you can define the behaviour when an episodes' video tracks differ in length. Valid options are audio - store one video and all other languages as audio only; video - store the video + audio for every language; auto - detect if videos differ in length: if so, behave like video - otherwise like audio. Subtitles will always match the primary audio and video.

    $ crunchy-cli archive -m audio https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is auto.

  • FFmpeg Preset

    You can specify specific built-in presets with the --ffmpeg-preset flag to convert videos to a specific coding while downloading. Multiple predefined presets how videos should be encoded (h264, h265, av1, ...) are available, you can see them with crunchy-cli archive --help. If you need more specific ffmpeg customizations you could either convert the output file manually or use ffmpeg output arguments as value for this flag.

    $ crunchy-cli archive --ffmpeg-preset av1-lossless https://www.crunchyroll.com/watch/GRDQPM1ZY/alone-and-lonesome
  • Default subtitle

    --default-subtitle Set which subtitle language is to be flagged as default and forced.

    $ crunchy-cli archive --default-subtitle en-US https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is none.

  • Skip existing

    If you re-download a series but want to skip episodes you've already downloaded, the --skip-existing flag skips the already existing/downloaded files.

    $ crunchy-cli archive --skip-existing https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx
  • Yes

    Sometimes different seasons have the same season number (e.g. Sword Art Online Alicization and Alicization War of Underworld are both marked as season 3), in such cases an interactive prompt is shown which needs user further user input to decide which season to download. The --yes flag suppresses this interactive prompt and just downloads all seasons.

    $ crunchy-cli archive --yes https://www.crunchyroll.com/series/GR49G9VP6/sword-art-online

    If you've passed the -q / --quiet global flag, this flag is automatically set.

Search

Supported urls/input

  • Single episode (with episode filtering)
    $ crunchy-cli search https://www.crunchyroll.com/watch/GRDQPM1ZY/alone-and-lonesome
  • Series (with episode filtering)
    $ crunchy-cli search https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx
  • Search input
    $ crunchy-cli search "darling in the franxx"

Options

  • Audio

    Set the audio language to search via the --audio flag. Can be used multiple times.

    $ crunchy-cli search --audio en-US https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is your system locale.

  • Result limit

    If your input is a search term instead of an url, you have multiple options to control which results to process. The --search-top-results-limit flag sets the limit of top search results to process. --search-series-limit sets the limit of only series, --search-movie-listing-limit of only movie listings, --search-episode-limit of only episodes and --search-music-limit of only concerts and music videos.

    $ crunchy-cli search --search-top-results-limit 10 "darling in the franxx"
    # only return series which have 'darling' in it. do not return top results which might also be non-series items
    $ crunchy-cli search --search-top-results-limit 0 --search-series-limit 10 "darling"
    # this returns 2 top results, 3 movie listings, 5 episodes and 1 music item as result
    $ crunchy-cli search --search-top-results-limit 2 --search-movie-listing-limit 3 --search-episode-limit 5 --search-music-limit 1 "test"

    Default is 5 for --search-top-results-limit, 0 for all others.

  • Output template

    The search command is designed to show only the specific information you want. This is done with the -o/--output flag. You can specify keywords in a specific pattern, and they will get replaced in the output text. The required pattern for this begins with {{, then the keyword, and closes with }} (e.g. {{episode.title}}). For example, if you want to get the title of an episode, you can use Title: {{episode.title}} and {{episode.title}} will be replaced with the episode title. You can see all supported keywords with crunchy-cli search --help.

    $ crunchy-cli search -o "{{series.title}}" https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx

    Default is S{{season.number}}E{{episode.number}} - {{episode.title}}.


Output Template Options

You can use various template options to change how the filename is processed. The following tags are available:

  • {title} โ†’ Title of the video
  • {series_name} โ†’ Name of the series
  • {season_name} โ†’ Name of the season
  • {audio} โ†’ Audio language of the video
  • {resolution} โ†’ Resolution of the video
  • {season_number} โ†’ Number of the season
  • {episode_number} โ†’ Number of the episode
  • {relative_episode_number} โ†’ Number of the episode relative to its season
  • {series_id} โ†’ ID of the series
  • {season_id} โ†’ ID of the season
  • {episode_id} โ†’ ID of the episode

Example:

$ crunchy-cli archive -o "[S{season_number}E{episode_number}] {title}.mkv" https://www.crunchyroll.com/series/G8DHV7W21/dragon-ball
# Output file: '[S01E01] Secret of the Dragon Ball.mkv'

Episode filtering

Filters patterns can be used to download a specific range of episodes from a single series.

A filter pattern may consist of either a season, an episode, or a combination of the two. When used in combination, seasons S must be defined before episodes E.

There are many possible patterns, for example:

  • ...[E5] - Download the fifth episode.
  • ...[S1] - Download the whole first season.
  • ...[-S2] - Download the first two seasons.
  • ...[S3E4-] - Download everything from season three, episode four, onwards.
  • ...[S1E4-S3] - Download season one, starting at episode four, then download season two and three.
  • ...[S3,S5] - Download season three and five.
  • ...[S1-S3,S4E2-S4E6] - Download season one to three, then episodes two to six from season four.

In practice, it would look like this:

https://www.crunchyroll.com/series/GY8VEQ95Y/darling-in-the-franxx[E1-E5]

๐Ÿ“œ Disclaimer

This tool is meant for private use only. You need a Crunchyroll Premium subscription to access premium content.

You are entirely responsible for what happens when you use crunchy-cli.

โš– License

This project is licensed under the MIT License - see the LICENSE file for more details.

crunchy-cli's People

Contributors

adracea avatar bytedream avatar dependabot[bot] avatar frooastside avatar hannesbraun avatar hekmon avatar hitorilabs avatar ichbinleoon avatar lordbex avatar pdmahon1 avatar serverfrog avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.