[
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.yml",
    "content": "name: Bug Report\ndescription: \"Report  Mihomo bug\"\ntitle: \"[Bug] \"\nlabels: [\"bug\"]\nbody:\n  - type: checkboxes\n    id: ensure\n    attributes:\n      label: Verify steps\n      description: Before submitting, please check all the options below to confirm that you have read and understood the following requirements; otherwise, this issue will be closed.\n      options:\n        - label: I have read the [documentation](https://wiki.metacubex.one/) and understand the meaning of all the configuration items I have written, rather than just piling up seemingly useful options or default values.\n          required: false\n        - label: I have carefully reviewed the [documentation](https://wiki.metacubex.one/) and have not resolved the issue.\n          required: false\n        - label: I have searched the [Issue Tracker](……/) for the issue I want to raise and did not find it.\n          required: false\n        - label: I am a non-Chinese user.\n          required: false\n        - label: I have tested with the latest Alpha branch version, and the issue still persists.\n          required: true\n        - label: I have provided the server and client configuration files and processes that can reproduce the issue locally, rather than a sanitized complex client configuration file.\n          required: true\n        - label: I provided the simplest configuration that can be used to reproduce the errors in my report, rather than relying on remote servers or piling on a lot of unnecessary configurations for reproduction.\n          required: true\n        - label: I have provided complete logs, rather than just the parts I think are useful out of confidence in my own intelligence.\n          required: true\n        - label: I have directly reproduced the error using the Mihomo command-line program, rather than using other tools or scripts.\n          required: true\n\n  - type: dropdown\n    attributes:\n      label: Operating System\n      description: \"Please provide the type of operating system.\"\n      multiple: true\n      options:\n        - MacOS\n        - Windows\n        - Linux\n        - OpenBSD/FreeBSD\n        - Android\n  - type: input\n    attributes:\n      label: System Version\n      description: \"Please provide the version of the operating system where the issue occurred.\"\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      label: Mihomo Version\n      description: \"Provide the output of the `mihomo -v` command.\"\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      render: yaml\n      label: Configuration File\n      description: |-\n        Please attach the Mihomo configuration file below.\n        Make sure there is no sensitive information in the configuration file (such as server addresses, passwords, ports, etc.)\n        Also, ensure that the configuration file can reproduce the error using the Mihomo command-line program locally (if it's a proxy protocol issue, make sure the local server can be used for reproduction).\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      label: Description\n      description: \"Please provide a detailed description of the error.\"\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      label: Reproduction Steps\n      description: \"Please provide the steps to reproduce the error.\"\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      label: Logs\n      description: \"Attach the running logs of Mihomo Core below, with `log-level` set to `DEBUG`.\"\n      render: shell"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report_zh.yml",
    "content": "name: 错误反馈\ndescription: \"提交 Mihomo 漏洞\"\ntitle: \"[Bug] \"\nlabels: [\"bug\"]\nbody:\n  - type: checkboxes\n    id: ensure\n    attributes:\n      label: 验证步骤\n      description: 在提交之前，请勾选以下选项以证明您已经阅读并理解了以下要求，否则该 issue 将被关闭。\n      options:\n        - label: 我已经阅读了 [文档](https://wiki.metacubex.one/)，了解所有我编写的配置文件项的含义，而不是大量堆砌看似有用的选项或默认值。\n          required: false\n        - label: 我仔细看过 [文档](https://wiki.metacubex.one/) 并未解决问题\n          required: false\n        - label: 我已在 [Issue Tracker](……/) 中寻找过我要提出的问题，并且没有找到\n          required: false\n        - label: 我是中文用户，而非其他语言用户\n          required: false\n        - label: 我已经使用最新的 Alpha 分支版本测试过，问题依旧存在\n          required: true\n        - label: 我提供了可以在本地重现该问题的服务器、客户端配置文件与流程，而不是一个脱敏的复杂客户端配置文件。\n          required: true\n        - label: 我提供了可用于重现我报告的错误的最简配置，而不是依赖远程服务器或者堆砌大量对于复现无用的配置等。\n          required: true\n        - label: 我提供了完整的日志，而不是出于对自身智力的自信而仅提供了部分认为有用的部分。\n          required: true\n        - label: 我直接使用 Mihomo 命令行程序重现了错误，而不是使用其他工具或脚本。\n          required: true\n\n  - type: dropdown\n    attributes:\n      label: 操作系统\n      description: 请提供操作系统类型\n      multiple: true\n      options:\n        - MacOS\n        - Windows\n        - Linux\n        - OpenBSD/FreeBSD\n        - Android\n  - type: input\n    attributes:\n      label: 系统版本\n      description: 请提供出现问题的操作系统版本\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      label: Mihomo 版本\n      description: 提供 `mihomo -v` 命令的输出\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      render: yaml\n      label: 配置文件\n      description: |-\n        在下方附上 Mihomo 配置文件\n        请确保配置文件中没有敏感信息（比如：服务器地址，密码，端口等）\n        以及确保可以在本地（如果是代理协议问题，请确保本地服务器可用于复现）使用 Mihomo 原始命令行程序重现错误的配置文件\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      label: 描述\n      description: 请提供错误的详细描述。\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      label: 重现方式\n      description: 请提供重现错误的步骤\n    validations:\n      required: true\n  - type: textarea\n    attributes:\n      label: 日志\n      description: 在下方附上 Mihomo Core 的运行日志，`log-level` 使用 `DEBUG`\n      render: shell"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "content": "blank_issues_enabled: false\ncontact_links:\n  - name: mihomo Community Support\n    url: https://github.com/MetaCubeX/mihomo/discussions\n    about: Please ask and answer questions about mihomo here.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.yml",
    "content": "name: Feature Request\ndescription: Suggest improvements for this project\ntitle: \"[Feature] \"\nlabels: [\"enhancement\"]\nbody:\n  - type: checkboxes\n    id: ensure\n    attributes:\n      label: Verification Steps\n      description: Before submitting, please check the following options to confirm that you have read and understood the requirements below; otherwise, this issue will be closed.\n      options:\n        - label: I have read the [documentation](https://wiki.metacubex.one/) and confirmed that this feature is not implemented\n          required: false\n        - label: I have searched for the feature request I want to propose in the [Issue Tracker](……/) and did not find it\n          required: false\n        - label: I am a non-Chinese user.\n          required: false\n  - type: textarea\n    attributes:\n      label: Description\n      description: Please provide a detailed description of the feature, rather than vague statements.\n    validations:\n      required: true"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request_zh.yml",
    "content": "name: 功能请求\ndescription: 为该项目提出建议\ntitle: \"[Feature] \"\nlabels: [\"enhancement\"]\nbody:\n  - type: checkboxes\n    id: ensure\n    attributes:\n      label: 验证步骤\n      description: 在提交之前，请勾选以下选项以证明您已经阅读并理解了以下要求，否则该 issue 将被关闭。\n      options:\n        - label: 我已经阅读了 [文档](https://wiki.metacubex.one/)，确认了该功能没有实现\n          required: false\n        - label: 我已在 [Issue Tracker](……/) 中寻找过我要提出的功能请求，并且没有找到\n          required: false\n        - label: 我是中文用户，而非其他语言用户\n          required: false\n  - type: textarea\n    attributes:\n      label: 描述\n      description: 请提供对于该功能的详细描述，而不是莫名其妙的话术。\n    validations:\n      required: true"
  },
  {
    "path": ".github/workflows/Delete.yml",
    "content": "name: Delete old workflow\r\non:\r\n  workflow_dispatch:\r\n  schedule:\r\n    - cron: '0 0 * * 0'\r\n# Run monthly, at 00:00 on the 1st day of month.\r\n\r\njobs:\r\n  del_runs:\r\n    runs-on: ubuntu-latest\r\n    steps:\r\n      - name: Delete workflow runs\r\n        uses: GitRML/delete-workflow-runs@main\r\n        with:\r\n          token: ${{ secrets.AUTH_PAT }}\r\n          repository: ${{ github.repository }}\r\n          retain_days: 30"
  },
  {
    "path": ".github/workflows/build.yml",
    "content": "name: Build\non:\n  workflow_dispatch:\n    inputs:\n      version:\n        description: \"Tag version to release\"\n        required: true\n\npermissions:\n  contents: write\n  packages: write\n\njobs:\n  release_archive:\n    runs-on: ubuntu-latest\n    if: github.repository == 'KT-Yeh/mihomo'\n\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v3\n        with:\n          submodules: true\n\n      - name: Archive Release\n        uses: thedoctor0/zip-release@0.7.1\n        with:\n          type: zip\n          filename: 'mihomo_${{ github.ref_name }}.zip'\n          exclusions: '*.git*'\n\n      - name: Release\n        uses: softprops/action-gh-release@v1\n        with:\n          generate_release_notes: true\n          files: 'mihomo_${{ github.ref_name }}.zip'"
  },
  {
    "path": ".gitignore",
    "content": "__pycache__\nvenv\nbuild\nmihomo.egg-info\n*.ipynb"
  },
  {
    "path": "LICENSE",
    "content": "Copyright 2023 KT\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# mihomo\nA simple python pydantic model (type hint and autocompletion support) for Honkai: Star Rail parsed data from the Mihomo API.\n\nAPI url: https://api.mihomo.me/sr_info_parsed/{UID}?lang={LANG}\n\n## Installation\n```\npip install -U git+https://github.com/KT-Yeh/mihomo.git\n```\n\n## Usage\n\n### Basic\nThere are two parsed data formats:\n- V1:\n  - URL: https://api.mihomo.me/sr_info_parsed/800333171?lang=en&version=v1\n  - Fetching: use `client.fetch_user_v1(800333171)`\n  - Data model: `mihomo.models.v1.StarrailInfoParsedV1`\n  - All models defined in `mihomo/models/v1` directory.\n- V2: \n  - URL: https://api.mihomo.me/sr_info_parsed/800333171?lang=en\n  - Fetching: use `client.fetch_user(800333171)`\n  - Data model: `mihomo.models.StarrailInfoParsed`\n  - All models defined in `mihomo/models` directory.\n\nIf you don't want to use `client.get_icon_url` to get the image url everytime, you can use `client.fetch_user(800333171, replace_icon_name_with_url=True)` to get the parsed data with asset urls.\n\n### Example\n```py\nimport asyncio\n\nfrom mihomo import Language, MihomoAPI\nfrom mihomo.models import StarrailInfoParsed\nfrom mihomo.models.v1 import StarrailInfoParsedV1\n\nclient = MihomoAPI(language=Language.EN)\n\n\nasync def v1():\n    data: StarrailInfoParsedV1 = await client.fetch_user_v1(800333171)\n\n    print(f\"Name: {data.player.name}\")\n    print(f\"Level: {data.player.level}\")\n    print(f\"Signature: {data.player.signature}\")\n    print(f\"Achievements: {data.player_details.achievements}\")\n    print(f\"Characters count: {data.player_details.characters}\")\n    print(f\"Profile picture url: {client.get_icon_url(data.player.icon)}\")\n    for character in data.characters:\n        print(\"-----------\")\n        print(f\"Name: {character.name}\")\n        print(f\"Rarity: {character.rarity}\")\n        print(f\"Level: {character.level}\")\n        print(f\"Avatar url: {client.get_icon_url(character.icon)}\")\n        print(f\"Preview url: {client.get_icon_url(character.preview)}\")\n        print(f\"Portrait url: {client.get_icon_url(character.portrait)}\")\n\n\nasync def v2():\n    data: StarrailInfoParsed = await client.fetch_user(800333171, replace_icon_name_with_url=True)\n\n    print(f\"Name: {data.player.name}\")\n    print(f\"Level: {data.player.level}\")\n    print(f\"Signature: {data.player.signature}\")\n    print(f\"Profile picture url: {data.player.avatar.icon}\")\n    for character in data.characters:\n        print(\"-----------\")\n        print(f\"Name: {character.name}\")\n        print(f\"Rarity: {character.rarity}\")\n        print(f\"Portrait url: {character.portrait}\")\n\nasyncio.run(v1())\nasyncio.run(v2())\n```\n\n### Tools\n`from mihomo import tools`\n#### Remove Duplicate Character\n```py\n    data = await client.fetch_user(800333171)\n    data = tools.remove_duplicate_character(data)\n```\n\n#### Merge Character Data\n```py\n    old_data = await client.fetch_user(800333171)\n\n    # Change characters in game and wait for the API to refresh\n    # ...\n\n    new_data = await client.fetch_user(800333171)\n    data = tools.merge_character_data(new_data, old_data)\n```\n\n### Data Persistence\nTake pickle and json as an example\n```py\nimport pickle\nimport zlib\nfrom mihomo import MihomoAPI, Language, StarrailInfoParsed\n\nclient = MihomoAPI(language=Language.EN)\ndata = await client.fetch_user(800333171)\n\n# Save\npickle_data = zlib.compress(pickle.dumps(data))\nprint(len(pickle_data))\njson_data = data.json(by_alias=True, ensure_ascii=False)\nprint(len(json_data))\n\n# Load\ndata_from_pickle = pickle.loads(zlib.decompress(pickle_data))\ndata_from_json = StarrailInfoParsed.parse_raw(json_data)\nprint(type(data_from_pickle))\nprint(type(data_from_json))\n```\n"
  },
  {
    "path": "examples/basic.py",
    "content": "import asyncio\n\nfrom mihomo import Language, MihomoAPI\nfrom mihomo.models import StarrailInfoParsed\nfrom mihomo.models.v1 import StarrailInfoParsedV1\n\nclient = MihomoAPI(language=Language.EN)\n\n\nasync def v1():\n    data: StarrailInfoParsedV1 = await client.fetch_user_v1(800333171)\n\n    print(f\"Name: {data.player.name}\")\n    print(f\"Level: {data.player.level}\")\n    print(f\"Signature: {data.player.signature}\")\n    print(f\"Achievements: {data.player_details.achievements}\")\n    print(f\"Characters count: {data.player_details.characters}\")\n    print(f\"Profile picture url: {client.get_icon_url(data.player.icon)}\")\n    for character in data.characters:\n        print(\"-----------\")\n        print(f\"Name: {character.name}\")\n        print(f\"Rarity: {character.rarity}\")\n        print(f\"Level: {character.level}\")\n        print(f\"Avatar url: {client.get_icon_url(character.icon)}\")\n        print(f\"Preview url: {client.get_icon_url(character.preview)}\")\n        print(f\"Portrait url: {client.get_icon_url(character.portrait)}\")\n\n\nasync def v2():\n    data: StarrailInfoParsed = await client.fetch_user(800333171, replace_icon_name_with_url=True)\n\n    print(f\"Name: {data.player.name}\")\n    print(f\"Level: {data.player.level}\")\n    print(f\"Signature: {data.player.signature}\")\n    print(f\"Profile picture url: {data.player.avatar.icon}\")\n    for character in data.characters:\n        print(\"-----------\")\n        print(f\"Name: {character.name}\")\n        print(f\"Rarity: {character.rarity}\")\n        print(f\"Portrait url: {character.portrait}\")\n\n\nasyncio.run(v1())\nasyncio.run(v2())\n"
  },
  {
    "path": "examples/data_persistence.py",
    "content": "import asyncio\nimport pickle\nimport zlib\n\nfrom mihomo import Language, MihomoAPI, StarrailInfoParsed\n\n\nasync def main():\n    client = MihomoAPI(language=Language.EN)\n    data = await client.fetch_user(800333171)\n\n    # Save\n    pickle_data = zlib.compress(pickle.dumps(data))\n    print(len(pickle_data))\n    json_data = data.json(by_alias=True, ensure_ascii=False)\n    print(len(json_data))\n\n    # Load\n    data_from_pickle = pickle.loads(zlib.decompress(pickle_data))\n    data_from_json = StarrailInfoParsed.parse_raw(json_data)\n    print(type(data_from_pickle))\n    print(type(data_from_json))\n\n\nasyncio.run(main())\n"
  },
  {
    "path": "examples/merge_data.py",
    "content": "import asyncio\n\nfrom mihomo import Language, MihomoAPI, tools\n\n\nasync def main():\n    client = MihomoAPI(language=Language.EN)\n    old_data = await client.fetch_user(800333171)\n\n    # Change characters in game and wait for the API to refresh\n    # ...\n\n    new_data = await client.fetch_user(800333171)\n    data = tools.merge_character_data(new_data, old_data)\n\n    print(data)\n\n\nasyncio.run(main())\n"
  },
  {
    "path": "mihomo/__init__.py",
    "content": "from . import tools\nfrom .client import *\nfrom .errors import *\nfrom .models import *\n"
  },
  {
    "path": "mihomo/client.py",
    "content": "import typing\nfrom enum import Enum\n\nimport aiohttp\n\nfrom . import tools\nfrom .errors import HttpRequestError, InvalidParams, UserNotFound\nfrom .models import StarrailInfoParsed\nfrom .models.v1 import StarrailInfoParsedV1\n\n\nclass Language(Enum):\n    CHT = \"cht\"\n    CHS = \"cn\"\n    DE = \"de\"\n    EN = \"en\"\n    ES = \"es\"\n    FR = \"fr\"\n    ID = \"id\"\n    JP = \"jp\"\n    KR = \"kr\"\n    PT = \"pt\"\n    RU = \"ru\"\n    TH = \"th\"\n    VI = \"vi\"\n\n\nclass MihomoAPI:\n    \"\"\"\n    Represents an client for Mihomo API.\n\n    Args:\n        language (Language, optional):\n            The language to use for API responses.Defaults to Language.CHT.\n\n    Attributes:\n        - BASE_URL (str): The base URL of the API.\n        - ASSET_URL (str): The base URL for the asset files.\n\n    \"\"\"\n\n    BASE_URL: typing.Final[str] = \"https://api.mihomo.me/sr_info_parsed\"\n    ASSET_URL: typing.Final[\n        str\n    ] = \"https://raw.githubusercontent.com/Mar-7th/StarRailRes/master\"\n\n    def __init__(self, language: Language = Language.CHT):\n        self.lang = language\n\n    async def request(\n        self,\n        uid: int | str,\n        language: Language,\n        *,\n        params: dict[str, str] = {},\n    ) -> typing.Any:\n        \"\"\"\n        Makes an HTTP request to the API.\n\n        Args:\n            - uid (int | str): The user ID.\n            - language (Language): The language to use for the API response.\n\n        Returns:\n            typing.Any: The response from the API.\n\n        Raises:\n            HttpRequestError: If the HTTP request fails.\n            InvalidParams: If the API request contains invalid parameters.\n            UserNotFound: If the requested user is not found.\n\n        \"\"\"\n        url = self.BASE_URL + \"/\" + str(uid)\n        params.update({\"lang\": language.value})\n\n        async with aiohttp.ClientSession() as session:\n            async with session.get(url, params=params) as response:\n                match response.status:\n                    case 200:\n                        return await response.json(encoding=\"utf-8\")\n                    case 400:\n                        try:\n                            data = await response.json(encoding=\"utf-8\")\n                        except:\n                            raise InvalidParams()\n                        else:\n                            if isinstance(data, dict) and (\n                                detail := data.get(\"detail\")\n                            ):\n                                raise InvalidParams(detail)\n                            raise InvalidParams()\n                    case 404:\n                        raise UserNotFound()\n                    case _:\n                        raise HttpRequestError(response.status, str(response.reason))\n\n    async def fetch_user(\n        self,\n        uid: int,\n        *,\n        replace_icon_name_with_url: bool = False,\n    ) -> StarrailInfoParsed:\n        \"\"\"\n        Fetches user data from the API.\n\n        Args:\n            - uid (`int`): The user ID.\n            - replace_icon_name_with_url (`bool`): Whether to replace icon names with asset URLs.\n\n        Returns:\n            StarrailInfoParsed: The parsed user data from mihomo API.\n\n        \"\"\"\n        data = await self.request(uid, self.lang)\n        if replace_icon_name_with_url is True:\n            data = tools.replace_icon_name_with_url(data)\n        data = StarrailInfoParsed.parse_obj(data)\n        return data\n\n    async def fetch_user_v1(\n        self,\n        uid: int,\n        *,\n        replace_icon_name_with_url: bool = False,\n    ) -> StarrailInfoParsedV1:\n        \"\"\"\n        Fetches user data from the API using version 1 format.\n\n        Args:\n            - uid (`int`): The user ID.\n            - replace_icon_name_with_url (`bool`): Whether to replace icon names with asset URLs.\n\n        Returns:\n            StarrailInfoParsedV1: The parsed user data from the Mihomo API (version 1).\n\n        \"\"\"\n        data = await self.request(uid, self.lang, params={\"version\": \"v1\"})\n        data = tools.remove_empty_dict(data)\n        if replace_icon_name_with_url is True:\n            data = tools.replace_icon_name_with_url(data)\n        data = StarrailInfoParsedV1.parse_obj(data)\n        data = tools.replace_trailblazer_name(data)\n        return data\n\n    def get_icon_url(self, icon: str) -> str:\n        \"\"\"\n        Gets the asset url for the given icon.\n\n        Args:\n            icon (str): The icon name.\n\n        Returns:\n            str: The asset url for the icon.\n\n        \"\"\"\n        return self.ASSET_URL + \"/\" + icon\n"
  },
  {
    "path": "mihomo/errors.py",
    "content": "class BaseException(Exception):\n    \"\"\"Base exception class.\"\"\"\n\n    message: str = \"\"\n\n    def __init__(self, message: str | None = None, *args: object) -> None:\n        if message is not None:\n            self.message = message\n        super().__init__(self.message, *args)\n\n\nclass HttpRequestError(BaseException):\n    \"\"\"Exception raised when an HTTP request fails.\"\"\"\n\n    status: int = 0\n    reason: str = \"\"\n\n    def __init__(\n        self,\n        status: int,\n        reason: str,\n        message: str | None = None,\n        *args: object,\n    ) -> None:\n        if not message:\n            message = f\"[{status}] {reason}\"\n        self.status = status\n        self.reason = reason\n        self.message = message\n        super().__init__(message, *args)\n\n\nclass UserNotFound(BaseException):\n    \"\"\"Exception raised when a user is not found.\"\"\"\n\n    message = \"User not found.\"\n\n\nclass InvalidParams(BaseException):\n    \"\"\"Exception raised when invalid parameters are provided.\"\"\"\n\n    message: str = \"Invalid parameters\"\n"
  },
  {
    "path": "mihomo/models/__init__.py",
    "content": "from .base import *\nfrom .character import *\nfrom .combat import *\nfrom .equipment import *\nfrom .player import *\nfrom .stat import *\n"
  },
  {
    "path": "mihomo/models/base.py",
    "content": "from pydantic import BaseModel, Field\n\nfrom .character import Character\nfrom .player import Player\n\n\nclass StarrailInfoParsed(BaseModel):\n    \"\"\"\n    Mihomo parsed data\n\n    Attributes:\n        - player (`Player`): The player's info.\n        - characters (list[`Character`]): The list of characters.\n    \"\"\"\n\n    player: Player\n    \"\"\"Player's basic info\"\"\"\n    characters: list[Character]\n    \"\"\"The list of characters\"\"\"\n"
  },
  {
    "path": "mihomo/models/character.py",
    "content": "from typing import Any\n\nfrom pydantic import BaseModel, Field, root_validator\n\nfrom .combat import Element, Path, Trace, TraceTreeNode\nfrom .equipment import LightCone, Relic, RelicSet\nfrom .stat import Attribute, Property\n\n\nclass Character(BaseModel):\n    \"\"\"\n    Represents a character.\n\n    Attributes:\n    - Basic info:\n        - id (`str`): The character's ID.\n        - name (`str`): The character's name.\n        - rarity (`int`): The character's rarity.\n        - level (`int`): The character's current level.\n        - max_level (`int`): The maximum character level according to the current ascension phase.\n        - ascension (`int`): Ascension phase.\n        - eidolon (`int`): The character's eidolon rank.\n        - eidolon_icons (list[`str`]): The list of character's eiodolon icons.\n    - Image\n        - icon (`str`): The character avatar image\n        - preview (`str`): The character's preview image.\n        - portrait (`str`): The character's portrait image.\n    - Combat\n        - path (`Path`): The character's path.\n        - element (`Element`): The character's element.\n        - traces (list[`Trace`]): The list of character's skill traces.\n        - trace_tree (list[`TraceTreeNode]): The list of the character's skill traces.\n    - Equipment\n        - light_cone (`LightCone` | `None`): The character's light cone (weapon), or None if not applicable.\n        - relics (list[`Relic`] | `None`): The list of character's relics, or None if not applicable.\n        - relic_set (list[`RelicSet`] | `None`): The list of character's relic sets, or None if not applicable.\n        - stats (list[`Stat`]): The list of character's stats.\n    - Stats\n        - attributes (list[`Attribute`]): The list of character's attributes.\n        - additions (list[`Attribute`]): The list of character's additional attributes.\n        - properties (list[`Property`]): The list of character's properties.\n    \"\"\"\n\n    id: str\n    \"\"\"Character's ID\"\"\"\n    name: str\n    \"\"\"Character's name\"\"\"\n    rarity: int\n    \"\"\"Character's rarity\"\"\"\n    level: int\n    \"\"\"Character's level\"\"\"\n    ascension: int = Field(..., alias=\"promotion\")\n    \"\"\"Ascension phase\"\"\"\n    eidolon: int = Field(..., alias=\"rank\")\n    \"\"\"Character's eidolon rank\"\"\"\n    eidolon_icons: list[str] = Field([], alias=\"rank_icons\")\n    \"\"\"The list of character's eiodolon icons\"\"\"\n\n    icon: str\n    \"\"\"Character avatar image\"\"\"\n    preview: str\n    \"\"\"Character preview image\"\"\"\n    portrait: str\n    \"\"\"Character portrait image\"\"\"\n\n    path: Path\n    \"\"\"Character's path\"\"\"\n    element: Element\n    \"\"\"Character's element\"\"\"\n    traces: list[Trace] = Field(..., alias=\"skills\")\n    \"\"\"The list of character's skill traces\"\"\"\n    trace_tree: list[TraceTreeNode] = Field([], alias=\"skill_trees\")\n    \"\"\"The list of the character's skill traces\"\"\"\n\n    light_cone: LightCone | None = None\n    \"\"\"Character's light cone (weapon)\"\"\"\n    relics: list[Relic] = []\n    \"\"\"The list of character's relics\"\"\"\n    relic_sets: list[RelicSet] = []\n    \"\"\"The list of character's relic sets\"\"\"\n\n    attributes: list[Attribute]\n    \"\"\"The list of character's attributes\"\"\"\n    additions: list[Attribute]\n    \"\"\"The list of character's additional attributes\"\"\"\n    properties: list[Property]\n    \"\"\"The list of character's properties\"\"\"\n\n    @property\n    def max_level(self) -> int:\n        \"\"\"The maximum character level according to the current ascension phase\"\"\"\n        return 20 + 10 * self.ascension\n"
  },
  {
    "path": "mihomo/models/combat.py",
    "content": "from pydantic import BaseModel\n\n\nclass Element(BaseModel):\n    \"\"\"\n    Represents an element.\n\n    Attributes:\n        - id (`str`): The ID of the element.\n        - name (`str`): The name of the element.\n        - color (`str`): The color of the element.\n        - icon (`str`): The element icon.\n    \"\"\"\n\n    id: str\n    \"\"\"The ID of the element\"\"\"\n    name: str\n    \"\"\"The name of the element\"\"\"\n    color: str\n    \"\"\"The color of the element\"\"\"\n    icon: str\n    \"\"\"The element icon\"\"\"\n\n\nclass Path(BaseModel):\n    \"\"\"\n    Paths are congregations of Imaginary energy, with which the ideals harmonize.\n\n    Attributes:\n        - id (`str`): The ID of the path.\n        - name (`str`): The name of the path.\n        - icon (`str`): The path icon.\n    \"\"\"\n\n    id: str\n    \"\"\"The ID of the path\"\"\"\n    name: str\n    \"\"\"The name of the path\"\"\"\n    icon: str\n    \"\"\"The path icon\"\"\"\n\n\nclass Trace(BaseModel):\n    \"\"\"\n    Represents a character's skill trace.\n\n    Attributes:\n        - id (`int`): The ID of the trace.\n        - name (`str`): The name of the trace.\n        - level (`int`): The current level of the trace.\n        - max_level (`int`): The maximum level of the trace.\n        - element (`Element` | None): The element of the trace, or None if not applicable.\n        - type (`str`): The type of the trace.\n        - type_text (`str`): The type text of the trace.\n        - effect (`str`): The effect of the trace.\n        - effect_text (`str`): The effect text of the trace.\n        - simple_desc (`str`): The simple description of the trace.\n        - desc (`str`): The detailed description of the trace.\n        - icon (`str`): The trace icon.\n    \"\"\"\n\n    id: int\n    \"\"\"The ID of the trace\"\"\"\n    name: str\n    \"\"\"The name of the trace\"\"\"\n    level: int\n    \"\"\"The current level of the trace\"\"\"\n    max_level: int\n    \"\"\"The maximum level of the trace\"\"\"\n    element: Element | None = None\n    \"\"\"The element of the trace\"\"\"\n    type: str\n    \"\"\"The type of the trace\"\"\"\n    type_text: str\n    \"\"\"The type text of the trace\"\"\"\n    effect: str\n    \"\"\"The effect of the trace\"\"\"\n    effect_text: str\n    \"\"\"The effect text of the trace\"\"\"\n    simple_desc: str\n    \"\"\"The simple description of the trace\"\"\"\n    desc: str\n    \"\"\"The detailed description of the trace\"\"\"\n    icon: str\n    \"\"\"The trace icon\"\"\"\n\n\nclass TraceTreeNode(BaseModel):\n    \"\"\"\n    Represents a node in the trace skill tree of a character.\n\n    Attributes:\n    - id (`int`): The ID of the trace.\n    - level (`int`): The level of the trace.\n    - max_level (`int`): The max level of the trace.\n    - icon (`str`): The icon of the trace.\n    - anchor (`str`): The position of the trace tree node.\n    - parent (`int` | `None`): The preceding node id of trace.\n    \"\"\"\n\n    id: int\n    \"\"\"The ID of the trace\"\"\"\n    level: int\n    \"\"\"The level of the trace\"\"\"\n    max_level: int\n    \"\"\"The max level of the trace\"\"\"\n    icon: str\n    \"\"\"The icon of the trace\"\"\"\n    anchor: str\n    \"\"\"The position of the trace tree node\"\"\"\n    parent: int | None = None\n    \"\"\"The preceding node id of trace\"\"\"\n"
  },
  {
    "path": "mihomo/models/equipment.py",
    "content": "from pydantic import BaseModel, Field\n\nfrom .combat import Path\nfrom .stat import Attribute, MainAffix, Property, SubAffix\n\n\nclass LightCone(BaseModel):\n    \"\"\"\n    Represents a light cone (weapon).\n\n    Attributes:\n        - id (`int`): The ID of the light cone.\n        - name (`str`): The name of the light cone.\n        - rarity (`int`): The rarity of the light cone.\n        - superimpose (`int`): The superimpose rank of the light cone.\n        - level (`int`): The current level of the light cone.\n        - max_level (`int`): The maximum light cone level according to the current ascension phase.\n        - ascension (`int`): The ascension phase of the light cone.\n        - icon (`str`): The light cone icon image.\n        - preview (`str`): The light cone preview image.\n        - portrait (`str`): The light cone portrait image.\n        - path (`Path`): The path of the light cone.\n        - attributes (list[`Attribute`]): The list of attributes of the light cone.\n        - properties (list[`Property`]): The list of properties of the light cone.\n    \"\"\"\n\n    id: int\n    \"\"\"The ID of the light cone\"\"\"\n    name: str\n    \"\"\"The name of the light cone\"\"\"\n    rarity: int\n    \"\"\"The rarity of the light cone\"\"\"\n    superimpose: int = Field(..., alias=\"rank\")\n    \"\"\"The superimpose rank of the light cone\"\"\"\n    level: int\n    \"\"\"The level of the light cone\"\"\"\n    ascension: int = Field(..., alias=\"promotion\")\n    \"\"\"The ascension phase of the light cone\"\"\"\n    icon: str\n    \"\"\"The light cone icon image\"\"\"\n    preview: str\n    \"\"\"The light cone preview image\"\"\"\n    portrait: str\n    \"\"\"The light cone portrait image\"\"\"\n    path: Path\n    \"\"\"The path of the light cone\"\"\"\n    attributes: list[Attribute]\n    \"\"\"The list of attributes of the light cone\"\"\"\n    properties: list[Property]\n    \"\"\"The list of properties of the light cone\"\"\"\n\n    @property\n    def max_level(self) -> int:\n        \"\"\"The maximum light cone level according to the current ascension phase\"\"\"\n        return 20 + 10 * self.ascension\n\n\nclass Relic(BaseModel):\n    \"\"\"\n    Represents a relic.\n\n    Attributes:\n        - id (`int`): The ID of the relic.\n        - name (`str`): The name of the relic.\n        - set_id (`int`): The ID of the relic set.\n        - set_name (`str`): The name of the relic set.\n        - rarity (`int`): The rarity of the relic.\n        - level (`int`): The level of the relic.\n        - main_property (`MainAffix`): The main affix of the relic.\n        - sub_property (list[`SubAffix`]): The list of sub-affixes of the relic.\n        - icon (`str`): The relic icon.\n    \"\"\"\n\n    id: int\n    \"\"\"The ID of the relic\"\"\"\n    name: str\n    \"\"\"The name of the relic\"\"\"\n    set_id: int\n    \"\"\"The ID of the relic set\"\"\"\n    set_name: str\n    \"\"\"The name of the relic set\"\"\"\n    rarity: int\n    \"\"\"The rarity of the relic\"\"\"\n    level: int\n    \"\"\"The level of the relic\"\"\"\n    main_affix: MainAffix\n    \"\"\"The main affix of the relic\"\"\"\n    sub_affixes: list[SubAffix] = Field([], alias=\"sub_affix\")\n    \"\"\"The list of sub-affixes of the relic\"\"\"\n    icon: str\n    \"\"\"The relic icon\"\"\"\n\n\nclass RelicSet(BaseModel):\n    \"\"\"\n    Represents a set of relics.\n\n    Attributes:\n        - id (`int`): The ID of the relic set.\n        - name (`str`): The name of the relic set.\n        - icon (`str`): The icon of the relic set.\n        - num (`int`): The number of relics in the set.\n        - desc (`str`): The description of the relic set.\n        - properties (list[`Property`]): The list of properties of the relic set.\n    \"\"\"\n\n    id: int\n    \"\"\"The ID of the relic set\"\"\"\n    name: str\n    \"\"\"The name of the relic set\"\"\"\n    icon: str\n    \"\"\"The icon of the relic set\"\"\"\n    num: int\n    \"\"\"The number of relics in the set\"\"\"\n    desc: str\n    \"\"\"The description of the relic set\"\"\"\n    properties: list[Property]\n    \"\"\"The list of properties of the relic set\"\"\"\n"
  },
  {
    "path": "mihomo/models/player.py",
    "content": "from pydantic import BaseModel, Field, root_validator\n\n\nclass Avatar(BaseModel):\n    \"\"\"Profile picture\"\"\"\n\n    id: int\n    name: str\n    icon: str\n\n\nclass ForgottenHall(BaseModel):\n    \"\"\"The progress of the Forgotten Hall\n\n    Attributes:\n        - memory (`int`): The progress of the memory.\n        - memory_of_chaos_id (`int`): The ID of the memory of chaos, or None if not applicable.\n        - memory_of_chaos (`int`): The progress of the memory of chaos, or None if not applicable.\n    \"\"\"\n\n    memory: int = Field(..., alias=\"level\")\n    \"\"\"The progress of the memory (level)\"\"\"\n    memory_of_chaos_id: int = Field(..., alias=\"chaos_id\")\n    \"\"\"The ID of the memory of chaos (chaos_id)\"\"\"\n    memory_of_chaos: int = Field(..., alias=\"chaos_level\")\n    \"\"\"The progress of the memory of chaos (chaos_level)\"\"\"\n\n\nclass Player(BaseModel):\n    \"\"\"\n    Player basic info\n\n    Attributes:\n        - uid (`int`): The player's uid.\n        - name (`str`): The player's nickname.\n        - level (`int`): The player's Trailblaze level.\n        - world_level (`int`): The player's Equilibrium level.\n        - friend_count (`int`): The number of friends.\n        - avatar (`Avatar`): The player's profile picture.\n        - signature (`str`): The player's bio.\n        - is_display (`bool`): Is the player's profile display enabled.\n\n        - forgotten_hall (`ForgottenHall` | None): The progress of the Forgotten Hall, or None if not applicable.\n        - simulated_universes (`int`): The number of simulated universes passed.\n        - light_cones (`int`): The number of light cones owned.\n        - characters (`int`): The number of characters owned.\n        - achievements (`int`): The number of achievements unlocked.\n    \"\"\"\n\n    uid: int\n    \"\"\"Player's uid\"\"\"\n    name: str = Field(..., alias=\"nickname\")\n    \"\"\"Player's nickname\"\"\"\n    level: int\n    \"\"\"Trailblaze level\"\"\"\n    world_level: int\n    \"\"\"Equilibrium level\"\"\"\n    friend_count: int\n    \"\"\"Number of friends\"\"\"\n    avatar: Avatar\n    \"\"\"Profile picture\"\"\"\n    signature: str\n    \"\"\"Bio\"\"\"\n    is_display: bool\n    \"\"\"Is the player's profile display enabled.\"\"\"\n\n    forgotten_hall: ForgottenHall | None = Field(None, alias=\"memory_data\")\n    \"\"\"The progress of the Forgotten Hall (memory_data)\"\"\"\n    simulated_universes: int = Field(0, alias=\"universe_level\")\n    \"\"\"Number of simulated universes passed (universe_level)\"\"\"\n    light_cones: int = Field(0, alias=\"light_cone_count\")\n    \"\"\"Number of light cones owned\"\"\"\n    characters: int = Field(0, alias=\"avatar_count\")\n    \"\"\"Number of characters owned\"\"\"\n    achievements: int = Field(0, alias=\"achievement_count\")\n    \"\"\"Number of achievements unlocked\"\"\"\n\n    @root_validator(pre=True)\n    def decompose_space_info(cls, data):\n        if isinstance(data, dict):\n            space_info = data.get(\"space_info\")\n            if isinstance(space_info, dict):\n                data.update(space_info)\n        return data\n\n    @root_validator(pre=True)\n    def transform_for_backward_compatibility(cls, data):\n        if isinstance(data, dict):\n            if \"pass_area_progress\" in data and \"universe_level\" not in data:\n                data[\"universe_level\"] = data[\"pass_area_progress\"]\n            if \"challenge_data\" in data and \"memory_data\" not in data:\n                c: dict[str, int] = data[\"challenge_data\"]\n                data[\"memory_data\"] = {}\n                data[\"memory_data\"][\"level\"] = c.get(\"pre_maze_group_index\")\n                data[\"memory_data\"][\"chaos_id\"] = c.get(\"maze_group_id\")\n                data[\"memory_data\"][\"chaos_level\"] = c.get(\"maze_group_index\")\n        return data\n"
  },
  {
    "path": "mihomo/models/stat.py",
    "content": "from pydantic import BaseModel, Field\n\n\nclass Attribute(BaseModel):\n    \"\"\"\n    Represents an attribute.\n\n    Attributes:\n        - field (`str`): The field of the attribute.\n        - name (`str`): The name of the attribute.\n        - icon (`str`): The attribute icon image.\n        - value (`float`): The value of the attribute.\n        - displayed_value (`str`): The displayed value of the attribute.\n        - is_percent (`bool`): Indicates if the value is in percentage.\n    \"\"\"\n\n    field: str\n    \"\"\"The field of the attribute\"\"\"\n    name: str\n    \"\"\"The name of the attribute\"\"\"\n    icon: str\n    \"\"\"The attribute icon image\"\"\"\n    value: float\n    \"\"\"The value of the attribute\"\"\"\n    displayed_value: str = Field(..., alias=\"display\")\n    \"\"\"The displayed value of the attribute\"\"\"\n    is_percent: bool = Field(..., alias=\"percent\")\n    \"\"\"Indicates if the value is in percentage\"\"\"\n\n\nclass Property(BaseModel):\n    \"\"\"\n    Represents a property.\n\n    Attributes:\n        - type (`str`): The type of the property.\n        - field (`str`): The field of the property.\n        - name (`str`): The name of the property.\n        - icon (`str`): The property icon image.\n        - value (`float`): The value of the property.\n        - displayed_value (`str`): The displayed value of the property.\n        - is_percent (`bool`): Indicates if the value is in percentage.\n    \"\"\"\n\n    type: str\n    \"\"\"The type of the property\"\"\"\n    field: str\n    \"\"\"The field of the property\"\"\"\n    name: str\n    \"\"\"The name of the property\"\"\"\n    icon: str\n    \"\"\"The property icon image\"\"\"\n    value: float\n    \"\"\"The value of the property\"\"\"\n    displayed_value: str = Field(..., alias=\"display\")\n    \"\"\"The displayed value of the property\"\"\"\n    is_percent: bool = Field(..., alias=\"percent\")\n    \"\"\"Indicates if the value is in percentage\"\"\"\n\n\nclass MainAffix(Property):\n    \"\"\"\n    Represents a relic main affix.\n\n    Attributes:\n        - type (`str`): The type of the affix.\n        - field (`str`): The field of the affix.\n        - name (`str`): The name of the affix.\n        - icon (`str`): The affix icon image.\n        - value (`float`): The value of the affix.\n        - displayed_value (`str`): The displayed value of the affix.\n        - is_percent (`bool`): Indicates if the value is in percentage.\n    \"\"\"\n\n    ...\n\n\nclass SubAffix(MainAffix):\n    \"\"\"\n    Represents a relic sub-affix.\n\n    Attributes:\n        - type (`str`): The type of the affix.\n        - field (`str`): The field of the affix.\n        - name (`str`): The name of the affix.\n        - icon (`str`): The affix icon image.\n        - value (`float`): The value of the affix.\n        - displayed_value (`str`): The displayed value of the affix.\n        - is_percent (`bool`): Indicates if the value is in percentage.\n        - count (`int`): The upgrade times of the affix.\n        - step (`int`): The additional value of the affix.\n    \"\"\"\n\n    count: int\n    \"\"\"The upgrade times of the affix\"\"\"\n    step: int\n    \"\"\"The additional value of the affix\"\"\"\n"
  },
  {
    "path": "mihomo/models/v1/__init__.py",
    "content": "from .base import *\r\nfrom .character import *\r\nfrom .equipment import *\r\nfrom .player import *\r\n"
  },
  {
    "path": "mihomo/models/v1/base.py",
    "content": "from pydantic import BaseModel, Field\r\n\r\nfrom .character import Character\r\nfrom .player import Player, PlayerSpaceInfo\r\n\r\n\r\nclass StarrailInfoParsedV1(BaseModel):\r\n    \"\"\"\r\n    Mihomo parsed data V1\r\n\r\n    Attributes:\r\n        - player (`Player`): The player's basic info.\r\n        - player_details (`PlayerSpaceInfo`): The player's details.\r\n        - characters (list[`Character`]): The list of characters.\r\n    \"\"\"\r\n\r\n    player: Player\r\n    \"\"\"Player's basic info\"\"\"\r\n    player_details: PlayerSpaceInfo = Field(..., alias=\"PlayerSpaceInfo\")\r\n    \"\"\"Player's details\"\"\"\r\n    characters: list[Character]\r\n    \"\"\"The list of characters\"\"\"\r\n"
  },
  {
    "path": "mihomo/models/v1/character.py",
    "content": "from typing import Any\r\n\r\nfrom pydantic import BaseModel, Field, root_validator\r\n\r\nfrom .equipment import LightCone, Relic, RelicSet\r\n\r\n\r\nclass EidolonIcon(BaseModel):\r\n    \"\"\"\r\n    Represents an Eidolon icon.\r\n\r\n    Attributes:\r\n        - icon (`str`): The eidolon icon.\r\n        - unlock (`bool`): Indicates if the eidolon is unlocked.\r\n    \"\"\"\r\n\r\n    icon: str\r\n    \"\"\"The eidolon icon\"\"\"\r\n    unlock: bool\r\n    \"\"\"Indicates if the eidolon is unlocked\"\"\"\r\n\r\n\r\nclass Trace(BaseModel):\r\n    \"\"\"\r\n    Represents a character's skill trace.\r\n\r\n    Attributes:\r\n        - name (`str`): The name of the trace.\r\n        - level (`int`): The level of the trace.\r\n        - type (`str`): The type of the trace.\r\n        - icon (`str`): The trace icon.\r\n    \"\"\"\r\n\r\n    name: str\r\n    \"\"\"The name of the trace\"\"\"\r\n    level: int\r\n    \"\"\"The level of the trace\"\"\"\r\n    type: str\r\n    \"\"\"The type of the trace\"\"\"\r\n    icon: str\r\n    \"\"\"The trace icon\"\"\"\r\n\r\n\r\nclass Stat(BaseModel):\r\n    \"\"\"\r\n    Represents a character's stat.\r\n\r\n    Attributes:\r\n        - name (`str`): The name of the stat.\r\n        - base (`str`): The base value of the stat.\r\n        - addition (`str` | `None`): The additional value of the stat, or None if not applicable.\r\n        - icon (`str`): The stat icon.\r\n    \"\"\"\r\n\r\n    name: str\r\n    \"\"\"The name of the stat\"\"\"\r\n    base: str\r\n    \"\"\"The base value of the stat\"\"\"\r\n    addition: str | None = None\r\n    \"\"\"The additional value of the stat\"\"\"\r\n    icon: str\r\n    \"\"\"The stat icon\"\"\"\r\n\r\n\r\nclass Character(BaseModel):\r\n    \"\"\"\r\n    Represents a character.\r\n\r\n    Attributes:\r\n    - Basic info:\r\n        - id (`str`): The character's ID.\r\n        - name (`str`): The character's name.\r\n        - rarity (`int`): The character's rarity.\r\n        - level (`int`): The character's level.\r\n    - Eidolon\r\n        - eidolon (`int`): The character's eidolon rank.\r\n        - eidolon_icons (list[`EidolonIcon`]): The list of eidolon icons.\r\n    - Image\r\n        - icon (`str`): The character avatar image\r\n        - preview (`str`): The character's preview image.\r\n        - portrait (`str`): The character's portrait image.\r\n    - Combat type\r\n        - path (`str`): The character's path.\r\n        - path_icon (`str`): The character's path icon.\r\n        - element (`str`): The character's element.\r\n        - element_icon (`str`): The character's element icon.\r\n        - color (`str`): The character's element color.\r\n    - Equipment\r\n        - traces (list[`Trace`]): The list of character's skill traces.\r\n        - light_cone (`LightCone` | `None`): The character's light cone (weapon), or None if not applicable.\r\n        - relics (list[`Relic`] | `None`): The list of character's relics, or None if not applicable.\r\n        - relic_set (list[`RelicSet`] | `None`): The list of character's relic sets, or None if not applicable.\r\n        - stats (list[`Stat`]): The list of character's stats.\r\n    \"\"\"\r\n\r\n    id: str\r\n    \"\"\"Character's ID\"\"\"\r\n    name: str\r\n    \"\"\"Character's name\"\"\"\r\n    rarity: int\r\n    \"\"\"Character's rarity\"\"\"\r\n    level: int\r\n    \"\"\"Character's level\"\"\"\r\n\r\n    eidolon: int = Field(..., alias=\"rank\")\r\n    \"\"\"Character's eidolon rank\"\"\"\r\n    eidolon_icons: list[EidolonIcon] = Field(..., alias=\"rank_icons\")\r\n    \"\"\"The list of eidolon icons\"\"\"\r\n\r\n    preview: str\r\n    \"\"\"Character preview image\"\"\"\r\n    portrait: str\r\n    \"\"\"Character portrait image\"\"\"\r\n\r\n    path: str\r\n    \"\"\"Character's path\"\"\"\r\n    path_icon: str\r\n    \"\"\"Character's path icon\"\"\"\r\n\r\n    element: str\r\n    \"\"\"Character's element\"\"\"\r\n    element_icon: str\r\n    \"\"\"Character's element icon\"\"\"\r\n\r\n    color: str\r\n    \"\"\"Character's element color\"\"\"\r\n\r\n    traces: list[Trace] = Field(..., alias=\"skill\")\r\n    \"\"\"The list of character's skill traces\"\"\"\r\n    light_cone: LightCone | None = None\r\n    \"\"\"Character's light cone (weapon)\"\"\"\r\n    relics: list[Relic] | None = Field(None, alias=\"relic\")\r\n    \"\"\"The list of character's relics\"\"\"\r\n    relic_set: list[RelicSet] | None = None\r\n    \"\"\"The list of character's relic sets\"\"\"\r\n    stats: list[Stat] = Field(..., alias=\"property\")\r\n    \"\"\"The list of character's stats\"\"\"\r\n\r\n    @root_validator(pre=True)\r\n    def dict_to_list(cls, data: dict[str, Any]):\r\n        # The keys of the original dict is not necessary, so remove them here.\r\n        if isinstance(data, dict) and data.get(\"relic\") is not None:\r\n            if isinstance(data[\"relic\"], dict):\r\n                data[\"relic\"] = list(data[\"relic\"].values())\r\n        return data\r\n\r\n    @property\r\n    def icon(self) -> str:\r\n        \"\"\"Character avatar image\"\"\"\r\n        return f\"icon/character/{self.id}.png\"\r\n"
  },
  {
    "path": "mihomo/models/v1/equipment.py",
    "content": "from pydantic import BaseModel, Field\r\n\r\n\r\nclass LightCone(BaseModel):\r\n    \"\"\"\r\n    Represents a light cone (weapon).\r\n\r\n    Attributes:\r\n        - name (`str`): The name of the light cone.\r\n        - rarity (`int`): The rarity of the light cone.\r\n        - superimpose (`int`): The superimpose rank of the light cone.\r\n        - level (`int`): The level of the light cone.\r\n        - icon (`str`): The light cone icon.\r\n    \"\"\"\r\n\r\n    name: str\r\n    rarity: int\r\n    superimpose: int = Field(..., alias=\"rank\")\r\n    level: int\r\n    icon: str\r\n\r\n\r\nclass RelicProperty(BaseModel):\r\n    \"\"\"\r\n    Represents a property of a relic.\r\n\r\n    Attributes:\r\n        - name (`str`): The name of the relic property.\r\n        - value (`str`): The value of the relic property.\r\n        - icon (`str`): The property icon.\r\n    \"\"\"\r\n\r\n    name: str\r\n    value: str\r\n    icon: str\r\n\r\n\r\nclass Relic(BaseModel):\r\n    \"\"\"\r\n    Represents a relic.\r\n\r\n    Attributes:\r\n        - name (`str`): The name of the relic.\r\n        - rarity (`int`): The rarity of the relic.\r\n        - level (`int`): The level of the relic.\r\n        - main_property (`RelicProperty`): The main property of the relic.\r\n        - sub_property (list[`RelicProperty`]): The list of sub properties of the relic.\r\n        - icon (`str`): The relic icon.\r\n    \"\"\"\r\n\r\n    name: str\r\n    rarity: int\r\n    level: int\r\n    main_property: RelicProperty\r\n    sub_property: list[RelicProperty]\r\n    icon: str\r\n\r\n\r\nclass RelicSet(BaseModel):\r\n    \"\"\"\r\n    Represents a set of relics.\r\n\r\n    Attributes:\r\n        - name (`str`): The name of the relic set.\r\n        - icon (`str`): The relic set icon.\r\n        - desc (`int`): The description of the relic set.\r\n    \"\"\"\r\n\r\n    name: str\r\n    icon: str\r\n    desc: int\r\n"
  },
  {
    "path": "mihomo/models/v1/player.py",
    "content": "from pydantic import BaseModel, Field\r\n\r\n\r\nclass Player(BaseModel):\r\n    \"\"\"\r\n    Player basic info\r\n\r\n    Attributes:\r\n        - uid (`str`): The player's uid.\r\n        - name (`str`): The player's nickname.\r\n        - level (`int`): The player's Trailblaze level.\r\n        - icon (`str`): The player's profile picture.\r\n        - signature (`str`): The player's bio.\r\n    \"\"\"\r\n\r\n    uid: str\r\n    \"\"\"Player's uid\"\"\"\r\n    name: str\r\n    \"\"\"Player's nickname\"\"\"\r\n    level: int\r\n    \"\"\"Trailblaze level\"\"\"\r\n    icon: str\r\n    \"\"\"Profile picture\"\"\"\r\n    signature: str\r\n    \"\"\"Bio\"\"\"\r\n\r\n\r\nclass ForgottenHall(BaseModel):\r\n    \"\"\"The progress of the Forgotten Hall\r\n\r\n    Attributes:\r\n        - memory (`int`): The progress of the memory.\r\n        - memory_of_chaos_id (`int` | `None`): The ID of the memory of chaos, or None if not applicable.\r\n        - memory_of_chaos (`int` | `None`): The progress of the memory of chaos, or None if not applicable.\r\n    \"\"\"\r\n\r\n    memory: int | None = Field(None, alias=\"PreMazeGroupIndex\")\r\n    \"\"\"The progress of the memory\"\"\"\r\n    memory_of_chaos_id: int | None = Field(None, alias=\"MazeGroupIndex\")\r\n    \"\"\"The ID of the memory of chaos\"\"\"\r\n    memory_of_chaos: int | None = Field(None, alias=\"MazeGroupID\")\r\n    \"\"\"The progress of the memory of chaos\"\"\"\r\n\r\n\r\nclass PlayerSpaceInfo(BaseModel):\r\n    \"\"\"Player details\r\n\r\n    Attributes:\r\n        - forgotten_hall (`ForgottenHall` | None): The progress of the Forgotten Hall, or None if not applicable.\r\n        - simulated_universes (`int`): The number of simulated universes passed.\r\n        - light_cones (`int`): The number of light cones owned.\r\n        - characters (`int`): The number of characters owned.\r\n        - achievements (`int`): The number of achievements unlocked.\r\n    \"\"\"\r\n\r\n    forgotten_hall: ForgottenHall | None = Field(None, alias=\"ChallengeData\")\r\n    \"\"\"The progress of the Forgotten Hall\"\"\"\r\n    simulated_universes: int = Field(0, alias=\"PassAreaProgress\")\r\n    \"\"\"Number of simulated universes passed\"\"\"\r\n    light_cones: int = Field(0, alias=\"LightConeCount\")\r\n    \"\"\"Number of light cones owned\"\"\"\r\n    characters: int = Field(0, alias=\"AvatarCount\")\r\n    \"\"\"Number of characters owned\"\"\"\r\n    achievements: int = Field(0, alias=\"AchievementCount\")\r\n    \"\"\"Number of achievements unlocked\"\"\"\r\n"
  },
  {
    "path": "mihomo/tools.py",
    "content": "from typing import Final, TypeVar\n\nfrom .models import Character, StarrailInfoParsed\nfrom .models.v1 import Character, StarrailInfoParsedV1\n\nRawData = TypeVar(\"RawData\")\nParsedData = TypeVar(\"ParsedData\", StarrailInfoParsed, StarrailInfoParsedV1)\n\nASSET_URL: Final[str] = \"https://raw.githubusercontent.com/Mar-7th/StarRailRes/master\"\n\n\ndef remove_empty_dict(data: RawData) -> RawData:\n    \"\"\"\n    Recursively removes empty dictionaries from the given raw data.\n\n    Args:\n        - data (`RawData`): The input raw data.\n\n    Returns:\n        - `RawData`: The data with empty dictionaries removed.\n    \"\"\"\n    if isinstance(data, dict):\n        for key in data.keys():\n            data[key] = None if (data[key] == {}) else remove_empty_dict(data[key])\n    elif isinstance(data, list):\n        for i in range(len(data)):\n            data[i] = remove_empty_dict(data[i])\n    return data\n\n\ndef replace_icon_name_with_url(data: RawData) -> RawData:\n    \"\"\"\n    Replaces icon file names with asset URLs in the given raw data.\n\n    Example: Replace \"/icon/avatar/1201.png\" with\n    \"https://raw.githubusercontent.com/Mar-7th/StarRailRes/master/icon/avatar/1201.png\"\n\n    Args:\n        - data (`RawData`): The input raw data.\n\n    Returns:\n        - `RawData`: The data with icon file names replaced by asset URLs.\n    \"\"\"\n    if isinstance(data, dict):\n        for key in data.keys():\n            data[key] = replace_icon_name_with_url(data[key])\n    elif isinstance(data, list):\n        for i in range(len(data)):\n            data[i] = replace_icon_name_with_url(data[i])\n    elif isinstance(data, str):\n        if \".png\" in data:\n            data = ASSET_URL + \"/\" + data\n    return data\n\n\ndef replace_trailblazer_name(data: StarrailInfoParsedV1) -> StarrailInfoParsedV1:\n    \"\"\"\n    Replaces the trailblazer name with the player's name.\n\n    Args:\n        - data (`StarrailInfoParsed`): The input StarrailInfoParsed data.\n\n    Returns:\n        - `StarrailInfoParsed`: The updated StarrailInfoParsed data.\n    \"\"\"\n    for i in range(len(data.characters)):\n        if data.characters[i].name == r\"{NICKNAME}\":\n            data.characters[i].name = data.player.name\n    return data\n\n\ndef remove_duplicate_character(data: ParsedData) -> ParsedData:\n    \"\"\"\n    Removes duplicate characters from the given StarrailInfoParsed data.\n\n    Args:\n        - data (`ParsedData`): The input StarrailInfoParsed data.\n\n    Returns:\n        - `ParsedData`: The updated StarrailInfoParsed data without duplicate characters.\n    \"\"\"\n    new_characters = []\n    characters_ids: set[str] = set()\n    for character in data.characters:\n        if character.id not in characters_ids:\n            new_characters.append(character)\n            characters_ids.add(character.id)\n    data.characters = new_characters\n    return data\n\n\ndef merge_character_data(new_data: ParsedData, old_data: ParsedData) -> ParsedData:\n    \"\"\"\n    Append the old data characters to the list of new data characters.\n    The player's info from the old data will be omitted/discarded.\n\n    Args:\n        - new_data (`ParsedData`): The new data to be merged.\n        - old_data (`ParsedData`): The old data to merge into.\n\n    Returns:\n        - `ParsedData`: The merged new data.\n    \"\"\"\n    for character in old_data.characters:\n        new_data.characters.append(character)\n    new_data = remove_duplicate_character(new_data)\n    return new_data\n"
  },
  {
    "path": "pyproject.toml",
    "content": "[build-system]\nrequires = [\"setuptools>=61.0\"]\nbuild-backend = \"setuptools.build_meta\"\n\n[project]\nname = \"mihomo\"\nversion = \"1.1.7\"\nauthors = [\n  { name=\"KT\", email=\"xns77477@gmail.com\" },\n]\ndescription = \"A simple Python Pydantic model for Honkai: Star Rail parsed data from the Mihomo API.\"\nreadme = \"README.md\"\nrequires-python = \">=3.10\"\nclassifiers = [\n    \"Programming Language :: Python :: 3\",\n    \"License :: OSI Approved :: MIT License\",\n    \"Operating System :: OS Independent\",\n]\ndependencies = [\n  \"aiohttp==3.*\",\n  \"pydantic==1.*\",\n]"
  }
]