https://github.com/metaory/nyaa-cli
🚧 Download episodes in bulk from nyaa.si
https://github.com/metaory/nyaa-cli
Last synced: 11 months ago
JSON representation
🚧 Download episodes in bulk from nyaa.si
- Host: GitHub
- URL: https://github.com/metaory/nyaa-cli
- Owner: metaory
- License: mit
- Created: 2025-06-04T16:16:37.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-04T22:40:10.000Z (about 1 year ago)
- Last Synced: 2025-06-05T02:54:26.433Z (about 1 year ago)
- Language: Shell
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
nyaa-cli
Smart anime torrent fetcher with stateful episode tracking
Installation |
Usage |
Patterns |
Workflow
---
## Requirements
- `Bash 5.0+`
- `jq`
- `curl`
- `Go` _(needed for first-time installation of `pup`)_
Bash 5+ (macOS users only)
This script requires Bash 5.0 or later.
On macOS, the default /bin/bash is too old.
Install the latest Bash with Homebrew:
```sh
brew install bash
```
Then, either:
- Run the script with the full path:
```sh
/opt/homebrew/bin/bash ./nyaa-cli ...
```
- Or, add Homebrew Bash to your PATH (Apple Silicon):
```sh
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
```
(For Intel Macs, use /usr/local/bin)
Check your Bash version:
```sh
bash --version
```
It should say `5.x` or later
---
## Installation
```sh
# clone the repository
git clone https://github.com/metaory/nyaa-cli.git
cd nyaa-cli
# make the script executable
chmod +x nyaa-cli
# symlink the script to somewhere in $PATH
sudo ln -sf "$(pwd)/nyaa-cli" /usr/local/bin/nyaa-cli
```
## Usage
```dart
nyaa-cli :: Smart anime torrent fetcher with stateful episode tracking
Options:
-n, --name Anime name (required)
-e, --episode Download a single episode
-f, --from Starting episode (exclusive with -e)
-t, --to Ending episode (optional, with -f)
-q, --quality Video quality (default: 720)
-u, --uploader Uploader filter (e.g. Erai, SubsPlease)
-o, --output Output directory (default: ./output)
-h, --help Show this help message
Notes:
• -f and -e cannot be used together
• -f without -t downloads all episodes from start
• Not specifying -u picks highest seeder
```
### Examples
```bash
# Basic usage - continues from last downloaded episode
nyaa-cli --name "one piece"
# Download a specific episode
nyaa-cli --name "one piece" --episode 120
# Download all episodes from a starting point
nyaa-cli --name "one piece" --from 120
# Download a specific range of episodes
nyaa-cli --name "one piece" --from 120 --to 130
# Additional options
nyaa-cli --name "one piece" --from 120 --quality "720"
nyaa-cli --name "one piece" --from 120 --uploader "Erai"
```
---
Continue downloading from last tracked episode
---
More Demos
Single Episode
Download a specific episode by number
Episode Range
Download multiple episodes within a range
From Episode
Download all episodes from a starting point
---
Usage Patterns
The script supports four main usage patterns:
1. **Continue from Last Episode** (`--name` only)
- Automatically continues from the last downloaded episode
- If no previous episodes found, starts from episode 1
- Uses state file to track progress
2. **Single Episode** (`--episode`)
- Downloads a specific episode
- Cannot be used with `--from` or `--to`
- Example: `--episode 120`
3. **From Episode to Present** (`--from` without `--to`)
- Downloads all available episodes from the starting point
- Continues until no more episodes are found
- Example: `--from 120`
4. **Episode Range** (`--from` and `--to`)
- Downloads episodes within a specific range
- `--to` must be greater than `--from`
- Example: `--from 120 --to 130`
---
State Management
The script maintains a state file at `~/.local/state/nyaa-cli/progress` to track the last downloaded episode for each anime. The state file is a TSV (Tab-Separated Values) file where:
- First column: Normalized anime name
- Second column: Last downloaded episode number
Example state file:
```
one+piece 1278
solo+leveling 18
```
The state is automatically updated whenever an episode is downloaded, and is used to:
- Continue from the last downloaded episode when no episode is specified
- Track progress across multiple runs
- Start from episode 1 for new anime
---
Example Workflow
You can use `nyaa-cli` to automate your anime downloads with a torrent client that supports directory watching. For example, with **rtorrent**, you can configure it to watch a directory for new `.torrent` files. When a torrent file is placed there, rtorrent will automatically start downloading it.
A typical workflow:
1. Configure your torrent client (e.g., rtorrent) to watch a directory (e.g., `~/watch/torrents`).
2. Create a script to download new episodes (e.g., `~/bin/update-anime.sh`):
```sh
#!/bin/bash
# Update One Piece
nyaa-cli --name "one piece" --output ~/watch/torrents
# Update Solo Leveling
nyaa-cli --name "solo leveling" --output ~/watch/torrents
```
3. Make the script executable:
```sh
chmod +x ~/bin/update-anime.sh
```
4. Add a weekly cronjob to run the script (e.g., every Sunday at 2 AM):
```sh
# Edit crontab
crontab -e
# Add this line
0 2 * * 0 ~/bin/update-anime.sh
```
The script will:
- Use the state file to automatically continue from the last downloaded episode
- Download new episodes if available
- Save torrent files with normalized filenames (lowercase, no spaces, no special characters)
- Your torrent client will pick up the new files and start downloading automatically
Many other torrent clients also support directory watching for automation.
---
## License
[MIT](LICENSE)