Skip to main content

Web novel scraper and library manager with Rich UI

Project description

novel-cli

A CLI tool for scraping and managing web novels offline, with an optional web viewer.

Features

  • Smart Scraping: Automatically skips completed novels with all chapters already downloaded, saving time and bandwidth
  • Offline Reading: Download and store complete novels locally
  • Web Viewer: Optional web-based reader for your library
  • Multiple Sources: Support for various novel hosting sites ( Only tested on one site - RR)
  • Library Management: Add, remove, export, and organize your collection
  • Progress Tracking: Monitor download progress and completion status

Installation

From Source

git clone https://github.com/Azizgic/novel-cli.git
cd novel-cli
pip install -e .

From PyPI

pip install novel-cli

Quick Start

# Add a novel to your reading list
novel add https://www.royalroad.com/fiction/12345/some-novel

# Scrape all novels (smart mode - skips completed ones)
novel scrape

# Scrape a single novel
novel scrape "Novel Title"

# Update stats only (no chapter download)
novel update-stats

# List your library
novel list

# Show novel details
novel show "Novel Title"

# Remove a novel
novel remove "Novel Title"

# Export library
novel export json
novel export csv

# Show statistics
novel stats

# Clean up orphaned data
novel clean

Command Reference

Command Description
novel add <url> Add a novel URL to your reading list
novel scrape [title] Download chapters (skips completed novels by default)
novel scrape --dry-run Preview what would be scraped without downloading
novel update-stats [title] Update metadata without downloading chapters
novel list Display all novels in your library
novel show [title] Show detailed information about a novel
novel remove [title] Remove a novel from your library
novel export <json|csv> Export your library to JSON or CSV
novel stats Display library statistics
novel clean Remove orphaned data and thumbnails
novel read Start the web viewer

Web Viewer (Optional)

cd viewer && pnpm install
novel read
# Opens at http://localhost:4173

Data Storage

All your data is stored locally in ~/.novel-library/:

  • library.db - SQLite database with chapters and metadata
  • urls.txt - Your reading list
  • thumbnails/ - Cover images
  • library.json - Configuration file

Smart Scraping

The tool intelligently avoids rescraping novels that are already complete. A novel is skipped if:

  • Its status is marked as "Completed"
  • AND all chapters have already been downloaded

This saves time and bandwidth during regular scraping sessions. Other statuses (Ongoing, Hiatus, Dropped, etc.) are always scraped to catch updates.

Testing

The project includes comprehensive automated tests to ensure reliability.

Running Tests

# Install test dependencies
pip install pytest pytest-cov

# Run all tests
pytest tests/

# Run with verbose output
pytest tests/ -v

# Generate coverage report
pytest tests/ --cov=novel --cov-report=html

See tests/README.md for detailed testing documentation.

Recent Changes

Smart Skip Feature (v0.1.0)

  • Added ScrapeChecker module to prevent rescraping completed novels
  • Reduces unnecessary downloads and improves performance
  • Fully automated testing with 30+ test cases
  • See docs/ENHANCEMENT_SKIP_COMPLETED.md for details

Development

Project Structure

novel-cli/
├── novel/
│   ├── cli.py              # Command-line interface
│   ├── manage.py           # Library management
│   ├── paths.py            # Data storage paths
│   └── scraper/
│       ├── novel_scraper_indexer.py   # Main scraper
│       ├── scrape_checker.py          # Skip logic
│       ├── writers.py      # Database writer
│       └── base_scraper.py # Base scraper class
├── tests/
│   └── test_scrape_checker.py  # Test suite
├── examples/
│   └── integration_example.py   # Integration examples
└── viewer/                      # Web viewer (Svelte)

Contributing

Contributions are welcome! Please ensure:

  1. All tests pass: pytest tests/
  2. Code follows the existing style
  3. New features include test coverage

Dependencies

  • requests - HTTP requests
  • beautifulsoup4 - HTML parsing
  • cloudscraper - Handle CloudFlare protection
  • selenium - Browser automation (if needed)
  • markdownify - Convert HTML to Markdown
  • lxml - XML/HTML processing

For development:

  • pytest - Testing framework
  • pytest-cov - Coverage reports

AI Use

Ai has been used to create a portion of this code. Specifically to write the tests, and other minor improvements. AI has also been used to improve readability and add helpful code comments.

License

MIT License - see LICENSE file for details

Support

Found a bug or have a suggestion? Open an issue on GitHub: https://github.com/Azizgic/novel-cli/issues


Made with ❤️ for novel readers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

novel_cli-2.0.0.tar.gz (49.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

novel_cli-2.0.0-py3-none-any.whl (56.2 kB view details)

Uploaded Python 3

File details

Details for the file novel_cli-2.0.0.tar.gz.

File metadata

  • Download URL: novel_cli-2.0.0.tar.gz
  • Upload date:
  • Size: 49.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for novel_cli-2.0.0.tar.gz
Algorithm Hash digest
SHA256 aeaf7e98e8e771787750ae52b8a7587aaa4147a23b5e6c2c5756456b62e6a69d
MD5 468104cd780b8e149a95701b523a03ac
BLAKE2b-256 d36c058219bf693c24c5f7b1257981d818587247b7f0dbd3d526a65b42aee539

See more details on using hashes here.

File details

Details for the file novel_cli-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: novel_cli-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 56.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for novel_cli-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e19efdaee9d2707f007a5462cb767d3ce44fc30fcef6bdcb31caba446d32a57
MD5 44e9ee6bedccdd9e45c60cab0a0c321e
BLAKE2b-256 4db898df2f16d10c5c15d0877df61c8606efa8a790b2a76c10a11b4a9e75e400

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page