From b01587cf266ea9d9afec487214140bb253327657 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sun, 7 Jan 2024 21:40:50 +0800 Subject: [PATCH] :bug: Fix AssetsCouldNotFound Error in calendar --- .../apihelper/client/components/calendar.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/apihelper/client/components/calendar.py b/modules/apihelper/client/components/calendar.py index a098375..1241af2 100644 --- a/modules/apihelper/client/components/calendar.py +++ b/modules/apihelper/client/components/calendar.py @@ -4,12 +4,13 @@ from typing import List, Tuple, Optional, Dict, Union, TYPE_CHECKING from httpx import AsyncClient +from core.dependence.assets import AssetsCouldNotFound from metadata.genshin import AVATAR_DATA from metadata.shortname import roleToId from modules.apihelper.client.components.remote import Remote from modules.apihelper.models.genshin.calendar import Date, FinalAct, ActEnum, ActDetail, ActTime, BirthChar from modules.wiki.character import Character - +from utils.log import logger if TYPE_CHECKING: from core.dependence.assets import AssetsService @@ -110,10 +111,6 @@ class Calendar: new_list_data[idx].append(ActDetail(**item)) time_map = {} time_map.update(await self.parse_official_content_date()) - req = await self.client.get(self.MIAO_API) - if req.status_code == 200: - miao_data = req.json() - time_map.update({key: ActTime(**value) for key, value in miao_data.get("data", {}).items()}) remote_data = await Remote.get_remote_calendar() if remote_data: time_map.update({key: ActTime(**value) for key, value in remote_data.get("data", {}).items()}) @@ -318,13 +315,16 @@ class Calendar: birthday_chars[str(date.month)][str(d)] = [] for c in char: character = await Character.get_by_name(c) - birthday_chars[str(date.month)][str(d)].append( - BirthChar( - name=c, - star=character.rarity, - icon=(await assets.avatar(roleToId(c)).icon()).as_uri(), + try: + birthday_chars[str(date.month)][str(d)].append( + BirthChar( + name=c, + star=character.rarity, + icon=(await assets.avatar(roleToId(c)).icon()).as_uri(), + ) ) - ) + except AssetsCouldNotFound: + logger.warning("角色 %s 图片素材未找到", c) return birthday_char_line, birthday_chars @staticmethod