mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
🐛 修复下载图标报错
This commit is contained in:
parent
10c98e6ba4
commit
1b625dcdef
@ -27,7 +27,7 @@ talent_color = [('#d5f2b6', '#6d993d'), ('#d5f2b6', '#6d993d'), ('#d5f2b6', '#6d
|
|||||||
|
|
||||||
|
|
||||||
async def draw_chara_card(info: Character):
|
async def draw_chara_card(info: Character):
|
||||||
img = await aiorequests.get_img(f'http://img.genshin.cherishmoon.fun/{info.name}', mode='RGBA')
|
img = await aiorequests.get_img(f'http://img.genshin.cherishmoon.fun/{info.name}', mode='RGBA', follow_redirects=True)
|
||||||
if img == 'No Such File':
|
if img == 'No Such File':
|
||||||
return '暂时没有这个角色的同人图哦~', None
|
return '暂时没有这个角色的同人图哦~', None
|
||||||
# 新建卡片
|
# 新建卡片
|
||||||
|
@ -96,7 +96,6 @@ class aiorequests:
|
|||||||
headers=headers,
|
headers=headers,
|
||||||
params=params,
|
params=params,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
follow_redirects=True,
|
|
||||||
**kwargs)
|
**kwargs)
|
||||||
# 不保存安柏计划的问号图标
|
# 不保存安柏计划的问号图标
|
||||||
if resp.headers.get('etag') == 'W/"6363798a-13c7"' or resp.headers.get(
|
if resp.headers.get('etag') == 'W/"6363798a-13c7"' or resp.headers.get(
|
||||||
@ -112,7 +111,6 @@ class aiorequests:
|
|||||||
headers=headers,
|
headers=headers,
|
||||||
params=params,
|
params=params,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
follow_redirects=True,
|
|
||||||
**kwargs)
|
**kwargs)
|
||||||
if resp.headers.get('etag') == 'W/"6363798a-13c7"' or resp.headers.get(
|
if resp.headers.get('etag') == 'W/"6363798a-13c7"' or resp.headers.get(
|
||||||
'content-md5') == 'JeG5b/z8SpViMmO/E9eayA==':
|
'content-md5') == 'JeG5b/z8SpViMmO/E9eayA==':
|
||||||
|
@ -58,6 +58,7 @@ def cache(ttl=datetime.timedelta(hours=1)):
|
|||||||
缓存装饰器
|
缓存装饰器
|
||||||
:param ttl: 过期时间
|
:param ttl: 过期时间
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def wrap(func):
|
def wrap(func):
|
||||||
cache_data = {}
|
cache_data = {}
|
||||||
|
|
||||||
@ -87,7 +88,9 @@ def cache(ttl=datetime.timedelta(hours=1)):
|
|||||||
async def check_resource():
|
async def check_resource():
|
||||||
logger.info('资源检查', '开始检查资源')
|
logger.info('资源检查', '开始检查资源')
|
||||||
try:
|
try:
|
||||||
resource_list = await aiorequests.get(f'{config.github_proxy}https://raw.githubusercontent.com/CMHopeSunshine/LittlePaimonRes/main/resources_list.json')
|
resource_list = await aiorequests.get(
|
||||||
|
f'{config.github_proxy}https://raw.githubusercontent.com/CMHopeSunshine/LittlePaimonRes/main/resources_list.json',
|
||||||
|
follow_redirects=True)
|
||||||
resource_list = resource_list.json()
|
resource_list = resource_list.json()
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.info('资源检查', '读取资源列表<r>失败</r>,请尝试更换<m>github资源地址</m>')
|
logger.info('资源检查', '读取资源列表<r>失败</r>,请尝试更换<m>github资源地址</m>')
|
||||||
@ -102,7 +105,8 @@ async def check_resource():
|
|||||||
file_path.unlink()
|
file_path.unlink()
|
||||||
flag = True
|
flag = True
|
||||||
try:
|
try:
|
||||||
await aiorequests.download(url=f'{config.github_proxy}https://raw.githubusercontent.com/CMHopeSunshine/LittlePaimonRes/main/{resource["path"]}',
|
await aiorequests.download(
|
||||||
|
url=f'{config.github_proxy}https://raw.githubusercontent.com/CMHopeSunshine/LittlePaimonRes/main/{resource["path"]}',
|
||||||
save_path=file_path, exclude_json=resource['path'].split('.')[-1] != 'json')
|
save_path=file_path, exclude_json=resource['path'].split('.')[-1] != 'json')
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user