-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauto.py
55 lines (43 loc) · 1.46 KB
/
auto.py
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
import os
import json
path = "sticker"
base_url = "https://cdn1.tianli0.top/gh/tianli0/Sticker-Bochi/sticker/"
icon_url_template = base_url + "{}" + "?webp=true"
twikoo = {}
data_valine = {}
data_artalk = {}
file_list = [file for file in os.listdir(path) if file.endswith(".png")]
items_twikoo = []
items_valine = []
items_artalk = []
# 遍历png文件
for file in file_list:
icon = icon_url_template.format(file)
text = file[:-4]
items_twikoo.append({
"icon": f"<img src=\"{icon}\">",
"text": f"bochi-{text}"
})
data_valine[text] = icon
items_artalk.append({
"key": f"Strit-{text}",
"val": icon
})
twikoo["<img src=\"https://cdn1.tianli0.top/gh/tianli0/Sticker-Bochi/sticker/垃圾桶_04.png?webp=true\" style=\"width: 30px;top: 4px;position: relative;\" title=\"bochi\">"] = {
"type": "image",
"container": items_twikoo
}
data_valine = json.dumps(data_valine, indent=4, ensure_ascii=False)
data_artalk = {
"name": "Strit",
"type": "image",
"items": items_artalk
}
data_artalk = json.dumps(data_artalk, indent=4, ensure_ascii=False)
with open("twikoo.json", "w", encoding="utf-8") as f:
json.dump(twikoo, f, indent=4, ensure_ascii=False)
with open("valine.json", "w", encoding="utf-8") as f:
f.write(data_valine)
with open("artalk.json", "w", encoding="utf-8") as f:
f.write(data_artalk)
print("JSON文件生成成功!")