🐛 Fix error order in post images

This commit is contained in:
xtaodada 2024-07-22 12:35:33 +08:00
parent e211aa7305
commit a3fa8c3819
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 10 additions and 2 deletions

View File

@ -104,7 +104,12 @@ class HyperionBase:
url, params=Hyperion.get_images_params(resize=2000) if is_image else None, de_json=False
)
return ArtworkImage.gen(
art_id=art_id, page=page, file_name=filename, file_extension=url.split(".")[-1], data=response.content
art_id=art_id,
page=page,
file_name=filename,
file_extension=url.split(".")[-1],
data=response.content,
url=url,
)
@abstractmethod

View File

@ -1,3 +1,5 @@
from collections import OrderedDict
import ujson
from datetime import datetime, timedelta
from enum import Enum
@ -26,6 +28,7 @@ class ArtworkImage(BaseModel):
file_name: Optional[str] = None
file_extension: Optional[str] = None
is_error: bool = False
url: str = ""
@property
def format(self) -> Optional[str]:
@ -107,7 +110,7 @@ class PostInfo(BaseModel):
image_keys = {"cover_list", "image_list"}
for key in image_keys:
image_list.extend(_data_post.get(key, []))
image_urls = list({image["url"] for image in image_list})
image_urls = list(OrderedDict.fromkeys([image["url"] for image in image_list]))
key1, key2 = ("video", "resolution") if hoyolab else ("vod_list", "resolutions")
vod_list = _data_post.get(key1, [])
if not isinstance(vod_list, list):