code wiki / _hdl_build / nx_manga_browser_research_fetch.nx
nx_manga_browser_research_fetch.nx source
↩ module page · 77 lines · 5041 B
1// nx_manga_browser_research_fetch.nx -- HONEST research (operator 2026-07-04: "use nishi researcher and really
2// benchmark what things like github.com/topics/hentai do"). Fetches the GitHub topic search API (top repos by
3// stars) + top-repo READMEs with our sovereign Chrome client (we beat GitHub's Cloudflare/TLS wall). Parses the
4// search JSON to a COMPACT list (rank, full_name, stars, topics, description) then dumps chosen READMEs -> so the
5// browse/progress/UI census is grounded on what these tools ACTUALLY do. Temporary research organ. license_tier: ORIGINAL
6import "nx_syscalls.nx"
7import "nx_x509_trust_store.nx"
8import "nx_trust_store_load_from_certdata.nx"
9import "nx_https_fetch_follow.nx"
10import "nx_manga_sites.nx" // na_find_from
11const K_MAGIC_4194304: i64 = 4194304
12const K_MAGIC_2097152: i64 = 2097152
13const K_MAGIC_3000: i64 = 3000
14const K_MAGIC_2600: i64 = 2600
15const K_MAGIC_1600: i64 = 1600
16
17func iw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
18func iln(v: i64) -> i64 { let b: *u8=sys_mmap(24); var m: i64=v; if m<0{iw("-" 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 }
19// print buf[a..e) verbatim
20func iseg(buf: *u8, a: i64, e: i64) -> i64 { if e>a { sys_write(1,(buf as i64+a) as *u8, e-a) } return 0 }
21// value of "key":"..." after `from`, bounded by `bound`; returns the inner [s,e) via out-params; -1 if absent
22func jval(buf: *u8, n: i64, key: *u8, from: i64, bound: i64, sp: *i64, ep: *i64) -> i64 {
23 let kp: i64 = na_find_from(buf, n, key, from)
24 if kp < 0 { return 0-1 } if kp >= bound { return 0-1 }
25 var kl: i64 = 0; while key[kl]!=(0 as u8){kl=kl+1}
26 let s: i64 = kp + kl
27 let e: i64 = na_find_from(buf, n, "\"" as *u8, s)
28 sp[0]=s; ep[0]=e; return 0
29}
30
31func fetch(url: *u8, store: *TrustStore, buf: *u8, cap: i64) -> i64 {
32 let st: *i64 = sys_mmap(8) as *i64
33 let n: i64 = nx_https_fetch_follow_chrome(url, store, buf, cap, 6, st)
34 iw("\n==== "); iw(url); iw(" status="); iln(st[0]); iw(" bytes="); iln(n); iw("\n" as *u8)
35 return n
36}
37
38func main() -> i64 {
39 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304)
40 if r <= 0 { iw("certdata fail\n" as *u8); return 1 }
41 let store: *TrustStore = r as *TrustStore
42 let buf: *u8 = sys_mmap(K_MAGIC_2097152)
43 let n: i64 = fetch("https://api.github.com/search/repositories?q=topic:hentai&sort=stars&order=desc&per_page=20" as *u8, store, buf, K_MAGIC_2097152)
44 if n <= 0 { return 1 }
45 // compact list
46 let sp: *i64 = sys_mmap(8) as *i64; let ep: *i64 = sys_mmap(8) as *i64
47 var pos: i64 = 0; var rank: i64 = 1; var guard: i64 = 0
48 while guard < 40 {
49 guard = guard + 1
50 let fp: i64 = na_find_from(buf, n, "\"full_name\":\"" as *u8, pos)
51 if fp < 0 { guard = 40 } else {
52 let nb: i64 = na_find_from(buf, n, "\"full_name\":\"" as *u8, fp + 13)
53 var bound: i64 = n; if nb >= 0 { bound = nb }
54 iw("["); iln(rank); iw("] " as *u8)
55 if jval(buf, n, "\"full_name\":\"" as *u8, fp, bound, sp, ep) == 0 { iseg(buf, sp[0], ep[0]) }
56 // stars
57 let stp: i64 = na_find_from(buf, n, "\"stargazers_count\":" as *u8, fp)
58 if stp >= 0 { if stp < bound { iw(" *"); var q: i64 = stp + 19; while q < bound { let c: i64 = buf[q] as i64; if c>=48 { if c<=57 { let o1: *u8=sys_mmap(1); o1[0]=buf[q]; sys_write(1,o1,1); q=q+1 } else { q=bound } } else { q=bound } } } }
59 iw("\n topics: " as *u8)
60 let tp: i64 = na_find_from(buf, n, "\"topics\":[" as *u8, fp)
61 if tp >= 0 { if tp < bound { let te: i64 = na_find_from(buf, n, "]" as *u8, tp+10); iseg(buf, tp+9, te+1) } }
62 iw("\n desc: " as *u8)
63 if jval(buf, n, "\"description\":\"" as *u8, fp, bound, sp, ep) == 0 { var d: i64 = ep[0]; if d - sp[0] > 160 { d = sp[0]+160 } iseg(buf, sp[0], d) }
64 iw("\n" as *u8)
65 pos = fp + 13; rank = rank + 1
66 }
67 }
68 // ground the feature census on real READMEs (HEAD = default branch)
69 let rb: *u8 = sys_mmap(K_MAGIC_2097152)
70 let m1: i64 = fetch("https://raw.githubusercontent.com/jiangtian616/JHenTai/HEAD/README.md" as *u8, store, rb, K_MAGIC_2097152)
71 if m1 > 0 { var d: i64 = m1; if d > K_MAGIC_3000 { d = K_MAGIC_3000 } sys_write(1, rb, d); iw("\n" as *u8) }
72 let m2: i64 = fetch("https://raw.githubusercontent.com/Dar9586/NClientV2/HEAD/README.md" as *u8, store, rb, K_MAGIC_2097152)
73 if m2 > 0 { var d2: i64 = m2; if d2 > K_MAGIC_2600 { d2 = K_MAGIC_2600 } sys_write(1, rb, d2); iw("\n" as *u8) }
74 let m3: i64 = fetch("https://raw.githubusercontent.com/9-FS/nhentai_archivist/HEAD/README.md" as *u8, store, rb, K_MAGIC_2097152)
75 if m3 > 0 { var d3: i64 = m3; if d3 > K_MAGIC_1600 { d3 = K_MAGIC_1600 } sys_write(1, rb, d3); iw("\n" as *u8) }
76 return 0
77}