Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Novel Scraper, Translator & EPUB Generator

This project scrapes online novel chapters, translates them into English using Google Gemini AI, and generates an EPUB eBook.


Features

  • Scrapes novel chapters from URLs listed in input.txt.
  • Translates content and titles while preserving HTML formatting.
  • Caches translations to avoid redundant API calls.
  • Generates a fully formatted EPUB eBook with optional cover image.

Prerequisites

  • Node.js v18+
  • NPM or Yarn
  • Google Gemini AI API key

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd <repo-folder>
  1. Install dependencies:
npm install
  1. Create a .env file with your Gemini API key:
GEMINI_API_KEY=your_api_key_here
  1. Prepare input.txt with a list of URLs to scrape, one per line.

  2. (Optional) Add extra instructions in extra.txt to customize translation behavior.


Usage

Run the project with:

npm start

The workflow:

  1. Scrapes chapters from URLs listed in input.txt.
  2. Translates chapters and titles to English.
  3. Generates an EPUB file in the output directory.

Project Structure

.
├── input.txt        # List of URLs to scrape
├── extra.txt        # Optional extra translation instructions
├── cache.json       # Translation cache
├── cover.jpg        # Optional EPUB cover image
├── src/
│   ├── scraper.ts
│   ├── translator.ts
│   ├── generator.ts
│   └── types/
│       └── chapter.type.ts
├── output/          # Generated EPUB files
└── .env

Configuration

You can customize the EPUB details in constants.ts:

export const EPUB_DETAILS = {
	TITLE: "My Translated Novel",
	AUTHOR: "Author Name",
	OUTPUT_FILE_NAME: "Test",
};

Notes

  • Ensure each URL in input.txt points to a valid chapter page with an <article> containing headings and sections.
  • Translations preserve all paragraph tags (<p>) and HTML structure.
  • Cache is stored in cache.json to speed up repeated runs.

About

Scrape online novels, translate chapters to English using Google Gemini AI, and generate EPUB eBooks.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages