Skip to content

Commit

Permalink
Apply automatic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 1, 2024
0 parents commit 9030471
Show file tree
Hide file tree
Showing 3 changed files with 33,752 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
schedule:
- cron: '28 21 * * *'
workflow_dispatch:

jobs:
pull:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4
- run: python3 gen.py
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
commit_options: '--amend --no-edit'
push_options: '--force'
skip_fetch: true
24 changes: 24 additions & 0 deletions gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import requests
try:
import ujson as json
except ModuleNotFoundError:
import json

with open('zh2en.json', 'r', encoding='UTF-8') as f:
zh2en = json.load(f)

r = requests.get("https://cdn.jsdelivr.net/gh/EhTagTranslation/DatabaseReleases/db.text.json")
r.raise_for_status()
j = r.json()
assert j["version"] == 6

detrans_namespace = zh2en["namespace"]
detrans_tag = zh2en["tag"]
for namespace in j["data"]:
detrans_namespace[namespace["frontMatters"]["name"]] = namespace["namespace"]
detrans_tag[namespace["namespace"]] = detrans_tag.get(namespace["namespace"], {})
for tag in namespace["data"]:
detrans_tag[namespace["namespace"]][namespace["data"][tag]["name"]] = tag

with open('zh2en.json', 'w', encoding='UTF-8') as f:
json.dump(zh2en, f, ensure_ascii=False, indent='\t')
Loading

0 comments on commit 9030471

Please sign in to comment.