A Deno utility that converts Apple Books EPUB files to standard EPUB format by removing Apple-specific elements and creating a standard-compliant EPUB structure.
- Converts iTunesArtwork to standard EPUB cover image
- Creates responsive SVG-based cover page
- Updates content.opf with required metadata
- Preserves existing styles while adding cover-specific CSS
- Sanitizes special characters in filenames
- Provides verbose mode for debugging
- Handles cleanup of temporary files
- Deno 1.x or higher
zipcommand-line utility
git clone https://github.com/timurmaio/epub-deapplefier.git
cd epub-deapplefier# Using deno task
deno task start "path/to/book.epub"
# Or run directly
deno run --allow-read --allow-write --allow-run src/main.ts "path/to/book.epub"The utility will:
- Create a temporary working directory
- Copy all files from the source EPUB
- Convert iTunesArtwork to cover.jpg
- Create cover.xhtml with SVG wrapper
- Update content.opf with necessary metadata
- Generate a new EPUB file named
<author>-<title>.epub - Clean up temporary files
epub-deapplefier/
├── src/
│ ├── main.ts # Entry point
│ ├── processor/
│ │ ├── epub-processor.ts # Core processing logic
│ │ └── types.ts # TypeScript interfaces
│ ├── constants/
│ │ ├── paths.ts # File paths and patterns
│ │ └── templates.ts # HTML/CSS templates
│ └── utils/
│ └── fs.ts # File system utilities
└── tests/
├── processor/
│ └── epub-processor.test.ts
└── utils/
└── fs.test.ts
# Run the utility
deno task start <path>
# Run tests
deno task test
# Format code
deno task fmt
# Lint code
deno task lint-
Cover Processing
- Locates and processes iTunesArtwork
- Creates cover HTML and CSS files
- Updates content.opf with cover information
- Handles SVG viewbox for cover display
-
Content Processing
- Validates XML structure
- Cleans up metadata formatting
- Manages content.opf updates
-
Metadata Processing
- Extracts title and author from content.opf
- Sanitizes strings for filenames
- Handles file path generation
-
Cleanup Processing
- Removes Apple-specific metadata
- Cleans up temporary files
- Handles iTunesArtwork removal
-
EPUB Building
- Creates proper EPUB structure
- Handles mimetype file requirements
- Manages ZIP compression levels
- Validates final EPUB file
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run tests (
deno task test) - Format code (
deno task fmt) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the 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.
Timur Makarov