Example script: download every album's photos and metadata (closes #144) #150

Merged
clawbot merged 2 commits from issue-144-download-albums-example into next 2026-10-02 00:33:01 +02:00
Collaborator

Implements #144, as read in #144 (comment).

examples/download-albums.ts exports downloadAlbums(lib, dir). It walks the albums from await lib.fresh(), which waits for a refresh from the server and throws if it fails, so nothing added since the cache was last written is missed. For every album it downloads each photo to its save path, writes {savePath}.json (the photo's record without thumbnailPath and originalPath, plus exif), and writes {dir}/albums/{collectionID}.json (collectionID, name, and savePaths relative to dir). A JSON file is written only when its content differs.

main() reads QUAK_EMAIL and QUAK_PASSWORD, asks for a code on the terminal only when the account needs one, opens the library on dir (default photos), and prints how many photos it downloaded and how many were already local. tsconfig.json now includes examples/; the README gains an "Examples" section.

The test runs downloadAlbums twice, each on a newly opened library, against two albums sharing a photo and a live photo with EXIF. Before the second run the stand-in account gains an album holding a new photo; that run downloads it and fetches or rewrites nothing else.

What the diff does not show:

  • make build and the CI build type-check the example; make check does not.
  • The test sets every modification time to the epoch before the second run, so a rewrite shows even within one timestamp tick.
  • Opening the library still starts its ML data fetch into the cache, as in quak backup.

Deviation: main() turns the thumbnail and originals precache off, as quak backup does; the README says so.

Model: opus-5-5

Implements https://git.eeqj.de/sneak/quak/issues/144, as read in https://git.eeqj.de/sneak/quak/issues/144#issuecomment-107573. `examples/download-albums.ts` exports `downloadAlbums(lib, dir)`. It walks the albums from `await lib.fresh()`, which waits for a refresh from the server and throws if it fails, so nothing added since the cache was last written is missed. For every album it downloads each photo to its save path, writes `{savePath}.json` (the photo's record without `thumbnailPath` and `originalPath`, plus `exif`), and writes `{dir}/albums/{collectionID}.json` (`collectionID`, `name`, and `savePaths` relative to `dir`). A JSON file is written only when its content differs. `main()` reads `QUAK_EMAIL` and `QUAK_PASSWORD`, asks for a code on the terminal only when the account needs one, opens the library on `dir` (default `photos`), and prints how many photos it downloaded and how many were already local. `tsconfig.json` now includes `examples/`; the README gains an "Examples" section. The test runs `downloadAlbums` twice, each on a newly opened library, against two albums sharing a photo and a live photo with EXIF. Before the second run the stand-in account gains an album holding a new photo; that run downloads it and fetches or rewrites nothing else. What the diff does not show: - `make build` and the CI build type-check the example; `make check` does not. - The test sets every modification time to the epoch before the second run, so a rewrite shows even within one timestamp tick. - Opening the library still starts its ML data fetch into the cache, as in `quak backup`. Deviation: `main()` turns the thumbnail and originals precache off, as `quak backup` does; the README says so. Model: opus-5-5
clawbot added the needs-review label 2026-10-01 23:44:06 +02:00
clawbot self-assigned this 2026-10-01 23:44:06 +02:00
Author
Collaborator

Review: fail.

  1. examples/download-albums.ts:39 (with :103): the script walks lib.albums.list() straight after Library.open. Once the cache exists (after the first run, or after any quak command for the same account), Library.open returns the cached copy and refreshes in the background. Photos and albums added on the server since the cache was last written are then not downloaded, and the run still reports success; they arrive only on a later run. If the first refresh fails, the library opens empty and the script prints 0 photos downloaded and exits 0. Acceptable: walk the albums from await lib.fresh(), which waits for the refresh and throws when it fails. Extend test/examples/download-albums.test.ts so the stand-in account gains a photo and an album before the second run, and that run must download them.

  2. README.md:83-109: the "Examples" section does not say that the script opens the library with precacheThumbnails and precacheOriginals off, as quak backup does. That deviation is acceptable only if the README says so. Acceptable: one sentence in that section stating it.

Model: opus-5-5

Review: fail. 1. `examples/download-albums.ts:39` (with `:103`): the script walks `lib.albums.list()` straight after `Library.open`. Once the cache exists (after the first run, or after any `quak` command for the same account), `Library.open` returns the cached copy and refreshes in the background. Photos and albums added on the server since the cache was last written are then not downloaded, and the run still reports success; they arrive only on a later run. If the first refresh fails, the library opens empty and the script prints `0 photos downloaded` and exits 0. Acceptable: walk the albums from `await lib.fresh()`, which waits for the refresh and throws when it fails. Extend `test/examples/download-albums.test.ts` so the stand-in account gains a photo and an album before the second run, and that run must download them. 2. `README.md:83-109`: the "Examples" section does not say that the script opens the library with `precacheThumbnails` and `precacheOriginals` off, as `quak backup` does. That deviation is acceptable only if the README says so. Acceptable: one sentence in that section stating it. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-02 00:00:54 +02:00
clawbot added 2 commits 2026-10-02 00:18:15 +02:00
`examples/download-albums.ts` logs in with `QUAK_EMAIL` and `QUAK_PASSWORD`,
opens the library, and for every album downloads each photo to its save path,
writes `{savePath}.json` with the photo's record (cache paths left out) and its
EXIF fields, and writes `albums/{collectionID}.json` with the album's save
paths. A JSON file is written only when its content changed, so a second run
downloads and rewrites nothing. `tsconfig.json` includes `examples/`, so the
build type-checks it. A test runs it twice against a stand-in account.

Model: opus-5-5
downloadAlbums now waits for a refresh from the server through lib.fresh()
before walking the albums, so albums and photos added since the cache was
last written are downloaded, and a failed refresh throws instead of
reporting an empty or stale library as done. The test's stand-in account
gains an album holding a new photo before the second run, and that run must
download it. The README's "Examples" section says the script opens the
library with the thumbnail and originals precache off, as `quak backup` does.

Model: opus-5-5
clawbot force-pushed issue-144-download-albums-example from 12616e7254 to b42c5b0e0d 2026-10-02 00:18:15 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-02 00:18:50 +02:00
Author
Collaborator

Review: pass.

Model: opus-5-5

Review: pass. Model: opus-5-5
clawbot merged commit 10afa7a7f4 into next 2026-10-02 00:33:01 +02:00
clawbot deleted branch issue-144-download-albums-example 2026-10-02 00:33:01 +02:00
Sign in to join this conversation.