A powerful bash script to download books from the O'Reilly Learning Platform in PDF and/or EPUB format.
- Download books in PDF and/or EPUB format
- Support for both username/password and SSO login methods
- Batch downloading capability for multiple books
- EPUB to PDF conversion using:
- Local Calibre installation on macOS (if available)
- Docker-based conversion as fallback
- Progress indicators and detailed output
- Docker: Required for downloading books from O'Reilly
- Bash shell: To run the script
- O'Reilly subscription: Either personal account or organizational SSO access
- Calibre (optional): For local PDF conversion on macOS
-
Clone or download this repository
-
Make the script executable:
chmod +x oreilly-downloader.sh
-
Set up authentication (see below)
-
Create
data
directory:mkdir -p data
-
Create a configuration file with your O'Reilly credentials:
cp user.conf.sample data/user.conf
-
Edit
data/user.conf
with your actual username and password:your_oreilly_username@example.com your_password_here
-
Log in to O'Reilly using your organization's SSO
-
Navigate to https://learning.oreilly.com/profile/ (or any authenticated page, really)
-
Extract cookies from your browser:
- Open Developer Tools (F12)
- Run this code snippet from Console to copy your cookies as JSON:
copy(JSON.stringify(document.cookie.split(';').map(c => c.split('=')).map(i => [i[0].trim(), i[1].trim()]).reduce((r, i) => {r[i[0]] = i[1]; return r;}, {})))
-
Save the cookies JSON to a file (e.g.,
cookies.json
)
./oreilly-downloader.sh -b <book_id> -t <output_title> -f <format> [-m <login_method>] [-c <cookie_file>]
Options:
-b <book_id>
: Book ID or URL (required for single book download)-t <output_title>
: Output filename without extension (required for single book download)-f <format>
: Format to download:pdf
,epub
, orboth
(required)-m <login_method>
: Authentication method:user
(default) orsso
-c <cookie_file>
: JSON file with cookies (required for SSO login)-h
: Display help message
./oreilly-downloader.sh -l <batch_file> -f <format> [-m <login_method>] [-c <cookie_file>]
Options:
-l <batch_file>
: Path to file containing list of books to download- Other options same as Basic Usage
Create a text file with one book per line in the format:
<book_id>,<output_title>
Example (books.txt
):
9780321635754,Art of Computer Programming
9781492092506,Data Pipelines Pocket Reference
# Lines starting with # are comments
9781492087144,Building ML Pipelines
# Download a book in PDF format
./oreilly-downloader.sh -b 9780321635754 -t "Art_of_Computer_Programming" -f pdf
# Download a book in both PDF and EPUB formats
./oreilly-downloader.sh -b 9780321635754 -t "Art_of_Computer_Programming" -f both
# Download a book in PDF format with SSO
./oreilly-downloader.sh -b 9780321635754 -t "Art_of_Computer_Programming" -f pdf -m sso -c cookies.json
# Download multiple books with SSO
./oreilly-downloader.sh -l books.txt -f pdf -m sso -c cookies.json
- Browse to the book on O'Reilly Learning Platform
- The book ID is in the URL:
https://learning.oreilly.com/library/view/book-title/<BOOK_ID>/
- For example:
https://learning.oreilly.com/library/view/art-of-computer/9780321635754/
→ Book ID is9780321635754
- For PDF conversion, the script uses:
- Local Calibre on macOS if available (
/Applications/calibre.app/Contents/MacOS/ebook-convert
) - Docker-based conversion using
rappdw/ebook-convert
as fallback (untested)
- Local Calibre on macOS if available (
- Temporary files are stored in the
download/tmp
directory - Final downloaded files are saved to:
- PDFs:
download/pdf/
- EPUBs:
download/epub/
- PDFs:
- kirinnee/oreilly-downloader for the Docker image used for downloading
- Calibre Project for the ebook conversion tools
- rappdw/ebook-convert for the Docker image used for conversion