shinkansen-cli 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shinkansen_cli-1.0.2/LICENSE +21 -0
- shinkansen_cli-1.0.2/PKG-INFO +253 -0
- shinkansen_cli-1.0.2/README.md +210 -0
- shinkansen_cli-1.0.2/pyproject.toml +66 -0
- shinkansen_cli-1.0.2/setup.cfg +4 -0
- shinkansen_cli-1.0.2/src/anime_pahe_dl/__init__.py +488 -0
- shinkansen_cli-1.0.2/src/anime_pahe_dl/cli.py +965 -0
- shinkansen_cli-1.0.2/src/anime_pahe_dl/client.py +672 -0
- shinkansen_cli-1.0.2/src/anime_pahe_dl/config.py +64 -0
- shinkansen_cli-1.0.2/src/anime_pahe_dl/downloader.py +690 -0
- shinkansen_cli-1.0.2/src/anime_pahe_dl/utils.py +56 -0
- shinkansen_cli-1.0.2/src/anime_pahe_dl/worker_pool.py +623 -0
- shinkansen_cli-1.0.2/src/shinkansen_cli.egg-info/PKG-INFO +253 -0
- shinkansen_cli-1.0.2/src/shinkansen_cli.egg-info/SOURCES.txt +20 -0
- shinkansen_cli-1.0.2/src/shinkansen_cli.egg-info/dependency_links.txt +1 -0
- shinkansen_cli-1.0.2/src/shinkansen_cli.egg-info/entry_points.txt +2 -0
- shinkansen_cli-1.0.2/src/shinkansen_cli.egg-info/requires.txt +18 -0
- shinkansen_cli-1.0.2/src/shinkansen_cli.egg-info/top_level.txt +1 -0
- shinkansen_cli-1.0.2/tests/test_cli.py +492 -0
- shinkansen_cli-1.0.2/tests/test_client.py +474 -0
- shinkansen_cli-1.0.2/tests/test_config.py +132 -0
- shinkansen_cli-1.0.2/tests/test_downloader.py +569 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Pasindu Janith
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shinkansen-cli
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Fast, reliable anime downloader for AnimePahe - built with lessons from autopahe
|
|
5
|
+
Author: Pasindu Janith
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/pasindujanith/anime-pahe-dl
|
|
8
|
+
Project-URL: Repository, https://github.com/pasindujanith/anime-pahe-dl.git
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/pasindujanith/anime-pahe-dl/issues
|
|
10
|
+
Keywords: anime,downloader,animepahe,cli,playwright
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Internet
|
|
22
|
+
Classifier: Topic :: Multimedia :: Video
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: click>=8.1.0
|
|
27
|
+
Requires-Dist: playwright>=1.45.0
|
|
28
|
+
Requires-Dist: requests>=2.31.0
|
|
29
|
+
Requires-Dist: tqdm>=4.66.0
|
|
30
|
+
Requires-Dist: rich>=13.0.0
|
|
31
|
+
Requires-Dist: InquirerPy>=0.3.4
|
|
32
|
+
Requires-Dist: nest_asyncio>=1.5.0
|
|
33
|
+
Provides-Extra: test
|
|
34
|
+
Requires-Dist: pytest>=7.4.0; extra == "test"
|
|
35
|
+
Requires-Dist: pytest-mock>=3.12.0; extra == "test"
|
|
36
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "test"
|
|
37
|
+
Requires-Dist: responses>=0.24.0; extra == "test"
|
|
38
|
+
Provides-Extra: dev
|
|
39
|
+
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
40
|
+
Requires-Dist: mypy>=1.10.0; extra == "dev"
|
|
41
|
+
Requires-Dist: pre-commit>=3.7.0; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# 🚅 Shinkansen - Anime Downloader (anime-pahe-dl)
|
|
45
|
+
|
|
46
|
+
> **A blazing-fast, fully interactive terminal application for downloading anime.**
|
|
47
|
+
|
|
48
|
+
<p align="left">
|
|
49
|
+
<img src="demo.gif" alt="Shinkansen TUI Demo" width="700" height="450" >
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
`Shinkansen` is a powerful Terminal User Interface (TUI) that lets you search and batch-download anime directly
|
|
53
|
+
from [AnimePahe](https://animepahe.si).
|
|
54
|
+
It natively bypasses Cloudflare, fetches episodes in true parallel, and features an elegant interactive full-width
|
|
55
|
+
menu right in your terminal.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🚀 Quick Start (1-Command Install)
|
|
60
|
+
|
|
61
|
+
For the absolute easiest setup across Mac/Linux/Windows, install the tool globally in its own isolated environment
|
|
62
|
+
using [pipx](https://pipx.pypa.io/) (the modern standard for Python CLIs):
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Safely install globally using the official PyPI release (Zero Configuration!)
|
|
66
|
+
pipx install shinkansen-cli
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## ⚙️ Manual Installation (For Development)
|
|
70
|
+
|
|
71
|
+
If you are cloning the repository directly instead of using the 1-command install:
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/sano0007/Shinkansen.git
|
|
74
|
+
cd Shinkansen
|
|
75
|
+
pip install -e .
|
|
76
|
+
|
|
77
|
+
# Note: The embedded auto-installer will automatically secure Playwright on first run!
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 🎮 Usage
|
|
81
|
+
|
|
82
|
+
### Interactive Mode (Recommended)
|
|
83
|
+
|
|
84
|
+
Simply type the root command anywhere in your terminal to launch the pure TUI experience:
|
|
85
|
+
```bash
|
|
86
|
+
shinkansen
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
This launches a beautiful, dynamically-rendered menu offering Search & Download, Library browsing, History tracking, and
|
|
90
|
+
recursive Settings management—all fully navigable via your arrow keys!
|
|
91
|
+
|
|
92
|
+
### Advanced Command-Line Execution
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Interactive download directly from a query
|
|
96
|
+
shinkansen get "naruto"
|
|
97
|
+
|
|
98
|
+
# Search for anime
|
|
99
|
+
shinkansen search "naruto"
|
|
100
|
+
|
|
101
|
+
# List episodes
|
|
102
|
+
shinkansen episodes <session>
|
|
103
|
+
|
|
104
|
+
# Download a single episode
|
|
105
|
+
shinkansen download <session> --episode 1 --quality 720 --name "Naruto"
|
|
106
|
+
|
|
107
|
+
# Download a range of episodes
|
|
108
|
+
shinkansen download <session> --range 1-12 --quality 1080
|
|
109
|
+
|
|
110
|
+
# Download all episodes
|
|
111
|
+
shinkansen download <session> --all
|
|
112
|
+
|
|
113
|
+
# Override parallel workers (default: from config)
|
|
114
|
+
shinkansen download <session> --all --workers 5
|
|
115
|
+
|
|
116
|
+
# Show available sources for an episode
|
|
117
|
+
shinkansen sources <session> 1
|
|
118
|
+
|
|
119
|
+
# View download history
|
|
120
|
+
shinkansen history
|
|
121
|
+
|
|
122
|
+
# Browse downloaded anime library
|
|
123
|
+
shinkansen library
|
|
124
|
+
|
|
125
|
+
# Find anime in library
|
|
126
|
+
shinkansen find "naruto"
|
|
127
|
+
|
|
128
|
+
# Manage configuration
|
|
129
|
+
shinkansen config show
|
|
130
|
+
shinkansen config set quality 720
|
|
131
|
+
shinkansen config set create_folder true
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Features
|
|
135
|
+
|
|
136
|
+
- **HTTP-first approach** -- tries direct API calls before launching a browser, for speed
|
|
137
|
+
- **Cloudflare bypass** -- Playwright fallback when Cloudflare blocks HTTP requests
|
|
138
|
+
- **Persistent cookie caching** -- saves Cloudflare session cookies to disk (`~/.shinkansen/cookies.json`) so subsequent
|
|
139
|
+
runs skip the challenge entirely (25-min TTL)
|
|
140
|
+
- **Parallel batch downloads** -- spawns multiple Playwright browser instances (`prepare_workers`, default 3) to prepare
|
|
141
|
+
episodes in true parallel, with a separate download thread pool (`max_downloads`, default 5); 200 episodes drops from
|
|
142
|
+
~5 hours to ~2 hours
|
|
143
|
+
- **Pipelined downloading** -- each episode's download starts the moment it's resolved, overlapping Playwright prep
|
|
144
|
+
with file I/O
|
|
145
|
+
- **Multiple quality options** -- select 360p, 480p, 720p, 1080p, best, or worst
|
|
146
|
+
- **Sub/Dub preference** -- choose between Japanese audio with subtitles or English dub
|
|
147
|
+
- **Download resume** -- partial downloads are resumed automatically via HTTP Range headers
|
|
148
|
+
- **Episode ranges** -- download specific episodes (`--range 1-12`), comma-separated (`--range 1,3,5-7`), or all (
|
|
149
|
+
`--all`)
|
|
150
|
+
- **Download history** -- tracks every download with anime name, episode, quality, and date
|
|
151
|
+
- **Anime library** -- browse and search your downloaded collection
|
|
152
|
+
- **Config system** -- persistent settings at `~/.shinkansen/config.json` (default quality, output dir, folder creation,
|
|
153
|
+
etc.)
|
|
154
|
+
- **Interactive TUI** -- run `shinkansen` to access a beautiful arrow-key navigable main menu routing your entire
|
|
155
|
+
application
|
|
156
|
+
- **Automatic Retries** -- any episodes that timeout or fail directly prompt you to instantly retry them at the end of
|
|
157
|
+
the batch
|
|
158
|
+
- **Rich terminal UI** -- Claude-style split screen welcome banners, colored output, live progress bars, tables, and
|
|
159
|
+
spinners
|
|
160
|
+
|
|
161
|
+
## Architecture
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
AnimePahe API (JSON)
|
|
165
|
+
|
|
|
166
|
+
v
|
|
167
|
+
AnimePaheClient (client.py)
|
|
168
|
+
- HTTP-first with Playwright fallback
|
|
169
|
+
- Cookie caching for Cloudflare sessions
|
|
170
|
+
- Paginated episode fetching
|
|
171
|
+
|
|
|
172
|
+
v
|
|
173
|
+
Downloader (downloader.py)
|
|
174
|
+
- pahe.win -> kwik.cx -> direct .mp4 URL
|
|
175
|
+
- Split into prepare() + download_prepared() for pipelining
|
|
176
|
+
- Resume support via Range headers
|
|
177
|
+
- Pluggable backends: requests (default) or aria2c
|
|
178
|
+
|
|
|
179
|
+
v
|
|
180
|
+
WorkerPool (worker_pool.py)
|
|
181
|
+
- N PrepareWorkers (own Playwright browser + thread each)
|
|
182
|
+
- Download ThreadPoolExecutor (bounded by max_downloads)
|
|
183
|
+
- Cookie sharing: Worker 0 clears Cloudflare, others load cached cookies
|
|
184
|
+
- Rich Live progress display
|
|
185
|
+
|
|
|
186
|
+
v
|
|
187
|
+
CLI (cli.py)
|
|
188
|
+
- Click commands with Rich output
|
|
189
|
+
- History and library management
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Configuration
|
|
193
|
+
|
|
194
|
+
Settings are stored at `~/.shinkansen/config.json`:
|
|
195
|
+
|
|
196
|
+
| Setting | Default | Description |
|
|
197
|
+
|----------------------|-------------|------------------------------------------------------|
|
|
198
|
+
| `default_quality` | `best` | Preferred video quality |
|
|
199
|
+
| `default_output` | `downloads` | Output directory |
|
|
200
|
+
| `auto_retry` | `true` | Retry failed downloads |
|
|
201
|
+
| `retry_count` | `3` | Number of retry attempts |
|
|
202
|
+
| `create_folder` | `true` | Create per-anime subfolders |
|
|
203
|
+
| `parallel_downloads` | `3` | Number of episodes to prefetch/download concurrently |
|
|
204
|
+
| `download_backend` | `requests` | Download engine: `requests` or `aria2c` |
|
|
205
|
+
| `aria2c_path` | `aria2c` | Path to aria2c binary (if not in `$PATH`) |
|
|
206
|
+
| `aria2c_connections` | `16` | Segments per file for aria2c (`--split`) |
|
|
207
|
+
| `prepare_workers` | `3` | Parallel Playwright browser instances for batch prep |
|
|
208
|
+
| `max_downloads` | `5` | Max concurrent file downloads |
|
|
209
|
+
|
|
210
|
+
## Testing
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Install test dependencies
|
|
214
|
+
pip install -e ".[test]"
|
|
215
|
+
|
|
216
|
+
# Run all tests
|
|
217
|
+
pytest tests/ -v
|
|
218
|
+
|
|
219
|
+
# Run with coverage
|
|
220
|
+
pytest tests/ --cov=anime_pahe_dl --cov-report=term-missing
|
|
221
|
+
|
|
222
|
+
# Run a specific test module
|
|
223
|
+
pytest tests/test_config.py -v
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## 🤝 Contributing & New Anime Sources
|
|
227
|
+
|
|
228
|
+
**We want to grow!** Shinkansen currently supports downloading directly from AnimePahe, but our goal is to build a
|
|
229
|
+
massive ecosystem supporting multiple anime sources.
|
|
230
|
+
|
|
231
|
+
We highly encourage the open-source community to get involved:
|
|
232
|
+
|
|
233
|
+
- **Suggest new anime sites** to support by opening an Issue.
|
|
234
|
+
- **Fork the repository** and open Pull Requests implementing new fetchers/extractors.
|
|
235
|
+
- Improve the interactive TUI or squash bugs.
|
|
236
|
+
|
|
237
|
+
Please read our `CONTRIBUTING.md` guidelines to easily get started. Let's build the ultimate anime CLI together!
|
|
238
|
+
|
|
239
|
+
## 💖 Support
|
|
240
|
+
|
|
241
|
+
If you love the blinding speed of Shinkansen and want to say thanks for the hours saved, you can buy me a coffee! It
|
|
242
|
+
goes a long way in keeping the project alive and well-maintained.
|
|
243
|
+
|
|
244
|
+
[](https://ko-fi.com/sanoo)
|
|
245
|
+
|
|
246
|
+
## Requirements
|
|
247
|
+
|
|
248
|
+
- Python >= 3.9
|
|
249
|
+
- [Playwright](https://playwright.dev/python/) (Chromium) -- for Cloudflare bypass and source extraction
|
|
250
|
+
- [Click](https://click.palletsprojects.com/) -- CLI framework
|
|
251
|
+
- [Rich](https://rich.readthedocs.io/) -- terminal UI
|
|
252
|
+
- [requests](https://requests.readthedocs.io/) -- HTTP client
|
|
253
|
+
- [tqdm](https://tqdm.github.io/) -- progress bars
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# 🚅 Shinkansen - Anime Downloader (anime-pahe-dl)
|
|
2
|
+
|
|
3
|
+
> **A blazing-fast, fully interactive terminal application for downloading anime.**
|
|
4
|
+
|
|
5
|
+
<p align="left">
|
|
6
|
+
<img src="demo.gif" alt="Shinkansen TUI Demo" width="700" height="450" >
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
`Shinkansen` is a powerful Terminal User Interface (TUI) that lets you search and batch-download anime directly
|
|
10
|
+
from [AnimePahe](https://animepahe.si).
|
|
11
|
+
It natively bypasses Cloudflare, fetches episodes in true parallel, and features an elegant interactive full-width
|
|
12
|
+
menu right in your terminal.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🚀 Quick Start (1-Command Install)
|
|
17
|
+
|
|
18
|
+
For the absolute easiest setup across Mac/Linux/Windows, install the tool globally in its own isolated environment
|
|
19
|
+
using [pipx](https://pipx.pypa.io/) (the modern standard for Python CLIs):
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Safely install globally using the official PyPI release (Zero Configuration!)
|
|
23
|
+
pipx install shinkansen-cli
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## ⚙️ Manual Installation (For Development)
|
|
27
|
+
|
|
28
|
+
If you are cloning the repository directly instead of using the 1-command install:
|
|
29
|
+
```bash
|
|
30
|
+
git clone https://github.com/sano0007/Shinkansen.git
|
|
31
|
+
cd Shinkansen
|
|
32
|
+
pip install -e .
|
|
33
|
+
|
|
34
|
+
# Note: The embedded auto-installer will automatically secure Playwright on first run!
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 🎮 Usage
|
|
38
|
+
|
|
39
|
+
### Interactive Mode (Recommended)
|
|
40
|
+
|
|
41
|
+
Simply type the root command anywhere in your terminal to launch the pure TUI experience:
|
|
42
|
+
```bash
|
|
43
|
+
shinkansen
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This launches a beautiful, dynamically-rendered menu offering Search & Download, Library browsing, History tracking, and
|
|
47
|
+
recursive Settings management—all fully navigable via your arrow keys!
|
|
48
|
+
|
|
49
|
+
### Advanced Command-Line Execution
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Interactive download directly from a query
|
|
53
|
+
shinkansen get "naruto"
|
|
54
|
+
|
|
55
|
+
# Search for anime
|
|
56
|
+
shinkansen search "naruto"
|
|
57
|
+
|
|
58
|
+
# List episodes
|
|
59
|
+
shinkansen episodes <session>
|
|
60
|
+
|
|
61
|
+
# Download a single episode
|
|
62
|
+
shinkansen download <session> --episode 1 --quality 720 --name "Naruto"
|
|
63
|
+
|
|
64
|
+
# Download a range of episodes
|
|
65
|
+
shinkansen download <session> --range 1-12 --quality 1080
|
|
66
|
+
|
|
67
|
+
# Download all episodes
|
|
68
|
+
shinkansen download <session> --all
|
|
69
|
+
|
|
70
|
+
# Override parallel workers (default: from config)
|
|
71
|
+
shinkansen download <session> --all --workers 5
|
|
72
|
+
|
|
73
|
+
# Show available sources for an episode
|
|
74
|
+
shinkansen sources <session> 1
|
|
75
|
+
|
|
76
|
+
# View download history
|
|
77
|
+
shinkansen history
|
|
78
|
+
|
|
79
|
+
# Browse downloaded anime library
|
|
80
|
+
shinkansen library
|
|
81
|
+
|
|
82
|
+
# Find anime in library
|
|
83
|
+
shinkansen find "naruto"
|
|
84
|
+
|
|
85
|
+
# Manage configuration
|
|
86
|
+
shinkansen config show
|
|
87
|
+
shinkansen config set quality 720
|
|
88
|
+
shinkansen config set create_folder true
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Features
|
|
92
|
+
|
|
93
|
+
- **HTTP-first approach** -- tries direct API calls before launching a browser, for speed
|
|
94
|
+
- **Cloudflare bypass** -- Playwright fallback when Cloudflare blocks HTTP requests
|
|
95
|
+
- **Persistent cookie caching** -- saves Cloudflare session cookies to disk (`~/.shinkansen/cookies.json`) so subsequent
|
|
96
|
+
runs skip the challenge entirely (25-min TTL)
|
|
97
|
+
- **Parallel batch downloads** -- spawns multiple Playwright browser instances (`prepare_workers`, default 3) to prepare
|
|
98
|
+
episodes in true parallel, with a separate download thread pool (`max_downloads`, default 5); 200 episodes drops from
|
|
99
|
+
~5 hours to ~2 hours
|
|
100
|
+
- **Pipelined downloading** -- each episode's download starts the moment it's resolved, overlapping Playwright prep
|
|
101
|
+
with file I/O
|
|
102
|
+
- **Multiple quality options** -- select 360p, 480p, 720p, 1080p, best, or worst
|
|
103
|
+
- **Sub/Dub preference** -- choose between Japanese audio with subtitles or English dub
|
|
104
|
+
- **Download resume** -- partial downloads are resumed automatically via HTTP Range headers
|
|
105
|
+
- **Episode ranges** -- download specific episodes (`--range 1-12`), comma-separated (`--range 1,3,5-7`), or all (
|
|
106
|
+
`--all`)
|
|
107
|
+
- **Download history** -- tracks every download with anime name, episode, quality, and date
|
|
108
|
+
- **Anime library** -- browse and search your downloaded collection
|
|
109
|
+
- **Config system** -- persistent settings at `~/.shinkansen/config.json` (default quality, output dir, folder creation,
|
|
110
|
+
etc.)
|
|
111
|
+
- **Interactive TUI** -- run `shinkansen` to access a beautiful arrow-key navigable main menu routing your entire
|
|
112
|
+
application
|
|
113
|
+
- **Automatic Retries** -- any episodes that timeout or fail directly prompt you to instantly retry them at the end of
|
|
114
|
+
the batch
|
|
115
|
+
- **Rich terminal UI** -- Claude-style split screen welcome banners, colored output, live progress bars, tables, and
|
|
116
|
+
spinners
|
|
117
|
+
|
|
118
|
+
## Architecture
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
AnimePahe API (JSON)
|
|
122
|
+
|
|
|
123
|
+
v
|
|
124
|
+
AnimePaheClient (client.py)
|
|
125
|
+
- HTTP-first with Playwright fallback
|
|
126
|
+
- Cookie caching for Cloudflare sessions
|
|
127
|
+
- Paginated episode fetching
|
|
128
|
+
|
|
|
129
|
+
v
|
|
130
|
+
Downloader (downloader.py)
|
|
131
|
+
- pahe.win -> kwik.cx -> direct .mp4 URL
|
|
132
|
+
- Split into prepare() + download_prepared() for pipelining
|
|
133
|
+
- Resume support via Range headers
|
|
134
|
+
- Pluggable backends: requests (default) or aria2c
|
|
135
|
+
|
|
|
136
|
+
v
|
|
137
|
+
WorkerPool (worker_pool.py)
|
|
138
|
+
- N PrepareWorkers (own Playwright browser + thread each)
|
|
139
|
+
- Download ThreadPoolExecutor (bounded by max_downloads)
|
|
140
|
+
- Cookie sharing: Worker 0 clears Cloudflare, others load cached cookies
|
|
141
|
+
- Rich Live progress display
|
|
142
|
+
|
|
|
143
|
+
v
|
|
144
|
+
CLI (cli.py)
|
|
145
|
+
- Click commands with Rich output
|
|
146
|
+
- History and library management
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Configuration
|
|
150
|
+
|
|
151
|
+
Settings are stored at `~/.shinkansen/config.json`:
|
|
152
|
+
|
|
153
|
+
| Setting | Default | Description |
|
|
154
|
+
|----------------------|-------------|------------------------------------------------------|
|
|
155
|
+
| `default_quality` | `best` | Preferred video quality |
|
|
156
|
+
| `default_output` | `downloads` | Output directory |
|
|
157
|
+
| `auto_retry` | `true` | Retry failed downloads |
|
|
158
|
+
| `retry_count` | `3` | Number of retry attempts |
|
|
159
|
+
| `create_folder` | `true` | Create per-anime subfolders |
|
|
160
|
+
| `parallel_downloads` | `3` | Number of episodes to prefetch/download concurrently |
|
|
161
|
+
| `download_backend` | `requests` | Download engine: `requests` or `aria2c` |
|
|
162
|
+
| `aria2c_path` | `aria2c` | Path to aria2c binary (if not in `$PATH`) |
|
|
163
|
+
| `aria2c_connections` | `16` | Segments per file for aria2c (`--split`) |
|
|
164
|
+
| `prepare_workers` | `3` | Parallel Playwright browser instances for batch prep |
|
|
165
|
+
| `max_downloads` | `5` | Max concurrent file downloads |
|
|
166
|
+
|
|
167
|
+
## Testing
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Install test dependencies
|
|
171
|
+
pip install -e ".[test]"
|
|
172
|
+
|
|
173
|
+
# Run all tests
|
|
174
|
+
pytest tests/ -v
|
|
175
|
+
|
|
176
|
+
# Run with coverage
|
|
177
|
+
pytest tests/ --cov=anime_pahe_dl --cov-report=term-missing
|
|
178
|
+
|
|
179
|
+
# Run a specific test module
|
|
180
|
+
pytest tests/test_config.py -v
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 🤝 Contributing & New Anime Sources
|
|
184
|
+
|
|
185
|
+
**We want to grow!** Shinkansen currently supports downloading directly from AnimePahe, but our goal is to build a
|
|
186
|
+
massive ecosystem supporting multiple anime sources.
|
|
187
|
+
|
|
188
|
+
We highly encourage the open-source community to get involved:
|
|
189
|
+
|
|
190
|
+
- **Suggest new anime sites** to support by opening an Issue.
|
|
191
|
+
- **Fork the repository** and open Pull Requests implementing new fetchers/extractors.
|
|
192
|
+
- Improve the interactive TUI or squash bugs.
|
|
193
|
+
|
|
194
|
+
Please read our `CONTRIBUTING.md` guidelines to easily get started. Let's build the ultimate anime CLI together!
|
|
195
|
+
|
|
196
|
+
## 💖 Support
|
|
197
|
+
|
|
198
|
+
If you love the blinding speed of Shinkansen and want to say thanks for the hours saved, you can buy me a coffee! It
|
|
199
|
+
goes a long way in keeping the project alive and well-maintained.
|
|
200
|
+
|
|
201
|
+
[](https://ko-fi.com/sanoo)
|
|
202
|
+
|
|
203
|
+
## Requirements
|
|
204
|
+
|
|
205
|
+
- Python >= 3.9
|
|
206
|
+
- [Playwright](https://playwright.dev/python/) (Chromium) -- for Cloudflare bypass and source extraction
|
|
207
|
+
- [Click](https://click.palletsprojects.com/) -- CLI framework
|
|
208
|
+
- [Rich](https://rich.readthedocs.io/) -- terminal UI
|
|
209
|
+
- [requests](https://requests.readthedocs.io/) -- HTTP client
|
|
210
|
+
- [tqdm](https://tqdm.github.io/) -- progress bars
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "shinkansen-cli"
|
|
7
|
+
version = "1.0.2"
|
|
8
|
+
description = "Fast, reliable anime downloader for AnimePahe - built with lessons from autopahe"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "Pasindu Janith" }]
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
keywords = ["anime", "downloader", "animepahe", "cli", "playwright"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: End Users/Desktop",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Internet",
|
|
26
|
+
"Topic :: Multimedia :: Video",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"click>=8.1.0",
|
|
30
|
+
"playwright>=1.45.0",
|
|
31
|
+
"requests>=2.31.0",
|
|
32
|
+
"tqdm>=4.66.0",
|
|
33
|
+
"rich>=13.0.0",
|
|
34
|
+
"InquirerPy>=0.3.4",
|
|
35
|
+
"nest_asyncio>=1.5.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
shinkansen = "anime_pahe_dl.cli:cli"
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
test = [
|
|
43
|
+
"pytest>=7.4.0",
|
|
44
|
+
"pytest-mock>=3.12.0",
|
|
45
|
+
"pytest-cov>=4.1.0",
|
|
46
|
+
"responses>=0.24.0",
|
|
47
|
+
]
|
|
48
|
+
dev = [
|
|
49
|
+
"ruff>=0.4.0",
|
|
50
|
+
"mypy>=1.10.0",
|
|
51
|
+
"pre-commit>=3.7.0",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[project.urls]
|
|
55
|
+
Homepage = "https://github.com/pasindujanith/anime-pahe-dl"
|
|
56
|
+
Repository = "https://github.com/pasindujanith/anime-pahe-dl.git"
|
|
57
|
+
"Bug Tracker" = "https://github.com/pasindujanith/anime-pahe-dl/issues"
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
markers = [
|
|
62
|
+
"integration: tests requiring real network or Playwright",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[tool.setuptools.packages.find]
|
|
66
|
+
where = ["src"]
|