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)
- 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
- Python 3.8+
- Node.js (required for chapter page decryption)
Debian/Ubuntu:
sudo apt update && sudo apt install -y nodejsFedora/RHEL:
sudo dnf install nodejsArch Linux:
sudo pacman -S nodejspip install batoto-parsergit clone https://github.com/yourusername/batoto-parser.git
cd batoto-parser
pip install -e .pip install -e ".[dev]"After installation, the batoto-parser command will be available:
# 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# 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 image URLs for a chapter
batoto-parser pages /reader/12345
# Save to file
batoto-parser pages /reader/12345 --output chapter.jsonAll 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
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.
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
-
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
generate_uid(url): Generate unique ID from URLdecrypt_batoto(encrypted, password): Decrypt Batoto image URLsevp_bytes_to_key(...): OpenSSL key derivation
# 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]"# Run tests
pytest
# With coverage
pytest --cov=batoto_parser --cov-report=html
# Run only unit tests (skip integration tests)
pytest -m "not integration"# Format code
black src/ tests/
# Lint
ruff check src/ tests/
# Type check
mypy src/Ensure Node.js is installed and available on your PATH:
node --version # Should show version numberIf parsing returns empty results, the site layout may have changed. Check:
- Site is accessible
- Selectors in
parser.pymatch current HTML structure
Add timeouts or retries in context.py for unstable connections.
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
This project is licensed under the MIT License - see the LICENSE file for details.
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.
- 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
- Built with Typer for CLI
- Rich for beautiful terminal output
- BeautifulSoup for HTML parsing