diff --git a/mihomo/models/player.py b/mihomo/models/player.py index 330219a50..cf4022fd5 100644 --- a/mihomo/models/player.py +++ b/mihomo/models/player.py @@ -18,12 +18,12 @@ class ForgottenHall(BaseModel): - memory_of_chaos (`int`): The progress of the memory of chaos, or None if not applicable. """ - memory: int = Field(..., alias="pre_maze_group_index") - """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 (maze_group_id)""" - memory_of_chaos: int = Field(..., alias="maze_group_index") - """The progress of the memory of chaos (maze_group_index)""" + memory: int = Field(..., alias="level") + """The progress of the memory (level)""" + memory_of_chaos_id: int = Field(..., alias="chaos_id") + """The ID of the memory of chaos (chaos_id)""" + memory_of_chaos: int = Field(..., alias="chaos_level") + """The progress of the memory of chaos (chaos_level)""" class Player(BaseModel): @@ -64,10 +64,10 @@ class Player(BaseModel): is_display: bool """Is the player's profile display enabled.""" - forgotten_hall: ForgottenHall | None = Field(None, alias="challenge_data") - """The progress of the Forgotten Hall (challenge_data)""" - simulated_universes: int = Field(0, alias="pass_area_progress") - """Number of simulated universes passed (pass_area_progress)""" + forgotten_hall: ForgottenHall | None = Field(None, alias="memory_data") + """The progress of the Forgotten Hall (memory_data)""" + simulated_universes: int = Field(0, alias="universe_level") + """Number of simulated universes passed (universe_level)""" light_cones: int = Field(0, alias="light_cone_count") """Number of light cones owned""" characters: int = Field(0, alias="avatar_count") @@ -82,3 +82,16 @@ class Player(BaseModel): if isinstance(space_info, dict): data.update(space_info) return data + + @root_validator(pre=True) + def transform_for_backward_compatibility(cls, data): + if isinstance(data, dict): + if "pass_area_progress" in data and "universe_level" not in data: + data["universe_level"] = data["pass_area_progress"] + if "challenge_data" in data and "memory_data" not in data: + c: dict[str, int] = data["challenge_data"] + data["memory_data"] = {} + data["memory_data"]["level"] = c.get("pre_maze_group_index") + data["memory_data"]["chaos_id"] = c.get("maze_group_id") + data["memory_data"]["chaos_level"] = c.get("maze_group_index") + return data diff --git a/pyproject.toml b/pyproject.toml index a6d4ed8f8..aa566eea1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "mihomo" -version = "1.1.6" +version = "1.1.7" authors = [ { name="KT", email="xns77477@gmail.com" }, ]