-
Notifications
You must be signed in to change notification settings - Fork 6
/
get_data.py
46 lines (42 loc) · 1.23 KB
/
get_data.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
import requests
import json
github_url = "https://api.github.com/repos/CFPAOrg/Minecraft-Mod-Language-Package/contributors"
weblate_url = "https://weblate-t.exz.me/api/projects/langpack/statistics/?format=json"
data_js = """
var contri = new Vue({{
el: "#contributor",
data: {{
contributor: {}
}}
}});
"""
weblate_js = """
var transData = new Vue({{
el: "#weblate",
data: {{
result: {}
}},
computed: {{
precent: function() {{
return (this.result["translated"] / this.result["total"] * 100).toFixed(3) + "%"
}}
}}
}})
"""
data = []
weblate = {}
i = 1
github_result = requests.get('{}?page={}'.format(github_url, i))
data.extend(github_result.json())
while len(github_result.json()) > 0:
i = i+1
github_result = requests.get('{}?page={}'.format(github_url, i))
data.extend(github_result.json())
with open("./js/data.js", "w", encoding="utf-8") as f:
data_text = json.dumps(data, ensure_ascii=False)
f.write(data_js.format(data_text))
weblate_result = requests.get(weblate_url)
weblate = weblate_result.json()[0]
with open("./js/weblate.js", "w", encoding="utf-8") as f:
weblate_text = json.dumps(weblate, ensure_ascii=False)
f.write(weblate_js.format(weblate_text))