Batoto Parser
Lightweight parser for Batoto-style manga sites. Provides both a command-line interface and a Python library for:
- 📚 Listing/browsing manga
- 🔍 Searching manga
- 📖 Fetching manga details (metadata + chapters)
- 🖼️ Retrieving chapter pages (with encrypted image URL decryption)
Features
- CLI Tool: Easy-to-use command-line interface with rich output
- Python Library: Import and use in your own projects
- Flexible: Works with any Batoto-style manga site
- Fast: Efficient parsing with minimal dependencies
- Typed: Full type hints for better IDE support
Requirements
- Python 3.8+
- Node.js (required for chapter page decryption)
Installing Node.js (Linux)
Debian/Ubuntu:
sudo apt update && sudo apt install -y nodejs
Fedora/RHEL:
sudo dnf install nodejs
Arch Linux:
sudo pacman -S nodejs
Installation
From PyPI (recommended)
pip install batoto-parser
From source
git clone https://github.com/yourusername/batoto-parser.git
cd batoto-parser
pip install -e .
Development installation
pip install -e ".[dev]"
CLI Usage
After installation, the batoto-parser command will be available:
List/Browse Manga
# Browse first page
batoto-parser list
# Browse specific page
batoto-parser list --page 2
# Search for manga
batoto-parser list --query "one piece"
# Save results to file
batoto-parser list --page 1 --output results.json
# Use different domain
batoto-parser list --domain custom-site.com
Get Manga Details
# By path
batoto-parser details /series/Some-Manga
# By full URL
batoto-parser details https://bato.to/series/Some-Manga
# Save to file
batoto-parser details /series/Some-Manga --output manga.json
Get Chapter Pages
# Get image URLs for a chapter
batoto-parser pages /reader/12345
# Save to file
batoto-parser pages /reader/12345 --output chapter.json
Options
All commands support:
--domain, -d: Specify domain (default: bato.to)--output, -O: Save output to file instead of stdout--pretty/--compact: Pretty-print or compact JSON output--help: Show detailed help
Library Usage
Use batoto-parser as a library in your Python projects:
from batoto_parser import BatoToParser, MangaLoaderContext
# Initialize
ctx = MangaLoaderContext()
parser = BatoToParser(ctx, domain="bato.to")
# List manga
mangas = parser.get_list(page=1)
for manga in mangas:
print(f"{manga.title}: {manga.public_url}")
# Search
results = parser.get_list(page=1, query="one piece")
# Get details
detailed_manga = parser.get_details(mangas[0])
print(f"Chapters: {detailed_manga.chapterCount}")
# Get chapter pages (requires Node.js)
pages = parser.get_pages("/reader/12345")
for page in pages:
print(f"Page {page.pageNumber}: {page.imageUrl}")
See examples/example_usage.py for more examples.
Project Structure
batoto-parser/
├── src/
│ └── batoto_parser/
│ ├── __init__.py # Package exports
│ ├── __version__.py # Version info
│ ├── cli.py # CLI interface (Typer)
│ ├── parser.py # Main parser logic
│ ├── context.py # HTTP session & JS eval
│ ├── utils.py # Crypto & utility functions
│ └── models.py # Data models
├── tests/ # Test suite
├── examples/ # Usage examples
└── pyproject.toml # Package configuration
API Reference
Core Classes
-
BatoToParser: Main parser classget_list(page, order, query): List/search mangaget_details(manga): Get detailed manga infoget_pages(chapter_url): Get chapter image URLs
-
MangaLoaderContext: HTTP session manager with JS evaluation -
Manga: Manga data model -
MangaChapter: Chapter data model -
MangaPage: Page data model
Utility Functions
generate_uid(url): Generate unique ID from URLdecrypt_batoto(encrypted, password): Decrypt Batoto image URLsevp_bytes_to_key(...): OpenSSL key derivation
Development
Setup
# Clone repository
git clone https://github.com/mehrinshamim/batoto-parser.git
cd batoto-parser
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install with dev dependencies
pip install -e ".[dev]"
Testing
# Run tests
pytest
# With coverage
pytest --cov=batoto_parser --cov-report=html
# Run only unit tests (skip integration tests)
pytest -m "not integration"
Code Quality
# Format code
black src/ tests/
# Lint
ruff check src/ tests/
# Type check
mypy src/
Troubleshooting
"Cannot evaluate batoPass" error
Ensure Node.js is installed and available on your PATH:
node --version # Should show version number
Empty results
If parsing returns empty results, the site layout may have changed. Check:
- Site is accessible
- Selectors in
parser.pymatch current HTML structure
Network errors
Add timeouts or retries in context.py for unstable connections.
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This tool is for educational purposes only. Please respect the websites' terms of service and robots.txt. The authors are not responsible for misuse of this tool.
Changelog
0.1.0 (2024-XX-XX)
- Initial release
- CLI tool with list, details, and pages commands
- Library API for programmatic access
- Support for custom domains
- Rich terminal output
- Full test suite
Acknowledgments
- Built with Typer for CLI
- Rich for beautiful terminal output
- BeautifulSoup for HTML parsing
Metadata
Release files for batoto-parser 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| batoto_parser-0.1.0.tar.gz | 27.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| batoto_parser-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 53.4 kB
Release files / batoto_parser-0.1.0.tar.gz
| Download URL | batoto_parser-0.1.0.tar.gz |
|---|---|
| Size | 27.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
467dbd60a77705680bc497090f8f6ec779af4c1051848277da813ca9c16909c5
|
|
BLAKE2b-256 checksum How to use checksums |
f55d27589867f63a0c72dac44c56fe1f129d5756a588ad9025c64c9dd833c683
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / batoto_parser-0.1.0-py3-none-any.whl
| Download URL | batoto_parser-0.1.0-py3-none-any.whl |
|---|---|
| Size | 25.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e27dbc9f042b0d2bfc01264fb0ae0d423f308865afc00b3494b573eb2e55236
|
|
BLAKE2b-256 checksum How to use checksums |
ee12ec9a8dd6f96e57d160867a48aa63984a6752bccc2fc347dbcc59eca8baaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|