Added cli

bytedream 2022-03-22 19:46:21 +01:00
parent 9cae8209ba
commit 89e38a3c27

144
Cli.md Normal file

@ -0,0 +1,144 @@
### Login
Before you can do anything, you have to login first.
This can be performed via crunchyroll account email and password.
```shell
$ crunchy login user@example.com password
```
or via session id
```shell
$ crunchy login --session-id 8e9gs135defhga790dvrf2i0eris8gts
```
Note that this stores the credentials only temporary until the next reboot (on windows systems where the temp directory is not cleared it may stay forever ¯\_(ツ)_/¯).
If you want to store it explicit persistent, use the `--persistent` flag while login.
### Download
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.
```shell
$ 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).
```shell
$ 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.**
```shell
$ 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.
```shell
$ crunchy download --audio ja-JP --subtitle de-DE https://www.crunchyroll.com/darling-in-the-franxx
```
The following flags can be set to modify the command behavior:
| Short | Extended | Description |
|-------|----------------|--------------------------------------------------------------------------------|
| `-a` | `--audio` | Forces audio of the video(s). |
| `-s` | `--subtitle` | Forces subtitle of the video(s). |
| `-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. |
| `-g` | `--goroutines` | Sets how many parallel segment downloads should be used. |
### Archive
Archive is like [Download](#download) but for data horders and those under us which want to store anime for archive reasons.
It downloads the given episode(s) into an `.mkv` file, including all subtitles and audios which can be set by the user by specifying locales with the `-l` flag.
Unlike [Download](#download), you **must** have [ffmpeg](https://ffmpeg.org) installed in case to use this command.
Support for compression is also implemented. `.tar.gz` (gzip), `.tar` (tar) and `.zip` (zip) are currently supported.
To use compression, use the `--compress` flag and use a file name as argument.
The ending of the file sets the compression algorithm.
```shell
$ crunchy archive -l en-US -l de-DE https://www.crunchyroll.com/darling-in-the-franxx
```
To store all locales, use `all` as argument for `-l`.
If you're using `--compress` you can format the name: Every `{series_name}` in the string gets replaced with the actual series name from the episode(s) you're downloading.
```shell
$ crunchy archive --compress "{series_name}.tar.gz" -l all https://www.crunchyroll.com/darling-in-the-franxx
```
**NOTE**: Because of local restrictions (or other reasons) some episodes with different languages does not have the same length (because some scenes were cut out, for example).
I originally planned to only download the japanese video and extracting the audios of episodes with other languages and adding them to the video stream.
But because of this length differences it is possible that the audios does not match to the video.
With the `--merge` flag you can change the behaviour if the described situation is the case: `audio` stores one video and only the audio of all other languages, `video` stores all videos of the given languages and their audio, `auto` (which is the default) only behaves like _video_ if the length of two videos are different (and only for the two videos), else like _audio_.
The following flags can be set to modify the command behavior:
| Short | Extended | Description |
|-------|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `-l` | `--language` | Audio locale which should be downloaded. Can be used multiple times. |
| `-d` | `--directory` | Directory to download the video(s) to. |
| `-o` | `--output` | Name of the output file. |
| `-m` | `--merge` | Sets the behavior of the stream merging. Valid behaviors are 'auto', 'audio', 'video'. See the [wiki](https://github.com/ByteDream/crunchyroll-go/wiki/Cli#archive) for more information. |
| `-c` | `--compress` | If is set, all output will be compresses into an archive. This flag sets the name of the compressed output file and the file ending specifies the compression algorithm (gzip, tar, zip are supported). |
| `-r` | `--resolution` | The resolution of the video(s). `best` for best resolution, `worst` for worst. |
| `-g` | `--goroutines` | Sets how many parallel segment downloads should be used. |
### Format
The `-o` / `--output` and `-d` / `--directory` flags accept some patterns that get replaced with meta information about the episode which is currently downloaded.
| Pattern | Information |
|--------------------|-------------------------------|
| `{title}` | Title of the video. |
| `{series_name}` | Name of the series. |
| `{season_name}` | Name of the season. |
| `{season_number}` | Number of the season. |
| `{episode_number}` | Number of the episode. |
| `{resolution}` | Resolution of the video. |
| `{fps}` | Frame Rate of the video. |
| `{audio}` | Audio locale of the video. |
| `{subtitle}` | Subtitle locale of the video. |
Example:
```shell
$ crunchy download -o "S{episode_number}E{episode_number} ({title}).ts" https://www.crunchyroll.com/darling-in-the-franxx/episode-1-alone-and-lonesome-759575
...
➞ Downloading episode `Alone and Lonesome` to `S1E1 (Alone and Lonesome).ts`
...
```
### Filter
If you want to download only specific episode of a series, you could either pass every single episode url to the downloader (which is fine for 1 - 3 episodes) or use filtering.
It works pretty simple, just put a specific pattern surrounded by square brackets at the end of the url from the anime you want to download.
A season and / or episode as well as a range from where to where episodes should be downloaded can be specified.
Use the list below to get a better overview what is possible
- `...[E5]` - Download the fifth episode.
- `...[S1]` - Download the full first season.
- `...[-S2]` - Download all seasons up to and including season 2.
- `...[S3E4-]` - Download all episodes from and including season 3, episode 4.
- `...[S1E4-S3]` - Download all episodes from and including season 1, episode 4, until and including season 3.
In practise, it would look like this: `https://beta.crunchyroll.com/series/12345678/example[S1E5-S3E2]`.
The `S`, followed by the number indicates the _season_ number, `E`, followed by the number indicates an _episode_ number.
It doesn't matter if `S`, `E` or both are missing. Theoretically `[-]` is a valid pattern too.
Note that `S` must always stay before `E` when used.
There is also a regex available at [regex101.com](https://regex101.com/r/SDZyZM/1) where you can test if your pattern is correct.
Just put in your pattern into the big empty field and if the full pattern is highlighted this means it is valid. If none or only some parts are highlighted not.