Skip to content

Repository files navigation

acsm2md

Convert Adobe ACSM ebook files into clean Markdown. One command.

python3 acsm2md.py book.acsm

You get a folder of Markdown files — one per chapter, plus a combined full_book.md. Feed them to an LLM, drop them into Obsidian, read them in any editor, grep them, whatever you want.

Why this exists

When you borrow or buy an ebook from a library or retailer, you usually get a .acsm file — a tiny XML stub that Adobe Digital Editions uses to download the real book. ADE is bloated, Windows/Mac-only, and locks you into Adobe's ecosystem. On Linux it barely works under Wine.

This project chains together three steps that previously required separate tools:

.acsm file → Adobe fulfillment → DRM'd EPUB → DRM removal → clean Markdown

It uses the acsm-calibre-plugin by Leseratte10 (included, GPLv3) for the ACSM fulfillment, then decrypts the EPUB and extracts it to structured Markdown.

Setup

Install dependencies:

pip install lxml pycryptodome beautifulsoup4 oscrypto

Activate an ADE account (one-time):

cd calibre-plugin
python3 register_ADE_account.py

This creates activation.xml, device.xml, and devicesalt in the current directory. You can use your real AdobeID or create an anonymous authorization. Back up these files — if you lose them and used anonymous auth, your books are gone.

Usage

Basic — get Markdown from an ACSM file:

python3 acsm2md.py ~/Downloads/MyBook.acsm

Output goes to ./MyBook/ with per-chapter files and full_book.md.

Specify output directory:

python3 acsm2md.py book.acsm -o ~/notes/books/MyBook/

Keep the intermediate EPUB files:

python3 acsm2md.py book.acsm --keep-epub

ASCII-safe output (curly quotes → straight quotes, em-dashes → --, etc.):

python3 acsm2md.py book.acsm --ascii

What you get

MyBook/
├── 01_chapter1.md
├── 02_chapter2.md
├── 03_chapter3.md
├── ...
└── full_book.md          # all chapters concatenated

Each chapter file has proper headings, paragraphs, blockquotes, and lists extracted from the EPUB HTML. No leftover <div> tags or inline styles.

Using the Calibre plugin instead

If you just want ACSM → EPUB inside Calibre (without the Markdown step), the included calibre-plugin/ directory works as a standalone Calibre plugin:

  1. Run ./bundle_calibre_plugin.sh to build the ZIP
  2. In Calibre: Preferences → Plugins → Load plugin from file
  3. Authorize via plugin settings
  4. Drag .acsm files into Calibre

See the plugin's original documentation for details on authorization methods, returning library books, and eReader support.

Standalone scripts

The calibre-plugin/ folder also has scripts you can run without Calibre:

  • register_ADE_account.py — authorize with an AdobeID (or anonymous)
  • fulfill.py — download a book from an ACSM file (produces EPUB/PDF)
  • get_key_from_Adobe.py — get your DRM decryption key as a .der file

Project structure

acsm2md.py              ← the main pipeline script
calibre-plugin/          ← Leseratte10's ACSM plugin (fulfillment + DRM handling)
migration_plugin/        ← migration helper for older DeACSM versions
tests/                   ← test suite
bundle_calibre_plugin.sh ← build script for Calibre plugin ZIP
requirements.txt         ← Python dependencies

Requirements

  • Python 3.8+
  • lxml, pycryptodome, beautifulsoup4, oscrypto
  • An activated ADE account (via register_ADE_account.py)

How it works

  1. Fulfillment — sends the ACSM file to Adobe's server, which returns a DRM-protected EPUB (or PDF). This uses the same protocol as Adobe Digital Editions.
  2. Decryption — extracts the book encryption key from your activation data, decrypts each resource in the EPUB using AES-CBC, and writes a clean EPUB without DRM metadata.
  3. Markdown extraction — parses the EPUB's OPF spine, reads each XHTML chapter through BeautifulSoup, and converts headings/paragraphs/lists/blockquotes to Markdown.

Known limitations

  • PDF books: the pipeline handles EPUB only. If Adobe delivers a PDF, the fulfillment step will download it but the Markdown extraction won't run. You'll get the PDF in --keep-epub mode.
  • Complex layouts (tables, math, code blocks) get simplified to plain text. This works well for prose-heavy books but not for technical references.
  • Image extraction is not implemented yet — the Markdown references image paths but doesn't extract them from the EPUB.

Credits

The ACSM fulfillment and account management code is from acsm-calibre-plugin by Leseratte10 (Copyright 2021–2025), which is a Python reimplementation of libgourou by Grégory Soutadé.

License

GPLv3. See LICENSE.

About

Convert Adobe ACSM ebook files to clean Markdown — one command. ACSM → EPUB → decrypt → Markdown.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages