Skip to content

Commit

Permalink
feat: add more icon asset url
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao authored Nov 20, 2024
1 parent 7b57d6f commit 2304e85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions enkanetwork/model/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
class IconAsset(BaseModel):
filename: str = ""
url: str = ""
url_png: str = ""
url_webp: str = ""

def __init__(self, **data: Any) -> None:
super().__init__(**data)

self.url = create_ui_path(self.filename)
self.url_png = create_ui_path(self.filename, 1)
self.url_webp = create_ui_path(self.filename, 2)
10 changes: 8 additions & 2 deletions enkanetwork/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

# Base URL
BASE_URL = "https://enka.network/{PATH}"
YATTA_URL = "https://gi.yatta.moe/assets/UI/{PATH}"
HAKUSH_URL = "https://api.hakush.in/gi/UI/{PATH}"

# Request
CHUNK_SIZE = 5 * 2**20
Expand All @@ -50,8 +52,12 @@ def create_path(path: str) -> str:
return BASE_URL.format(PATH=path)


def create_ui_path(filename: str) -> str:
return create_path(f"ui/{filename}.png")
def create_ui_path(filename: str, base: int = 0) -> str:
if base == 0:
return create_path(f"ui/{filename}.png")
elif base == 1:
return YATTA_URL.format(PATH=f"{filename}.png")
return HAKUSH_URL.format(PATH=f"{filename}.webp")


def validate_uid(uid: str) -> bool:
Expand Down

0 comments on commit 2304e85

Please sign in to comment.