👷 Fix action download apk

This commit is contained in:
xtaodada 2023-10-01 22:24:15 +08:00
parent ddf77ef162
commit 6c4f1dd9e7
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 3 additions and 49 deletions

View File

@ -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

View File

@ -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())