mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-21 21:58:05 +00:00
🐛 Fix some genshin problems
This commit is contained in:
parent
0354fe7aa5
commit
70b683268b
@ -57,7 +57,7 @@ class TransactionClient(BaseClient):
|
||||
lang (str, optional): The language to use for the request. Defaults to None.
|
||||
"""
|
||||
kind = TransactionKind(kind)
|
||||
endpoint = "get" + kind.value.capitalize() + "Log"
|
||||
endpoint = "Get" + kind.value.capitalize() + "Log"
|
||||
|
||||
data = await self.request_transaction(
|
||||
endpoint,
|
||||
|
@ -30,6 +30,7 @@ class Cookies(_Cookies):
|
||||
for cookie in cookies.jar:
|
||||
self.jar.set_cookie(cookie)
|
||||
elif isinstance(cookies, str):
|
||||
self.jar = CookieJar()
|
||||
cookie = SimpleCookie(cookies)
|
||||
for key, value in cookie.items():
|
||||
self.set(key, value.value)
|
||||
|
@ -273,8 +273,8 @@ INFO_LEDGER_URL = GameRoute(
|
||||
)
|
||||
|
||||
YSULOG_URL = InternationalRoute(
|
||||
overseas="https://hk4e-api-os.hoyoverse.com/ysulog/api/",
|
||||
chinese="https://hk4e-api.mihoyo.com/ysulog/api/",
|
||||
overseas="https://hk4e-api-os.hoyoverse.com/common/hk4e_self_help_query/User/",
|
||||
chinese="https://hk4e-api.mihoyo.com/common/hk4e_self_help_query/User/",
|
||||
)
|
||||
|
||||
HK4E_URL = Route("https://sg-hk4e-api.hoyoverse.com/common/hk4e_global/")
|
||||
|
@ -1,12 +1,11 @@
|
||||
from datetime import timedelta, datetime
|
||||
from typing import Union, Literal, Tuple, List, Optional, Dict, Any
|
||||
|
||||
from pydantic import Field, root_validator, validator
|
||||
from pydantic import Field, root_validator
|
||||
|
||||
from simnet.models.base import APIModel
|
||||
from simnet.models.genshin.character import BaseCharacter
|
||||
|
||||
__all__ = ("Expedition", "ExpeditionCharacter", "Notes")
|
||||
__all__ = ("Expedition", "Notes")
|
||||
|
||||
|
||||
def _process_timedelta(time: Union[int, timedelta, datetime]) -> datetime:
|
||||
@ -36,20 +35,16 @@ def _process_timedelta(time: Union[int, timedelta, datetime]) -> datetime:
|
||||
return time
|
||||
|
||||
|
||||
class ExpeditionCharacter(BaseCharacter):
|
||||
"""Expedition character."""
|
||||
|
||||
|
||||
class Expedition(APIModel):
|
||||
"""The model for a real-time expedition.
|
||||
|
||||
Attributes:
|
||||
character (ExpeditionCharacter): The expedition character.
|
||||
character (str): The expedition character icon url.
|
||||
status (Literal["Ongoing", "Finished"]): The status of the expedition.
|
||||
remaining_time (timedelta): The remaining time of the expedition.
|
||||
"""
|
||||
|
||||
character: ExpeditionCharacter = Field(alias="avatar_side_icon")
|
||||
character: str = Field(alias="avatar_side_icon")
|
||||
status: Literal["Ongoing", "Finished"]
|
||||
remaining_time: timedelta = Field(alias="remained_time")
|
||||
|
||||
@ -63,20 +58,6 @@ class Expedition(APIModel):
|
||||
"""A property that returns the completion time of the expedition."""
|
||||
return datetime.now().astimezone() + self.remaining_time
|
||||
|
||||
@validator("character", pre=True)
|
||||
def complete_character(cls, v: Any) -> Any:
|
||||
"""A validator that completes the expedition character information.
|
||||
|
||||
Args:
|
||||
v (Any): The input character information.
|
||||
|
||||
Returns:
|
||||
Any: The completed character information.
|
||||
"""
|
||||
if isinstance(v, str):
|
||||
return dict(icon=v) # type: ignore
|
||||
return v
|
||||
|
||||
|
||||
class TransformerTimedelta(timedelta):
|
||||
"""The model for a transformer recovery time."""
|
||||
|
@ -33,10 +33,9 @@ class BaseTransaction(APIModel):
|
||||
kind: TransactionKind
|
||||
|
||||
id: int
|
||||
uid: int
|
||||
time: datetime
|
||||
time: datetime = Field(alias="datetime")
|
||||
amount: int = Field(alias="add_num")
|
||||
reason_id: int = Field(alias="reason")
|
||||
reason: str
|
||||
|
||||
|
||||
class Transaction(BaseTransaction):
|
||||
@ -51,4 +50,4 @@ class ItemTransaction(BaseTransaction):
|
||||
kind: Literal[TransactionKind.ARTIFACT, TransactionKind.WEAPON]
|
||||
|
||||
name: str
|
||||
rarity: int = Field(alias="rank")
|
||||
rarity: int = Field(alias="quality")
|
||||
|
Loading…
Reference in New Issue
Block a user