Skip to content

Add ao3 plugin for building EPUBs from AO3 fanfiction - #4

Merged
danielh-official merged 3 commits into
mainfrom
claude/project-thread-lln2lc
Oct 9, 2026
Merged

danielh-official merged 3 commits into
mainfrom
claude/project-thread-lln2lc

Conversation

@danielh-official

Copy link
Copy Markdown
Owner

Adds a new ao3 plugin that enables users to create EPUB ebooks from Archive of Our Own (AO3) stories for reading in Apple Books.

Summary

This plugin provides two workflows for converting AO3 fanfiction into EPUBs:

  • Fetch mode: Downloads a work from an AO3 URL, parses it, and lets users select chapters
  • Paste mode: Accepts chapter text pasted directly, useful when network access is unavailable

Key Changes

  • ao3.py: Main script that fetches works from AO3 URLs, parses HTML to extract chapters and metadata, and supports chapter selection via intuitive syntax (e.g., "1-3, 7", "latest 2")
  • epub.py: Builds valid EPUB 3 files from chapter data, with proper metadata, styling, and table of contents
  • html_clean.py: Lightweight HTML parser and sanitizer that converts user-generated content to safe XHTML suitable for ebooks, preserving formatting (italics, bold, links) while removing scripts and dangerous elements
  • paste.py: Converts pasted plain text into structured chapter data, with support for chapter heading detection and scene break markers
  • selfcheck.py: Comprehensive test suite validating parsing, chapter selection, and EPUB generation
  • SKILL.md: Documentation covering usage, rules for respectful AO3 access, and setup instructions
  • plugin.json: Plugin metadata for agent marketplaces

Implementation Details

  • Respects AO3's terms of service: one request per work, 5+ second throttling between requests, honest User-Agent, automatic caching, and single retry on rate limits
  • Handles edge cases: one-shots, locked works, multi-chapter works with notes, anonymous authors
  • Chapter selection supports flexible syntax: ranges ("1-3"), ordinal selections ("latest 2", "first 5"), and mixed ("1, 3-5, 7")
  • Partial chapter selections automatically label the book (e.g., "The Lake House (ch 1-3, 7)") to avoid collisions in Books
  • EPUB output includes proper language codes, metadata preservation, and CSS styling for readability

https://claude.ai/code/session_01Qp5oiTGA7KoCTXW1yfxAa1

claude added 3 commits October 9, 2026 20:51
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qp5oiTGA7KoCTXW1yfxAa1
Builds one EPUB per AO3 story from chosen chapters, either fetched from a
work URL (one polite request per work, cached) or pasted in as text.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qp5oiTGA7KoCTXW1yfxAa1
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qp5oiTGA7KoCTXW1yfxAa1
@danielh-official
danielh-official merged commit 2e442df into main Oct 9, 2026
2 checks passed
@danielh-official
danielh-official deleted the claude/project-thread-lln2lc branch October 9, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants