🐛 fix yatta api timeout

This commit is contained in:
xtaodada 2023-07-20 11:38:55 +08:00
parent 95cfd0ff14
commit 549291a553
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -21,20 +21,6 @@ async def get_all_avatar() -> List[str]:
return list(req.json()["data"]["items"].keys())
async def get_single_avatar(url: str) -> None:
req = await client.get(url)
try:
avatar = YattaAvatar(**req.json()["data"])
except Exception:
print(f"{url} 获取星魂数据失败")
return
if len(avatar.eidolons) != 6:
print(f"{url} 获取星魂图片失败")
return
urls = [i.icon_url for i in avatar.eidolons]
avatar_data[str(avatar.id)] = urls
def retry(func):
async def wrapper(*args, **kwargs):
for i in range(3):
@ -48,6 +34,21 @@ def retry(func):
return wrapper
@retry
async def get_single_avatar(url: str) -> None:
req = await client.get(url)
try:
avatar = YattaAvatar(**req.json()["data"])
except Exception as e:
print(f"{url} 获取星魂数据失败")
raise e
if len(avatar.eidolons) != 6:
print(f"{url} 获取星魂图片失败")
return
urls = [i.icon_url for i in avatar.eidolons]
avatar_data[str(avatar.id)] = urls
@retry
async def get_single_avatar_skill_icon(url: str, real_path: str) -> None:
req = await client.get(url)