code wiki / _hdl_build / nx_media_import.nx
nx_media_import.nx
buildroot/runtime/_hdl_build/nx_media_import.nx
about
nx_media_import.nx -- GENERAL POLITE media importer: pull images from ANY site (Shein/e-commerce/art/galleries)
into the family library, RESPECTING the host's rules. Operator 2026-07-03: "import politely images from places
like shein etc to get state of the art." The differentiator vs a crude scraper is POLITENESS BY CONSTRUCTION:
1. fetch the host's /robots.txt and HONOR it (nx_robots_allowed) -- a Disallow => we DO NOT fetch (refuse).
2. send an HONEST User-Agent identifying us + a contact/purpose.
3. pace requests to the host's Crawl-delay (nx_robots_crawl_delay), default a courteous floor.
Then it reuses the PROVEN engine: mg_gallery_to_pages (Chrome-JA3 fetch that beats anti-bot CDNs + multi-strategy
nx_img_harvest + download-integrity + cbx.json manifest) and lands the result in the caller's PRIVATE reader area
(rl_add_personal) so it shows up in the zoom reader as a browsable image collection. Composes; adds only the
politeness gate. CLI: nx_media_import <page_url> <slug> <ukey> (forked by the daemon on an "Import" POST).
license_tier: ORIGINAL
dependencies 7 imports · 1 importers
imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nxnx_robots.nxnx_manga_get.nxnx_reader_library.nx
imported by: nx_media_import_gate.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 19 | const MI_MAGIC_1000000: i64 = 1000000 |
| 20 | const MI_MAGIC_1024: i64 = 1024 |
| 21 | const MI_MAGIC_9309: i64 = 9309 |
| 22 | const MI_MAGIC_4194304: i64 = 4194304 |
| 25 | const MI_UA: *u8 = "NishiMediaImporter/1.0 (+https://nishifamily.com; personal family library import)" |
| 26 | const MI_UA_LEN: i64 = 78 |
| 27 | const MI_POLITE_FLOOR_MS: i64 = 1000 // courteous default spacing if the host sets no Crawl-delay |
| 28 | const MI_ROBOTS_CAP: i64 = 262144 |
functions
| 30 | func mi_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 31 | func mi_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 35 | func mi_split(url: *u8, host_out: *u8, path_idx_out: *i64) -> i64 |
| 59 | func mi_pace_ms(ms: i64) -> i64 |
| 69 | func mi_import(page_url: *u8, ukey: *u8, slug: *u8, store: *TrustStore) -> i64 |
| 119 | func main(argc: i64, argv: *i64) -> i64 |