code wiki / _hdl_build / nx_vk_probe.nx

nx_vk_probe.nx source

↩ module page · 72 lines · 4428 B

1// nx_vk_probe.nx -- capability test on VK (vk.com), a mainstream public video platform (yt-dlp supports it). 2// Fetch the watch page over sovereign TLS, report ground-truth stream signals, and run the NATIVE orchestrator 3// (mx_extract) to see how far our resilient classifier gets on a real site. VK embeds direct URLs in a 4// playerParams JSON (url240/url480/url720/hls, JSON-escaped \/), so this exercises the same embedded-state + 5// escaped-slash + classify path as YouTube's ytInitialPlayerResponse. Honest assessment, no download. Run from 6// nxc2 root. license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_x509_trust_store.nx" 9import "nx_trust_store_load_from_certdata.nx" 10import "nx_https_fetch_follow.nx" 11import "nx_media_state.nx" 12import "nx_media_signal.nx" 13import "nx_media_extract.nx" 14const K_MAGIC_4194304: i64 = 4194304 15const K_MAGIC_8388608: i64 = 8388608 16const K_MAGIC_4096: i64 = 4096 17const K_MAGIC_1024: i64 = 1024 18 19func pw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 20func pn(v: i64) -> i64 { let b: *u8=sys_mmap(24); var m: i64=v; if m<0{pw("-" as *u8);m=0-m} let t: *u8=sys_mmap(24); 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 i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } 21func pslen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 22func count_occ(hay: *u8, hl: i64, needle: *u8) -> i64 { 23 let nl: i64 = pslen(needle) 24 var c: i64 = 0 25 var i: i64 = ms_find(hay, hl, needle, nl, 0) 26 while i >= 0 { c = c + 1; i = ms_find(hay, hl, needle, nl, i + nl) } 27 return c 28} 29 30func main(argc: i64, argv: *i64) -> i64 { 31 var url: *u8 = "https://vk.com/video-220401040_456239479" as *u8 32 if argc >= 2 { url = argv[1] as *u8 } 33 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304) 34 if r <= 0 { pw("VK-PROBE: certdata load failed (run from nxc2 root)\n" as *u8); sys_exit(1); return 1 } 35 let store: *TrustStore = r as *TrustStore 36 let status: *i64 = sys_mmap(8) as *i64 37 38 pw("== nx_vk_probe ==\nurl: " as *u8); pw(url); pw("\n" as *u8) 39 let cap: i64 = K_MAGIC_8388608 40 let html: *u8 = sys_mmap(cap) 41 let hn: i64 = nx_https_fetch_follow(url, store, html, cap, 6, status) 42 pw("fetch status=" as *u8); pn(status[0]); pw(" bytes=" as *u8); pn(hn); pw("\n" as *u8) 43 if hn <= 0 { pw("VK-PROBE: fetch FAILED (VK may geo/bot-block our fetch -- honest data point)\n" as *u8); sys_exit(0); return 0 } 44 45 pw("-- FULL HTML ground-truth signals --\n" as *u8) 46 pw(" playerParams (embedded config): " as *u8); pn(count_occ(html, hn, "playerParams" as *u8)); pw("\n" as *u8) 47 pw(" url720/url480 (quality-keyed direct): u720=" as *u8); pn(count_occ(html, hn, "url720" as *u8)); pw(" u480=" as *u8); pn(count_occ(html, hn, "url480" as *u8)); pw("\n" as *u8) 48 pw(" .mp4 refs: " as *u8); pn(count_occ(html, hn, ".mp4" as *u8)); pw("\n" as *u8) 49 pw(" .m3u8 (HLS): " as *u8); pn(count_occ(html, hn, ".m3u8" as *u8)); pw("\n" as *u8) 50 pw(" mycdn.me (VK CDN host): " as *u8); pn(count_occ(html, hn, "mycdn.me" as *u8)); pw("\n" as *u8) 51 pw(" vkvd/vkuservideo: " as *u8); pn(count_occ(html, hn, "vkvd" as *u8)); pw("\n" as *u8) 52 pw(" al_video.php (API endpoint): " as *u8); pn(count_occ(html, hn, "al_video" as *u8)); pw("\n" as *u8) 53 54 // native resilient orchestrator on the REAL page 55 pw("-- intelligent orchestrator (mx_extract, NATIVE, no JS engine) --\n" as *u8) 56 let best: *u8 = sys_mmap(K_MAGIC_4096) 57 let kb: *i64 = sys_mmap(8) as *i64 58 let conf: i64 = mx_extract(html, hn, best, K_MAGIC_4096, kb) 59 pw(" best media kind: " as *u8); pn(kb[0]); pw(" confidence: " as *u8); pn(conf); pw("\n" as *u8) 60 if conf > 0 { 61 pw(" best URL (first 96 chars): " as *u8) 62 var q: i64 = 0 63 while q < 96 { if (best[q]&0xff) == 0 { q = 96 } else { sys_write(1, ((best as i64)+q) as *u8, 1); q = q + 1 } } 64 pw("\n" as *u8) 65 } 66 let title: *u8 = sys_mmap(K_MAGIC_1024) 67 let tl: i64 = xt_extract_title(html, hn, title, K_MAGIC_1024) 68 pw(" smart-name title (" as *u8); pn(tl); pw(" chars): " as *u8); if tl > 0 { sys_write(1, title, tl) } pw("\n" as *u8) 69 pw("== assessment: conf>0 = our native classifier found VK's stream on the live page; url720>0 = playerParams present ==\n" as *u8) 70 sys_exit(0) 71 return 0 72}