Download books from O'Reilly Learning (learning.oreilly.com) as clean EPUB 3 files for offline reading.
oreilly-dl fetches the book metadata, table of contents, chapters, images, fonts, and stylesheets using your browser session cookies. It strips the web reader markup, restores the publisher's CSS and @font-face rules, rewrites internal links, and packages everything into a standard EPUB 3 archive.
cargo install --path .
# Or build the binary directly
cargo build --releaseoreilly-dl needs session cookies from an O'Reilly account with an active subscription.
-
Log in to learning.oreilly.com in your browser.
-
Open the developer console and run:
JSON.stringify( Object.fromEntries(document.cookie.split("; ").map((c) => c.split(/=(.*)/s))), );
-
Save the output as
cookies.json.
oreilly-dl looks for the cookie file in this order:
-c/--cookies <FILE>$OREILLY_COOKIES<config dir>/oreilly-dl/cookies.json(~/Library/Application Support/oreilly-dl/on macOS,~/.config/oreilly-dl/on Linux)
When the cookies expire and O'Reilly answers 401, oreilly-dl stops and asks you to export fresh cookies.
Pass one or more book ISBNs or O'Reilly URLs:
# Download by ISBN (saves to ./downloads/<Title>.epub)
oreilly-dl 9781098119058
# Download by URL
oreilly-dl https://learning.oreilly.com/library/view/designing-data-intensive-applications/9781098119058/
# Download multiple books to a specific directory with a custom cookie file
oreilly-dl 9781098119058 9781098176228 -c cookies.json -o ~/Books/
# Save a single book to a specific file path
oreilly-dl 9781098119058 -o Designing_Data-Intensive_Applications.epubAudiobooks and videos are not supported.
If some chapters fail to download (for example, when O'Reilly rate-limits the session), the EPUB is still written but marked incomplete, and the command exits with a non-zero status.
-c, --cookies <FILE> sets the cookie file path (or set OREILLY_COOKIES). Defaults to <config dir>/oreilly-dl/cookies.json.
-o, --output <PATH> sets the output file or directory. Defaults to ./downloads/<Title>.epub. When downloading multiple books, PATH must be a directory.
--asset-delay <RANGE> sets the random wait before each image, font, or stylesheet download. Defaults to 100ms-300ms.
--chapter-delay <RANGE> sets the random wait before each chapter download. The first three chapters wait twice as long. Defaults to 500ms-1500ms.
--book-delay <RANGE> sets the random rest between books when downloading several. Defaults to 0s (no rest).
A RANGE is either MIN-MAX or one fixed time, with units such as ms, s, and m: 200ms-1s, 1m-3m, 30s. Very short delays make it more likely that O'Reilly rate-limits your session.
Set SOURCE_DATE_EPOCH to a Unix timestamp (in seconds) to pin the EPUB's dcterms:modified metadata for reproducible builds.
Partially ported from s110/oreilly-epub-downloader and tctibbs/oreilly-epub-downloader.
MIT