-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfetchg7.py
More file actions
73 lines (57 loc) · 1.76 KB
/
fetchg7.py
File metadata and controls
73 lines (57 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
# fetchg7.py - Fetch some charsets from zi.tools and system.
# (c) 2025 DWNfonts.
# This script requires `requests` to load.
import requests
import sys
sys.stdout.reconfigure(encoding="utf-8")
def fetchg7():
# Fetch the charset from zi.tools.
r = requests.get("https://zi.tools/api/ma/ma/g7.json")
zt_g7 = r.json()
g7 = [x[1] for x in zt_g7["rows"]]
return g7
def fetchgcy():
# Fetch the charset from zi.tools.
r = requests.get("https://zi.tools/api/ma/ma/g_cy.json")
zt_gcy = r.json()
gcy = [x[1] for x in zt_gcy["rows"]]
return gcy
def fetchgtg(maxchar=8105):
# Fetch the charset from zi.tools.
r = requests.get("https://zi.tools/api/ma/ma/g_tg.json")
zt_gtg = r.json()
gtg = []
for i in range(len(zt_gtg["rows"])):
id = zt_gtg["rows"][i][0]
zi = zt_gtg["rows"][i][1]
try:
if int(id) <= maxchar:
gtg.append(zi)
except:
pass
return gtg
def fetchg0(lvl1=False):
# Fetch the charset from zi.tools.
r = requests.get("https://zi.tools/api/ma/ma/g0.json")
zt_gcy = r.json()
gcy = [x[1] for x in zt_gcy["rows"]]
return gcy[:3755] if lvl1 else gcy
def allchr():
return set(fetchg0() + fetchg7() + fetchgtg())
if __name__ == "__main__":
result = list(allchr())
result.sort()
with open("data/stat.txt", encoding="utf8") as f:
stat = []
for lines in f:
try:
zi = lines.strip().split("\t")[1]
id = lines.strip().split("\t")[0]
except:
zi = ""
id = -1
if zi in result:
print(lines, end="")
stat.append(id)
print("# "+str(len(set(stat)) - 1))