From 72dbeb79cfd0a0bce943e95fd62485dd7e00e3c0 Mon Sep 17 00:00:00 2001
From: CMHopeSunshine <277073121@qq.com>
Date: Fri, 16 Dec 2022 20:02:00 +0800
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=9B=B4=E6=96=B0`=E6=B7=B1?=
=?UTF-8?q?=E6=B8=8A=E9=85=8D=E9=98=9F`=E7=89=88=E6=9C=AC=EF=BC=8C?=
=?UTF-8?q?=E5=87=8F=E5=B0=91`=E6=B7=B1=E6=B8=8A=E3=80=81=E6=AF=8F?=
=?UTF-8?q?=E6=97=A5=E6=9D=90=E6=96=99`=E5=9B=BE=E6=A0=87=E4=B8=A2?=
=?UTF-8?q?=E5=A4=B1=E7=9A=84=E5=8F=AF=E8=83=BD=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../plugins/Paimon_Abyss/youchuang/api.py | 2 +-
LittlePaimon/utils/requests.py | 17 +++++++++++------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/LittlePaimon/plugins/Paimon_Abyss/youchuang/api.py b/LittlePaimon/plugins/Paimon_Abyss/youchuang/api.py
index 4a5b29a..fefcbe0 100644
--- a/LittlePaimon/plugins/Paimon_Abyss/youchuang/api.py
+++ b/LittlePaimon/plugins/Paimon_Abyss/youchuang/api.py
@@ -10,7 +10,7 @@ BASE_API = 'https://www.youchuang.fun'
TEAM_RATE_API = f'{BASE_API}/gamerole/formationRate'
VERSION_API = 'https://api-cloudgame-static.mihoyo.com/hk4e_cg_cn/gamer/api/getFunctionShieldNew?client_type=1'
-VERSION = 3.2
+VERSION = 3.3
HEADERS = {
'Host': 'www.youchuang.fun',
'Referer': 'https://servicewechat.com/wxce4dbe0cb0f764b3/91/page-frame.html',
diff --git a/LittlePaimon/utils/requests.py b/LittlePaimon/utils/requests.py
index a51ad63..9fa2525 100644
--- a/LittlePaimon/utils/requests.py
+++ b/LittlePaimon/utils/requests.py
@@ -73,7 +73,7 @@ class aiorequests:
size: Optional[Union[Tuple[int, int], float]] = None,
mode: Optional[str] = None,
crop: Optional[Tuple[int, int, int, int]] = None,
- **kwargs) -> Union[str, Image.Image]:
+ **kwargs) -> Union[None, Image.Image]:
"""
说明:
httpx的get请求封装,获取图片
@@ -100,9 +100,11 @@ class aiorequests:
# 不保存安柏计划的问号图标
if resp.headers.get('etag') == 'W/"6363798a-13c7"' or resp.headers.get(
'content-md5') == 'JeG5b/z8SpViMmO/E9eayA==':
- save_path = False
+ # save_path = False
+ return None
if resp.headers.get('Content-Type') not in ['image/png', 'image/jpeg']:
- return 'No Such File'
+ # return 'No Such File'
+ return None
resp = resp.read()
img = Image.open(BytesIO(resp))
except SSLCertVerificationError:
@@ -114,9 +116,11 @@ class aiorequests:
**kwargs)
if resp.headers.get('etag') == 'W/"6363798a-13c7"' or resp.headers.get(
'content-md5') == 'JeG5b/z8SpViMmO/E9eayA==':
- save_path = False
+ # save_path = False
+ return None
if resp.headers.get('Content-Type') not in ['image/png', 'image/jpeg']:
- return 'No Such File'
+ # return 'No Such File'
+ return None
resp = resp.read()
img = Image.open(BytesIO(resp))
if size:
@@ -195,6 +199,7 @@ class aiorequests:
for url in urls:
with contextlib.suppress(Exception):
if url is not None:
- return await aiorequests.get_img(url=url, headers=headers, save_path=save_path, **kwargs)
+ if (img := await aiorequests.get_img(url=url, headers=headers, save_path=save_path, **kwargs)) is not None:
+ return img
logger.opt(colors=True).info(f'[资源检查]图标资源{name}下载失败')
return None