From bfd5e08aab23766986a477ca3954d00e1be448e6 Mon Sep 17 00:00:00 2001 From: KT Date: Tue, 13 Jun 2023 19:54:22 +0800 Subject: [PATCH] fix: Decompose space_info & add friend_count --- mihomo/models/player.py | 21 ++++++++++++++++----- pyproject.toml | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mihomo/models/player.py b/mihomo/models/player.py index 13ec9539b..330219a50 100644 --- a/mihomo/models/player.py +++ b/mihomo/models/player.py @@ -19,11 +19,11 @@ class ForgottenHall(BaseModel): """ memory: int = Field(..., alias="pre_maze_group_index") - """The progress of the memory""" + """The progress of the memory (pre_maze_group_index)""" memory_of_chaos_id: int = Field(..., alias="maze_group_id") - """The ID of the memory of chaos""" + """The ID of the memory of chaos (maze_group_id)""" memory_of_chaos: int = Field(..., alias="maze_group_index") - """The progress of the memory of chaos""" + """The progress of the memory of chaos (maze_group_index)""" class Player(BaseModel): @@ -35,6 +35,7 @@ class Player(BaseModel): - name (`str`): The player's nickname. - level (`int`): The player's Trailblaze level. - world_level (`int`): The player's Equilibrium level. + - friend_count (`int`): The number of friends. - avatar (`Avatar`): The player's profile picture. - signature (`str`): The player's bio. - is_display (`bool`): Is the player's profile display enabled. @@ -54,6 +55,8 @@ class Player(BaseModel): """Trailblaze level""" world_level: int """Equilibrium level""" + friend_count: int + """Number of friends""" avatar: Avatar """Profile picture""" signature: str @@ -62,12 +65,20 @@ class Player(BaseModel): """Is the player's profile display enabled.""" forgotten_hall: ForgottenHall | None = Field(None, alias="challenge_data") - """The progress of the Forgotten Hall""" + """The progress of the Forgotten Hall (challenge_data)""" simulated_universes: int = Field(0, alias="pass_area_progress") - """Number of simulated universes passed""" + """Number of simulated universes passed (pass_area_progress)""" light_cones: int = Field(0, alias="light_cone_count") """Number of light cones owned""" characters: int = Field(0, alias="avatar_count") """Number of characters owned""" achievements: int = Field(0, alias="achievement_count") """Number of achievements unlocked""" + + @root_validator(pre=True) + def decompose_space_info(cls, data): + if isinstance(data, dict): + space_info = data.get("space_info") + if isinstance(space_info, dict): + data.update(space_info) + return data diff --git a/pyproject.toml b/pyproject.toml index 0577fd545..2d49592c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "mihomo" -version = "1.1.3" +version = "1.1.4" authors = [ { name="KT", email="xns77477@gmail.com" }, ]