From 6c4f1dd9e7c4832428390e95c6c9ea919ef10921 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sun, 1 Oct 2023 22:24:15 +0800 Subject: [PATCH] :construction_worker: Fix action download apk --- .github/workflows/ds.yml | 5 +++-- compiler/ds/download.py | 47 ---------------------------------------- 2 files changed, 3 insertions(+), 49 deletions(-) delete mode 100644 compiler/ds/download.py 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())