nx_media_harvest.nx
buildroot/runtime/nx_media_harvest.nx
about
nx_media_harvest.nx -- SUPERSET media-URL harvester (operator 2026-07-08: "how do i get my nishi browser to
see the source of gifs and vids and images on a page like this" -- an ad/popunder lander hides media in lazy
attrs, <source>/<video>, HLS manifests, JSON blobs and CSS url()). This is nx_img_harvest's proven multi-
strategy raw-byte scan EXTENDED past images: it also finds VIDEO (.mp4/.webm/.m4v/.mov/.mkv/.ogv), STREAM
manifests (.m3u8/.mpd) and AUDIO (.mp3/.m4a/.ogg/.opus/.wav/.aac), and it adds a CSS url(...) pass so
UNQUOTED backgrounds (background:url(/bg/hero.gif)) surface too -- the quoted-region scan alone misses those.
Every hit is CLASSIFIED into a kind (0 image / 1 gif / 2 video / 3 stream / 4 audio) so the caller can label
and preview it. Same offs/lens/url_buf interface as nx_img_harvest, plus a parallel kinds[] array.
nx_media_harvest(html,hlen, base_url,base_len, url_buf,cap, offs,lens,kinds, max_n) -> count
Mechanism (per token): unescape JSON "\/"->"/", classify by path extension (path = up to ?/#), resolve
rel->abs (nx_url_resolve), dedup. Junk (data: URIs, .svg, favicon/sprite/logo) rejected for image kinds.
license_tier: ORIGINAL
dependencies 2 imports · 5 importers
imports: nx_syscalls.nxnx_url_resolve.nx
imported by: nx_browser.nxnx_media_deepcrawl.nxnx_media_grab.nxnx_media_harvest_gate.nxnx_media_inspect.nx
structs
| none |
consts
| 16 | const MH_KIND_IMAGE: i64 = 0 |
| 17 | const MH_KIND_GIF: i64 = 1 |
| 18 | const MH_KIND_VIDEO: i64 = 2 |
| 19 | const MH_KIND_STREAM: i64 = 3 |
| 20 | const MH_KIND_AUDIO: i64 = 4 |
functions
| 23 | func mh_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } |
| 24 | func mh_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: mh_classify |
| 27 | func mh_has_ci(hay: *u8, hn: i64, needle: *u8) -> i64 |
| 42 | func mh_classify(tok: *u8, tn: i64) -> i64 |
| 129 | func mh_unescape(tok: *u8, tn: i64, out: *u8, cap: i64) -> i64 called by 1: mh_consider |
| 144 | func mh_seen(url_buf: *u8, offs: *i64, lens: *i64, count: i64, cand: *u8, cn: i64) -> i64 called by 1: mh_consider |
| 160 | func mh_resolve(base: *u8, blen: i64, cand: *u8, cn: i64, out: *u8, cap: i64) -> i64 |
| 183 | func mh_consider(tok: *u8, tn: i64, base_url: *u8, base_url_len: i64, |
| 207 | func nx_media_harvest(html: *u8, hlen: i64, base_url: *u8, base_url_len: i64, |
| 281 | func nx_media_kind_label(kind: i64) -> *u8 |
| 291 | func mh_ap(buf: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; var w: i64=off; while s[i]!=(0 as u8){ buf[w]=s[i]; w=w+1; i=i+1 } return w } |
| 292 | func mh_apr(buf: *u8, off: i64, ptr: *u8, len: i64) -> i64 { var i: i64=0; var w: i64=off; while i<len { buf[w]=ptr[i]; w=w+1; i=i+1 } return w } |
| 293 | func mh_apn(buf: *u8, off: i64, v0: i64) -> i64 { var v: i64=v0; var w: i64=off; if v<0 { buf[w]=45 as u8; w=w+1; v=0-v } let b: *u8=sys_mmap(24); var k: i64=0; if v==0{b[0]=48 as u8;k=1} while v>0{b[k]=(48+(v%10)) as u8;v=v/10;k=k+1} var j: i64=k-1; while j>=0{ buf[w]=b[j]; w=w+1; j=j-1 } return w } |
| 295 | func mh_card_img(H: *u8, off: i64, p: *u8, ulen: i64) -> i64 |
| 301 | func mh_card_video(H: *u8, off: i64, p: *u8, ulen: i64) -> i64 |
| 307 | func mh_card_audio(H: *u8, off: i64, p: *u8, ulen: i64) -> i64 |
| 313 | func mh_card_link(H: *u8, off: i64, p: *u8, ulen: i64, note: *u8) -> i64 |
| 321 | func nx_media_emit_panel(H: *u8, srcurl: *u8, srclen: i64, ub: *u8, offs: *i64, lens: *i64, kinds: *i64, cnt: i64) -> i64 |