# crunchyroll-go A [Go](https://golang.org) library & cli for the undocumented [crunchyroll](https://www.crunchyroll.com) api. **You surely need a crunchyroll premium account to get full (api) access.**
CLI 🖥️ • Library 📚 • Credits 🙏 • License ⚖
## 🖥️ CLI #### ✨ Features - Download single videos and entire series from [crunchyroll](https://www.crunchyroll.com) #### Get the executable - 📥 Download the latest binaries [here](https://github.com/ByteDream/crunchyroll-go/releases/latest) or get it from below - [Linux (x64)](https://github.com/ByteDream/crunchyroll-go/releases/download/v1.1.0/crunchy-v1.1.0_linux) - [Windows (x64)](https://github.com/ByteDream/crunchyroll-go/releases/download/v1.1.0/crunchy-v1.1.0_windows.exe) - [MacOS (x64)](https://github.com/ByteDream/crunchyroll-go/releases/download/v1.1.0/crunchy-v1.1.0_darwin) - If you use `arch` btw. or any other Linux distro which is based on arch, you can download the package via the [AUR](https://aur.archlinux.org/packages/crunchyroll-go/) ``` $ yay -S crunchyroll-go ``` - 🛠 Build it yourself - use `make` (requires `go` to be installed) ``` $ git clone https://github.com/ByteDream/crunchyroll-go $ cd crunchyroll-go $ make ``` - use `go` ``` $ git clone https://github.com/ByteDream/crunchyroll-go $ cd crunchyroll-go/cmd/crunchyroll-go $ go build -o crunchy ``` ### 📝 Examples #### Login Before you can do something, you have to login first. This can be performed via crunchyroll account email and password ``` $ crunchy login user@example.com password ``` or via session id ``` $ crunchy login --session-id 8e9gs135defhga790dvrf2i0eris8gts ``` #### Download **With the cli you can download single videos or entire series.** By default the cli tries to download the episode with your system language as audio. If no streams with your system language are available, the video will be downloaded with japanese audio and hardsubbed subtitles in your system language. **If your system language is not supported, an error message will be displayed and en-US (american english) will be chosen as language.** ``` $ crunchy download https://www.crunchyroll.com/darling-in-the-franxx/episode-1-alone-and-lonesome-759575 ``` With `-r best` the video(s) will have the best available resolution (mostly 1920x1080 / Full HD). ``` $ crunchy download -r best https://www.crunchyroll.com/darling-in-the-franxx/episode-1-alone-and-lonesome-759575 ``` The file is by default saved as a `.ts` (mpeg transport stream) file. `.ts` files may can't be played or are looking very weird (it depends on the video player you are using). With the `-o` flag, you can change the name (and file ending) of the output file. So if you want to save it as, for example, `mp4` file, just name it `whatever.mp4`. **You need [ffmpeg](https://ffmpeg.org) to store the video in other file formats.** ``` $ crunchy download -o "daaaaaaaaaaaaaaaarling.ts" https://www.crunchyroll.com/darling-in-the-franxx/episode-1-alone-and-lonesome-759575 ``` With the `--audio` flag you can specify which audio the video should have and with `--subtitle` which subtitle it should have. Type `crunchy help download` to see all available locales. ``` $ crunchy download --audio ja-JP --subtitle de-DE https://www.crunchyroll.com/darling-in-the-franxx ``` ##### Flags - `--audio` » forces audio of the video(s) - `--subtitle` » forces subtitle of the video(s) - `--no-hardsub` » forces that the subtitles are stored as a separate file and are not directly embedded into the video - `-d`, `--directory` » directory to download the video(s) to - `-o`, `--output` » name of the output file - `-r`, `--resolution` » the resolution of the video(s). `best` for best resolution, `worst` for worst - `--alternative-progress` » shows an alternative, not so user-friendly progress instead of the progress bar #### Help - General help ``` $ crunchy help ``` - Login help ``` $ crunchy help login ``` - Download help ``` $ crunchy help download ``` #### Global flags These flags you can use across every sub-command - `-q`, `--quiet` » disables all output - `-v`, `--verbote` » shows additional debug output - `--color` » adds color to the output (works only on not windows systems) - `-p`, `--proxy` » use a proxy to hide your ip / redirect your traffic - `-l`, `--locale` » the language to display video specific things like the title. default is your system language ## 📚 Library Download the library via `go get` ``` $ go get github.com/ByteDream/crunchyroll-go ``` ### 📝 Examples ```go func main() { // login with credentials crunchy, err := crunchyroll.LoginWithCredentials("user@example.com", "password", crunchyroll.US, http.DefaultClient) if err != nil { panic(err) } // finds a series or movie by a crunchyroll link video, err := crunchy.FindVideo("https://www.crunchyroll.com/darling-in-the-franxx") if err != nil { panic(err) } series := video.(*crunchyroll.Series) seasons, err := series.Seasons() if err != nil { panic(err) } fmt.Printf("Found %d seasons for series %s\n", len(seasons), series.Title) // search `Darling` and return 20 results series, movies, err := crunchy.Search("Darling", 20) if err != nil { panic(err) } fmt.Printf("Found %d series and %d movies for query `Darling`\n", len(series), len(movies)) } ``` ```go func main() { crunchy, err := crunchyroll.LoginWithSessionID("8e9gs135defhga790dvrf2i0eris8gts", crunchyroll.US, http.DefaultClient) if err != nil { panic(err) } // returns an episode slice with all episodes which are matching the given url. // the episodes in the returning slice differs from the underlying streams, but are all pointing to the first ditf episode episodes, err := crunchy.FindEpisode("https://www.crunchyroll.com/darling-in-the-franxx/episode-1-alone-and-lonesome-759575") if err != nil { panic(err) } fmt.Printf("Found %d episodes\n", len(episodes)) } ```