Skip to content
qqiweiPublic

About

Index a local PDF/EPUB library, fetch Douban ratings by ISBN, and mirror it to a reMarkable tablet

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

books

books indexes a local PDF/EPUB library, fetches Douban ratings by ISBN, and mirrors the library to a reMarkable tablet. It is a single command: one run goes from directory selection to tablet upload and prints only a summary.

books                 # run the flow
books --db-path       # print the resolved SQLite path

One run

  1. Choose directories. fzf lists every directory containing PDF/EPUB files. The directories currently included are pre-marked; Tab toggles, Enter confirms and continues. Directories left unselected are written to books_local_ex and are not scanned.
  2. Scan the library. New files are inserted into books_local; ISBNs are extracted for new files only. Existing rows are not re-extracted unless the file is new.
  3. Fetch Douban incrementally. Only ISBNs without a successful rating are queried. not_found/blocked results are remembered per file and skipped on later runs; a block stops the batch.
  4. Mirror to the tablet. The tablet is compared through rmpp-web. Files with onrmpp = 0 are uploaded into the same relative directory; missing tablet folders are created through rmpp-sh.
  5. Print the summary.

Example:

directories: 11 kept, 4 excluded

library: 61 file(s) — 48 ISBN, 13 no ISBN
douban: 45 rated, 3 unresolved
tablet: 61/61 present, 2 extra

If the tablet is offline the last line says so; local scanning and Douban fetching still run.

Requirements

  • Python 3.11+ (standard library only)
  • rmpp-web on PATH (or settings.rmpp_web / $RMPP_WEB)
  • rmpp-sh on PATH (or settings.rmpp_sh / $RMPP_SH) — only for creating tablet folders
  • pdftotext from Poppler for PDF ISBN extraction
  • fzf for the directory picker
# in a checkout of rmpp-toolkit
cargo install --path crates/rmpp-web
cargo install --path crates/rmpp-sh

The command is this repository's books executable; it is on PATH through ~/.my.zshrc:

export PATH="$HOME/src/books:$PATH"

Configuration

The only options are --db-path (print the database path), --help and --version.

  • Library root: on the first run, if it is not configured, books prompts for it and stores it in settings.library_root. $BOOKS_ROOT overrides the stored value.
  • Database: $BOOKS_DB, db_path in rmpp_books.toml, or the platform default (~/Library/Application Support/rmpp_books/books.db on macOS). books --db-path prints the resolved path without running anything.
  • Tablet / tools: settings.device_host, settings.rmpp_web, settings.rmpp_sh, settings.douban_delay.

Settings live in the settings table. To change one without a CLI:

sqlite3 "$HOME/Library/Application Support/rmpp_books/books.db" \
  "UPDATE settings SET value='/path/to/library' WHERE key='library_root'"

Tables

Table Meaning
settings static configuration
books_local_ex directory prefixes excluded from the library
books_local files, primary key (filepath, filename, filesuffix); onrmpp is the mirror flag
books_douban successful ratings, primary key isbn
books_isbn_miss per-file ISBN/Douban state, same path key as books_local; no ISBN column

books_isbn_miss.status:

status Meaning
no_isbn file was scanned, but no ISBN was found
pending ISBN exists, not fetched yet
not_found Douban has no entry for that ISBN
blocked Douban blocked/rate-limited
http_* / error request failure

A successful fetch deletes the miss row and adds one books_douban row.

Views: v_books (join local + rating + miss status), v_books_missing (onrmpp = 0), v_summary.

Notes

  • ISBN extraction: EPUB OPF dc:identifier then the first pages; PDF first 15 pages through pdftotext; ISBN-10 converted to ISBN-13 and checksum validated. In the current library 48/61 files have an ISBN; the 13 without one are recorded as no_isbn and are not sent to Douban.
  • Douban has no official API. Requests use a browser User-Agent and douban_delay (default 2s). HTML changes or blocking are recorded rather than retried endlessly.
  • The tablet is a mirror: paths are identical, so onrmpp is enough. A misplaced document is simply “extra on tablet”; the next upload puts the file at the correct path.
  • Before the one-time rebuild, the old database was copied to ~/Library/Application Support/rmpp_books/backups/books-<timestamp>.db.

License

MIT — not affiliated with reMarkable or Douban.

About

Index a local PDF/EPUB library, fetch Douban ratings by ISBN, and mirror it to a reMarkable tablet

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages