Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change icon provider to Enka #165

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions genshin/models/genshin/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import re
import typing

from genshin.utility import deprecation

if typing.TYPE_CHECKING:
import pydantic.v1 as pydantic
else:
Expand All @@ -20,7 +22,7 @@

_LOGGER = logging.getLogger(__name__)

ICON_BASE = "https://upload-os-bbs.mihoyo.com/game_record/genshin/"
ICON_BASE = "https://enka.network/ui/"


def _parse_icon(icon: typing.Union[str, int]) -> str:
Expand Down Expand Up @@ -86,7 +88,14 @@ def _get_db_char(
constants.CHARACTER_NAMES[lang][char.id] = char
return char

return constants.DBChar(id or 0, icon_name, name or icon_name, element or "Anemo", rarity or 5, guessed=True)
return constants.DBChar(
id or 0,
icon_name,
name or icon_name,
element or "Anemo",
rarity or 5,
guessed=True,
)

if name:
for char in constants.CHARACTER_NAMES[lang].values():
Expand Down Expand Up @@ -115,7 +124,7 @@ def __autocomplete(cls, values: typing.Dict[str, typing.Any]) -> typing.Dict[str
id, name, icon, element, rarity = (values.get(x) for x in ("id", "name", "icon", "element", "rarity"))

char = _get_db_char(id, name, icon, element, rarity, lang=values["lang"])
icon = _create_icon(char.icon_name, "character_icon/UI_AvatarIcon_{}")
icon = _create_icon(char.icon_name, "UI_AvatarIcon_{}")

values["id"] = char.id
values["name"] = char.name
Expand Down Expand Up @@ -143,16 +152,21 @@ def __autocomplete(cls, values: typing.Dict[str, typing.Any]) -> typing.Dict[str
return values

@property
@deprecation.deprecated("gacha_art")
def image(self) -> str:
return _create_icon(self.icon, "character_image/UI_AvatarIcon_{}@2x")
return _create_icon(self.icon, "UI_Gacha_AvatarImg_{}")

@property
def gacha_art(self) -> str:
return _create_icon(self.icon, "UI_Gacha_AvatarImg_{}")

@property
def side_icon(self) -> str:
return _create_icon(self.icon, "character_side_icon/UI_AvatarIcon_Side_{}")
return _create_icon(self.icon, "UI_AvatarIcon_Side_{}")

@property
def card_icon(self) -> str:
return _create_icon(self.icon, "character_card_icon/UI_AvatarIcon_{}_Card")
return _create_icon(self.icon, "UI_AvatarIcon_{}_Card")

@property
def traveler_name(self) -> str:
Expand Down
Loading