🐛 Fix post parse image extension in jpeg

This commit is contained in:
xtaodada 2024-07-20 20:01:59 +08:00
parent 945fcf5ee9
commit e211aa7305
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 4 additions and 3 deletions

View File

@ -97,8 +97,9 @@ class HyperionBase:
@staticmethod @staticmethod
async def download_image(client: "HyperionRequest", art_id: int, url: str, page: int = 0) -> List[ArtworkImage]: async def download_image(client: "HyperionRequest", art_id: int, url: str, page: int = 0) -> List[ArtworkImage]:
filename = os.path.basename(url) filename = os.path.basename(url)
_, file_extension = os.path.splitext(filename) _, _file_extension = os.path.splitext(filename)
is_image = bool(file_extension in ".jpg" or file_extension in ".png") file_extension = _file_extension.lower()
is_image = file_extension in ".jpg" or file_extension in ".jpeg" or file_extension in ".png"
response = await client.get( response = await client.get(
url, params=Hyperion.get_images_params(resize=2000) if is_image else None, de_json=False url, params=Hyperion.get_images_params(resize=2000) if is_image else None, de_json=False
) )

View File

@ -107,7 +107,7 @@ class PostInfo(BaseModel):
image_keys = {"cover_list", "image_list"} image_keys = {"cover_list", "image_list"}
for key in image_keys: for key in image_keys:
image_list.extend(_data_post.get(key, [])) image_list.extend(_data_post.get(key, []))
image_urls = [image["url"] for image in image_list] image_urls = list({image["url"] for image in image_list})
key1, key2 = ("video", "resolution") if hoyolab else ("vod_list", "resolutions") key1, key2 = ("video", "resolution") if hoyolab else ("vod_list", "resolutions")
vod_list = _data_post.get(key1, []) vod_list = _data_post.get(key1, [])
if not isinstance(vod_list, list): if not isinstance(vod_list, list):