code wiki / _hdl_build / nx_manga_get.nx
nx_manga_get.nx
buildroot/runtime/_hdl_build/nx_manga_get.nx
about
nx_manga_get.nx -- R2a of the native manga DOWNLOAD ladder (census row URL): a generic gallery/chapter PAGE URL
-> ordered page images in a book dir + cbx.json, sovereign end-to-end (no python/gallery-dl/curl). Composes the
PROVEN organs: nx_https_fetch_follow (own TLS-1.3 GET) + nx_html_extract_imgs (extract every <img src>, RESOLVED
relative->absolute via nx_url_resolve) + nx_reader_library (land in the downloader's PRIVATE area). FORK-PER-IMAGE
so each image fetch's TLS mmaps die with the child (the researcher's proven per-fetch-process pattern) -> a
200-page gallery never leaks. Writes reader/u_<ukey>/<slug>/page000.<ext>... + cbx.json (the reader/zoom viewer's
manifest), then rl_add_personal(ukey, slug, title). The daemon calls this (fork) on an "Add manga" POST; also a
CLI. LEGAL POSTURE: general capability; smoke on public-domain/legal pages; the operator points it where they like.
license_tier: ORIGINAL
dependencies 8 imports · 2 importers
imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nxnx_img_harvest.nxnx_manga_sites.nxnx_reader_library.nxnx_img_dims.nx
imported by: nx_manga_get_gate.nxnx_media_import.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 18 | const MG_MAGIC_2048: i64 = 2048 |
| 19 | const MG_MAGIC_65536: i64 = 65536 |
| 20 | const MG_MAGIC_2166136261: i64 = 2166136261 |
| 21 | const MG_MAGIC_16777619: i64 = 16777619 |
| 22 | const MG_MAGIC_1048576: i64 = 1048576 |
| 23 | const MG_MAGIC_4096: i64 = 4096 |
| 24 | const MG_MAGIC_4095: i64 = 4095 |
| 25 | const MG_MAGIC_4194304: i64 = 4194304 |
| 27 | const MG_MAX_IMGS: i64 = 512 |
| 28 | const MG_IMG_CAP: i64 = 16777216 // 16MB per image cap (fetch buffer, per child) |
| 29 | const MG_HTML_CAP: i64 = 8388608 // 8MB page HTML cap |
| 30 | const MG_MIN_BYTES: i64 = 1024 // floor: below this = tracker/spacer/blank, never a real manga page |
| 31 | const MG_MIN_EDGE: i64 = 100 // reject nav icons/spacers/tracking-pixels: long edge < 100px is never content (real pages/photos are bigger) |
functions
| 33 | func mg_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 34 | func mg_putn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let d:*u8=sys_mmap(24); var k:i64=0; while m>0{d[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=k-1; while i>=0{let o:*u8=sys_mmap(1);o[0]=d[i];sys_write(1,o,1);i=i-1} return 0 } |
| 35 | func mg_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 36 | func mg_apps(dst: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ dst[o+i]=s[i]; i=i+1 } return o+i } |
| 37 | func mg_num(dst: *u8, o: i64, v: i64) -> i64 { let t: *u8=sys_mmap(24); var m: i64=v; var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var w: i64=o; var i: i64=0; while i<k{dst[w]=t[k-1-i]; w=w+1; i=i+1} return w } |
| 40 | func mg_page_name(idx: i64, ext: *u8, out: *u8) -> i64 |
| 50 | func mg_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]==(0 as u8){return 1} return 0 } called by 1: mg_ext_ok |
| 51 | func mg_ext_ok(e: *u8) -> i64 |
| 60 | func mg_default_jpg(out: *u8) -> i64 { out[0]=46 as u8; out[1]=106 as u8; out[2]=112 as u8; out[3]=103 as u8; out[4]=0 as u8; return 4 } called by 1: mg_ext_from_url |
| 62 | func mg_ext_from_url(url: *u8, out: *u8) -> i64 |
| 85 | func mg_img_magic_ok(b: *u8, n: i64) -> i64 |
| 99 | func mg_img_complete(b: *u8, n: i64) -> i64 |
| 129 | func mg_fetch_one(url: *u8, store: *TrustStore, dir: *u8, pagename: *u8) -> i64 called by 1: mg_gallery_to_pages calls 7: sys_mmapmg_img_completenx_img_long_edgemg_appssys_openat_wrsys_write+1 |
| 152 | func mg_file_fp(path: *u8) -> i64 |
| 174 | func mg_write_cbx(dir: *u8, title: *u8, npages: i64, exts: *i64) -> i64 called by 2: mg_gallery_to_pagesmain calls 7: sys_mmapmg_appssys_openat_wrmg_nummg_page_namesys_write+1 |
| 205 | func mg_write_dl(dir: *u8, total: i64, done: i64) -> i64 |
| 220 | func mg_gallery_to_pages(page_url: *u8, dest_dir: *u8, title: *u8, store: *TrustStore, title_out: *u8) -> i64 called by 1: main calls 19: sys_mmapmg_slenna_detectna_html_titlena_nhentai_from_pagena_mangadex_meta_api+13 |
| 314 | func main(argc: i64, argv: *i64) -> i64 |