Skip to content

About

Download books from O'Reilly Learning (learning.oreilly.com) as clean EPUB 3 files for offline reading.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oreilly-dl

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.

Installation

cargo install --path .

# Or build the binary directly
cargo build --release

Authentication

oreilly-dl needs session cookies from an O'Reilly account with an active subscription.

  1. Log in to learning.oreilly.com in your browser.

  2. Open the developer console and run:

    JSON.stringify(
      Object.fromEntries(document.cookie.split("; ").map((c) => c.split(/=(.*)/s))),
    );
  3. Save the output as cookies.json.

oreilly-dl looks for the cookie file in this order:

  1. -c/--cookies <FILE>
  2. $OREILLY_COOKIES
  3. <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.

Usage

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.epub

Audiobooks 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.

Options

-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.

Credits

Partially ported from s110/oreilly-epub-downloader and tctibbs/oreilly-epub-downloader.

License

MIT

About

Download books from O'Reilly Learning (learning.oreilly.com) as clean EPUB 3 files for offline reading.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages