From 1b625dcdeff49f6c67dab64d169658ad8e5831ab Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Thu, 8 Dec 2022 11:42:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=9B=BE=E6=A0=87=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/Paimon_Info/draw_character_card.py | 2 +- LittlePaimon/utils/requests.py | 2 -- LittlePaimon/utils/tool.py | 12 ++++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/LittlePaimon/plugins/Paimon_Info/draw_character_card.py b/LittlePaimon/plugins/Paimon_Info/draw_character_card.py index 4c6825e..f625f98 100644 --- a/LittlePaimon/plugins/Paimon_Info/draw_character_card.py +++ b/LittlePaimon/plugins/Paimon_Info/draw_character_card.py @@ -27,7 +27,7 @@ talent_color = [('#d5f2b6', '#6d993d'), ('#d5f2b6', '#6d993d'), ('#d5f2b6', '#6d 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': return '暂时没有这个角色的同人图哦~', None # 新建卡片 diff --git a/LittlePaimon/utils/requests.py b/LittlePaimon/utils/requests.py index cdfc78b..caa573d 100644 --- a/LittlePaimon/utils/requests.py +++ b/LittlePaimon/utils/requests.py @@ -96,7 +96,6 @@ class aiorequests: headers=headers, params=params, timeout=timeout, - follow_redirects=True, **kwargs) # 不保存安柏计划的问号图标 if resp.headers.get('etag') == 'W/"6363798a-13c7"' or resp.headers.get( @@ -112,7 +111,6 @@ class aiorequests: headers=headers, params=params, timeout=timeout, - follow_redirects=True, **kwargs) if resp.headers.get('etag') == 'W/"6363798a-13c7"' or resp.headers.get( 'content-md5') == 'JeG5b/z8SpViMmO/E9eayA==': diff --git a/LittlePaimon/utils/tool.py b/LittlePaimon/utils/tool.py index 0256e77..c5b913b 100644 --- a/LittlePaimon/utils/tool.py +++ b/LittlePaimon/utils/tool.py @@ -58,6 +58,7 @@ def cache(ttl=datetime.timedelta(hours=1)): 缓存装饰器 :param ttl: 过期时间 """ + def wrap(func): cache_data = {} @@ -87,7 +88,9 @@ def cache(ttl=datetime.timedelta(hours=1)): async def check_resource(): logger.info('资源检查', '开始检查资源') 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() except Exception: logger.info('资源检查', '读取资源列表失败,请尝试更换github资源地址') @@ -102,12 +105,13 @@ async def check_resource(): file_path.unlink() flag = True try: - 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') + 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') await asyncio.sleep(0.5) except Exception: logger.warning('资源检查', f'下载{resource["path"]}出错,请尝试更换github资源地址') if flag: logger.info('资源检查', '资源下载完成') else: - logger.info('资源检查', '资源完好,无需下载') \ No newline at end of file + logger.info('资源检查', '资源完好,无需下载')