Repository navigation
Conversation
Getting an .apkg onto the handheld previously meant pulling the SD
card or SSH. Now a parent can host decks on any plain HTTP(S) server
(python -m http.server, a NAS, nginx, a static bucket) and the device
fetches them over WiFi — using only the standard library (urllib +
json + zipfile), per the project's no-new-dependencies policy.
- cardbrick/deck_download.py: fetch_deck_list() reads either a direct
.apkg URL or a JSON deck list ({"decks": [{"name", "url"|"file",
"size"}]}, relative URLs resolved against the manifest);
download_deck() streams to a .part file with a 1 GiB cap, verifies
the result is a real zip, then renames atomically, so a dropped
connection or captive-portal page never leaves a corrupt .apkg.
Only http/https are followed, redirects included (the default urllib
opener would follow a redirect to file://), and manifest filenames
are reduced to a safe basename.
- Parent mode gains a "Download decks (WiFi)" screen: lists the
server's decks with sizes, downloads with a progress readout into
the existing import/ folder, and imports immediately. The server URL
is a new deck_server_url key in settings.json — set once by editing
the file on the SD card, consistent with settings being
hand-editable on purpose (no on-device URL keyboard).
- CLI: `main.py import <url>` downloads then imports;
`main.py download [url] [--list] [--deck NAME]` fetches into
import/ without importing (URL defaults to the setting).
- Tests run against a real local http.server: manifest parsing,
relative/hostile entries, non-zip rejection, size cap, 404s, scheme
restrictions, filename sanitisation.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JUC6t25ShAwWjEeKK1fvvt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add optional WiFi-based deck downloading for the parent-mode appliance, allowing decks to be hosted on any plain HTTP(S) server and downloaded directly into the import folder without requiring SD card access or SSH.
Key Changes
New
deck_download.pymodule: Implements secure, hardened deck downloading with:.apkgURLs and JSON deck manifests.partfiles with byte-cap enforcement (1 GiB default)urllib,json,zipfile)Parent-mode UI: New "Download decks (WiFi)" screen in
app.py:CLI support: New
python main.py downloadcommand:data/import/--listflag to preview available decks--deck NAMEto selectively download specific decksdeck_server_urlsetting as defaultImport enhancement:
python main.py importnow accepts http(s) URLs in addition to file pathsConfiguration: New
deck_server_urlsetting insettings.jsonfor the server endpoint (either direct.apkgor JSON manifest URL)Documentation: Updated README with deck download workflow, manifest format, and security model
Implementation Details
{"decks": [...]}and bare list syntaxnamefield or URL path, with hostile characters neutralizedDownloadErrorexceptionshttps://claude.ai/code/session_01JUC6t25ShAwWjEeKK1fvvt