Code to backup my data from Goodreads. Daily cronjob to download CSV of books I've read. Also grab book recommendations, possibly using Python Playwright.
  • Python 95.9%
  • HTML 4.1%
Find a file
2026-11-10 11:06:07 +00:00
templates Add old code for downloading recommendations 2024-04-17 09:11:41 +01:00
.gitignore Add gitignore 2023-12-22 10:56:05 +00:00
AGENTS.md Replace Playwright backups with Requests and lxml 2026-11-10 11:06:07 +00:00
backup.py Replace Playwright backups with Requests and lxml 2026-11-10 11:06:07 +00:00
get.py Update code style 2024-04-17 10:02:26 +01:00
LICENSE Initial commit 2023-12-19 10:14:38 +00:00
parse.py Add docstring 2024-04-17 10:05:05 +01:00
README.md Replace Playwright backups with Requests and lxml 2026-11-10 11:06:07 +00:00
requirements.txt Replace Playwright backups with Requests and lxml 2026-11-10 11:06:07 +00:00
test_backup.py Replace Playwright backups with Requests and lxml 2026-11-10 11:06:07 +00:00

goodreads-backup

Download a fresh Goodreads library CSV using Requests and lxml. No browser or Playwright installation is needed.

Install dependencies with python3 -m pip install -r requirements.txt, or on Debian with sudo apt install python3-requests python3-lxml.

Configure ~/.config/goodreads/config (or $XDG_CONFIG_HOME/goodreads/config):

[login]
email = your-email@example.com
password = your-password

[backup]
dir = /path/to/existing/backup/directory

Run ./backup.py. It requests a fresh export, polls for completion for up to 15 minutes, validates the CSV header and atomically writes YYYY-MM-DD_goodreads_library_export.csv in the configured directory. Read requests retry transient failures up to three times, with a 60-second timeout per request. Login and export POSTs are never automatically repeated. An unchanged old export is not treated as a successful fresh backup.

The existing Playwright auth.json is read automatically; there is no manual cookie conversion. Refreshed cookies are saved privately in the same format. ./backup.py --check-login checks the saved session without logging in, exporting, or changing auth.json. ./backup.py --login-only refreshes authentication without exporting. If the saved session has expired, the script submits the email/password login form with its hidden fields. CAPTCHA, MFA or an unsupported login flow cause a clear error; refresh auth.json from a signed-in browser session if needed. The old --no-headless and --har-path options have been removed.

Use chronic (from moreutils) before the backup command in cron to suppress output on success and receive mail on failure. Failures exit nonzero and print a short error message. Add --debug when running manually for a full traceback.

Run regression checks with python3 -m unittest -v.