misskey2telegram/gen/achievement.py

30 lines
713 B
Python
Raw Normal View History

2023-07-20 14:21:37 +00:00
from json import dump
2023-07-03 14:22:02 +00:00
from pathlib import Path
2023-07-20 14:21:37 +00:00
import yaml
2023-07-03 14:22:02 +00:00
from httpx import get
json_path = Path(__file__).parent / "achievement.json"
def main():
2023-07-03 14:39:52 +00:00
yml_data = get(
"https://cdn.staticaly.com/gh/misskey-dev/misskey/develop/locales/zh-CN.yml"
)
2023-07-03 14:22:02 +00:00
json_raw_data = yaml.safe_load(yml_data.text)
json_data = {}
2023-07-03 14:39:52 +00:00
for key, value in json_raw_data["_achievements"]["_types"].items():
json_data[key[1:]] = (
value.get("title", ""),
value.get("description", ""),
value.get("flavor", ""),
)
2023-07-03 14:22:02 +00:00
with open(json_path, "w", encoding="utf-8") as f:
dump(json_data, f, ensure_ascii=False, indent=4)
if __name__ == "__main__":
main()