code wiki / (root) / nx_video_get.nx

nx_video_get.nx

buildroot/runtime/nx_video_get.nx

11317 B166 linesdepth 21pulls 129 transitivereach 1 importersview sourcekind tooltopic video
docsdependenciesstructsconstsfunctions

about

nx_video_get.nx -- SOVEREIGN streaming video downloader (X-TORRENT-LIVE-002 video rung). The engine both the Waterfox extension AND the future native nish browser feed: given a media URL (+ Referer/ cookie the sniffer captured), STREAM the body straight to a file (TLS record -> file fd, so multi-GB videos never buffer in RAM), skipping the HTTP headers, following 30x redirects (CDNs redirect a lot). Direct mp4/ts/webm = done here; HLS .m3u8 (fetch playlist -> per-segment) composes this = next rung. Reuses nx_https_get's connect+handshake + the TLS record codec. Sends a real Firefox UA + Referer + Cookie so CDNs that gate on those serve the bytes. argv[1]=url argv[2]=outpath argv[3]=referer argv[4]=cookie. license_tier: ORIGINAL module: nishi-core.media.video_get

dependencies 10 imports · 1 importers

nx_https_get.nx nx_tls13_record.nx nx_tls13_read_record_from_fd.nx nx_tls13_client_session.nx nx_http_client.nx nx_x509_trust_store.nx nx_pem_loader.nx nx_csprng.nx nx_url.nx nx_syscalls.nx nx_video_get.nx nx_hls_get.nx

imports: nx_https_get.nxnx_tls13_record.nxnx_tls13_read_record_from_fd.nxnx_tls13_client_session.nxnx_http_client.nxnx_x509_trust_store.nxnx_pem_loader.nxnx_csprng.nxnx_url.nxnx_syscalls.nx

imported by: nx_hls_get.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main vg_w sys_write sys_exit trust_store_alloc sys_mmap nx_pem_trust_load_file sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_pem_trust_load nx_str_len _pem_find nx_str_len ↻ sys_mmap ↻ b64_decode b64_grab b64_dec_char x509_parse sys_mmap ↻ asn1_cursor_init asn1_expect_tag sys_mmap ↻ asn1_read_tlv_header asn1_read_tag asn1_read_length asn1_read_length ↻ x509_read_tlv sys_mmap ↻ asn1_expect_tag ↻ x509_read_alg_id sys_mmap ↻ asn1_expect_tag ↻ trust_store_add nx_video_fetch vg_strlen

structs

none

consts

19const K_MAGIC_8192: i64 = 8192
20const K_MAGIC_131072: i64 = 131072
21const K_MAGIC_4096: i64 = 4096

functions

23func vg_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
24func vg_wn(fd: i64, v: i64) -> i64 { let t: *u8=sys_mmap(28); 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} let b: *u8=sys_mmap(28); var i: i64=0; while i<k {b[i]=t[k-1-i];i=i+1} sys_write(fd,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
25func vg_puts(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 }
called by 1: vg_build
26func vg_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: nx_video_fetch
27func _vg_write_n(fd: i64, buf: *u8, n: i64) -> i64 { var o: i64=0; while o<n { let w: i64=sys_write(fd,(buf as i64+o) as *u8,n-o); if w<=0 { return 0-1 } o=o+w } return 0 }
called by 1: vg_one calls 1: sys_write
30func vg_build(path: *u8, plen: i64, host: *u8, hlen: i64, referer: *u8, rlen: i64, cookie: *u8, clen: i64, out: *u8) -> i64
called by 1: vg_one calls 1: vg_puts
42func vg_hdr_end(buf: *u8, n: i64) -> i64 { var i: i64=0; while i+4<=n { if buf[i]==(13 as u8){if buf[i+1]==(10 as u8){if buf[i+2]==(13 as u8){if buf[i+3]==(10 as u8){return i+4}}}} i=i+1 } return 0-1 }
called by 1: vg_one
44func vg_status(buf: *u8, n: i64) -> i64 { if n<12 { return 0 } return ((buf[9] as i64-48)*100)+((buf[10] as i64-48)*10)+(buf[11] as i64-48) }
called by 1: vg_one
46func vg_location(buf: *u8, n: i64, out: *u8, ocap: i64) -> i64
called by 1: vg_one
64func vg_one(s: *Tls13ClientSession, fd: i64, path: *u8, plen: i64, host: *u8, hlen: i64, referer: *u8, rlen: i64, cookie: *u8, clen: i64, out_fd: i64, loc: *u8, loc_cap: i64) -> i64
107func nx_video_fetch(url0: *u8, referer: *u8, cookie: *u8, outpath: *u8, store: *TrustStore, now: i64) -> i64
155func main(argc: i64, argv: *i64) -> i64