diff --git a/enkanetwork/model/equipments.py b/enkanetwork/model/equipments.py index ccf8778..58cceb2 100644 --- a/enkanetwork/model/equipments.py +++ b/enkanetwork/model/equipments.py @@ -59,7 +59,7 @@ class EquipmentsDetail(BaseModel): __pydantic_self__.icon = Assets.create_icon_path(data["icon"]) __pydantic_self__.artifact_type = EquipType(data["equipType"]).name # Sub Stats - for stats in data["reliquarySubstats"]: + for stats in data["reliquarySubstats"] if "reliquarySubstats" in data else []: __pydantic_self__.substats.append( EquipmentsStats.parse_obj(stats)) diff --git a/enkanetwork/model/players.py b/enkanetwork/model/players.py index 53e00f1..ee618a3 100644 --- a/enkanetwork/model/players.py +++ b/enkanetwork/model/players.py @@ -1,7 +1,7 @@ import logging from pydantic import BaseModel, Field -from typing import List, Any +from typing import List, Any, Union from ..assets import Assets @@ -17,19 +17,20 @@ class ProfilePicture(BaseModel): """ Custom add data """ - url: str = "" + url: Union[str, None] = None def __init__(__pydantic_self__, **data: Any) -> None: super().__init__(**data) # Get character LOGGER.debug("=== Avatar ===") - icon = Assets.character_icon(str(data["avatarId"])) + if "avatarId" in data: + icon = Assets.character_icon(str(data["avatarId"])) - if not icon: - return + if not icon: + return - __pydantic_self__.url = icon.icon + __pydantic_self__.url = icon.icon class showAvatar(BaseModel):