code wiki / (root) / nx_media_gather.nx

nx_media_gather.nx

buildroot/runtime/nx_media_gather.nx

11078 B238 linesdepth 21pulls 135 transitivereach 0 importersview sourcekind tooltopic media
docsdependenciesstructsconstsfunctions

about

nx_media_gather.nx -- the ENTITY MEDIA GATHER rung (canonical case: Diora Baird, the dossier entity from docs/06): fetch an entity's page over the team's OWN validated HTTPS (sovereign DNS+TCP+TLS1.3+X.509, the proven nx_live_https path), extract its image URLs (nx_html_extract_imgs), politely fetch the FIRST hosted image (1.5s pacing, 2 requests total -- far under any polite floor), sniff the magic (nx_media_sniff), content-hash it (sha256_digest), store it content-addressed under knowledge/media/<entity>/, append a PROVENANCE ledger row (knowledge/media/media_ledger.tsv: entity, source url, image url, bytes, sha256, kind), and write a SEARCHABLE dossier doc (knowledge/library/media-<entity>.txt) so the next harvest makes the gathered media findable by nx_search_cli. SELF-VERIFYING: re-reads the stored file and re-hashes -- store verdict is byte-proven, not assumed. v2 rungs: pHash dedup (needs nx_jpeg_decode), multi-image walk, robots+governor wiring for >2-request sessions. Usage: nx_media_gather [url] [entity] license_tier: ORIGINAL

dependencies 9 imports · 0 importers

nx_str.nx nx_syscalls.nx nx_csprng.nx nx_x509_trust_store.nx nx_pem_loader.nx nx_https_get.nx nx_html_extract_imgs.nx nx_media_sniff.nx nx_sha256.nx nx_media_gather.nx

imports: nx_str.nxnx_syscalls.nxnx_csprng.nxnx_x509_trust_store.nxnx_pem_loader.nxnx_https_get.nxnx_html_extract_imgs.nxnx_media_sniff.nxnx_sha256.nx

imported by: nobody (leaf or entry point)

structs

none

consts

21const MG_MAGIC_131072: i64 = 131072
22const MG_MAGIC_4096: i64 = 4096
23const MG_MAGIC_1500: i64 = 1500
25const MG_PAGE_CAP: i64 = 4194304 // 4 MB page buffer
26const MG_IMG_CAP: i64 = 8388608 // 8 MB image buffer
27const MG_MAX_IMGS: i64 = 256

functions

29func mg_puts(s: *u8) -> i64 { sys_write(1, s, nx_str_len(s)); return 0 }
30func mg_pi(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 }
31func mg_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+i }
32func mg_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, nx_str_len(s)); return 0 }
33func mg_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 }
39func mg_mkdir(path: *u8) -> i64 { return __syscall(258, -100, path, 0x1ed, 0, 0, 0) }
42func mg_hex(d: *u8, out: *u8) -> i64
56func mg_body_off(resp: *u8, n: i64) -> i64
66func mg_has(hay: *u8, n: i64, needle: *u8) -> i64
calls 1: nx_str_len
81func mg_write_file(path: *u8, buf: *u8, n: i64) -> i64
94func main(argc: i64, argv: *i64) -> i64