This project scrapes online novel chapters, translates them into English using Google Gemini AI, and generates an EPUB eBook.
- 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.
- Node.js v18+
- NPM or Yarn
- Google Gemini AI API key
- Clone the repository:
git clone <your-repo-url>
cd <repo-folder>
- Install dependencies:
npm install- Create a
.envfile with your Gemini API key:
GEMINI_API_KEY=your_api_key_here-
Prepare
input.txtwith a list of URLs to scrape, one per line. -
(Optional) Add extra instructions in
extra.txtto customize translation behavior.
Run the project with:
npm startThe workflow:
- Scrapes chapters from URLs listed in
input.txt. - Translates chapters and titles to English.
- Generates an EPUB file in the
outputdirectory.
.
├── 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
You can customize the EPUB details in constants.ts:
export const EPUB_DETAILS = {
TITLE: "My Translated Novel",
AUTHOR: "Author Name",
OUTPUT_FILE_NAME: "Test",
};- Ensure each URL in
input.txtpoints 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.jsonto speed up repeated runs.