diff --git a/.github/workflows/ds.yml b/.github/workflows/ds.yml index ead279e..aa70832 100644 --- a/.github/workflows/ds.yml +++ b/.github/workflows/ds.yml @@ -25,11 +25,12 @@ jobs: distribution: 'temurin' java-version: '17' cache: 'gradle' + - name: Install jq + run: sudo apt-get install -y jq - name: Download apk run: | - pip install httpx cd compiler/ds - python download.py ${{ secrets.DOWNLOAD }} + curl -H 'x-rpc-client_type: 2' -H 'x-rpc-app_version: 2.37.1' -H 'x-rpc-channel: miyousheluodi' https://api-takumi.mihoyo.com/ptolemaios/api/getLatestRelease | jq --raw-output '.data.package_url' | xargs curl -o mihoyobbs.apk - name: Parse apk run: | cd compiler/ds diff --git a/compiler/ds/download.py b/compiler/ds/download.py deleted file mode 100644 index f3625c0..0000000 --- a/compiler/ds/download.py +++ /dev/null @@ -1,47 +0,0 @@ -from time import sleep - -from httpx import get -import subprocess -import sys - -url = sys.argv[1] if len(sys.argv) > 1 else "https://download-bbs.miyoushe.com" - - -def retry(func): - """retry 10 times""" - - def wrapper(*args, **kwargs) -> str: - """retry 10 times""" - for _ in range(10): - try: - return func(*args, **kwargs) - except Exception: # skipcq: PYL-W0703 - print("retrying...") - sleep(1) - continue - return None - - return wrapper - - -@retry -def get_version(): - """get version""" - return get( - "https://bbs-api.miyoushe.com/misc/wapi/getLatestPkgVer?channel=miyousheluodi", - verify=False, - ).json()[ - "data" - ]["version"] - - -version = get_version() -apk_url = f"{url}/app/mihoyobbs_{version}_miyousheluodi.apk" -print(f"download version {version} from {apk_url}") - -command = f"wget -O mihoyobbs.apk {apk_url}" -process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # skipcq: BAN-B602 -output, error = process.communicate() - -print("命令输出:\n", output.decode()) -print("错误信息:\n", error.decode())