mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
🐛 Fix AssetsService
to adapt to ambr
This commit is contained in:
parent
042e4e91ca
commit
df6b0e31ba
@ -1,9 +1,5 @@
|
||||
"""用于下载和管理角色、武器、材料等的图标"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import re
|
||||
from abc import ABC, abstractmethod
|
||||
from functools import cached_property, lru_cache, partial
|
||||
from multiprocessing import RLock as Lock
|
||||
@ -27,6 +23,11 @@ from utils.const import AMBR_HOST, ENKA_HOST, PROJECT_ROOT
|
||||
from utils.log import logger
|
||||
from utils.typedefs import StrOrInt, StrOrURL
|
||||
|
||||
try:
|
||||
import regex as re
|
||||
except ImportError:
|
||||
import re
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from httpx import Response
|
||||
from multiprocessing.synchronize import RLock
|
||||
@ -250,6 +251,8 @@ class _AvatarAssets(_AssetsService):
|
||||
temp = target
|
||||
result = _AvatarAssets(self.client)
|
||||
if isinstance(target, str):
|
||||
if targets := re.findall(r"^(1000000\d)-.*$", target):
|
||||
target = targets[0]
|
||||
try:
|
||||
target = int(target)
|
||||
except ValueError:
|
||||
@ -467,7 +470,7 @@ class AssetsService(BaseService.Dependence):
|
||||
async def initialize(self) -> None: # pylint: disable=R0201
|
||||
"""启动 AssetsService 服务,刷新元数据"""
|
||||
logger.info("正在刷新元数据")
|
||||
# todo 这3个任务同时异步下载
|
||||
# TODO:同时异步下载
|
||||
await update_metadata_from_github(False)
|
||||
await update_metadata_from_ambr(False)
|
||||
logger.info("刷新元数据成功")
|
||||
|
@ -39,10 +39,6 @@ class _AssetsService(ABC):
|
||||
def game_name(self) -> str:
|
||||
"""游戏数据中的名称"""
|
||||
|
||||
@property
|
||||
def honey_id(self) -> str:
|
||||
"""当前资源在 Honey Impact 所对应的 ID"""
|
||||
|
||||
@property
|
||||
def path(self) -> Path:
|
||||
"""当前资源的文件夹"""
|
||||
@ -66,11 +62,6 @@ class _AssetsService(ABC):
|
||||
def game_name_map(self) -> dict[str, str]:
|
||||
"""游戏中的图标名"""
|
||||
|
||||
@abstractmethod
|
||||
@property
|
||||
def honey_name_map(self) -> dict[str, str]:
|
||||
"""来自honey的图标名"""
|
||||
|
||||
class _AvatarAssets(_AssetsService):
|
||||
enka: EnkaCharacterAsset | None
|
||||
|
||||
@ -86,8 +77,6 @@ class _AvatarAssets(_AssetsService):
|
||||
gacha_card: ICON_TYPE
|
||||
"""抽卡卡片"""
|
||||
|
||||
@property
|
||||
def honey_name_map(self) -> dict[str, str]: ...
|
||||
@property
|
||||
def game_name_map(self) -> dict[str, str]: ...
|
||||
@property
|
||||
@ -104,16 +93,12 @@ class _WeaponAssets(_AssetsService):
|
||||
gacha: ICON_TYPE
|
||||
"""抽卡立绘"""
|
||||
|
||||
@property
|
||||
def honey_name_map(self) -> dict[str, str]: ...
|
||||
@property
|
||||
def game_name_map(self) -> dict[str, str]: ...
|
||||
def __call__(self, target: StrOrInt) -> Self: ...
|
||||
def game_name(self) -> str: ...
|
||||
|
||||
class _MaterialAssets(_AssetsService):
|
||||
@property
|
||||
def honey_name_map(self) -> dict[str, str]: ...
|
||||
@property
|
||||
def game_name_map(self) -> dict[str, str]: ...
|
||||
def __call__(self, target: StrOrInt) -> Self: ...
|
||||
@ -135,8 +120,6 @@ class _ArtifactAssets(_AssetsService):
|
||||
circlet: ICON_TYPE
|
||||
"""理之冠"""
|
||||
|
||||
@property
|
||||
def honey_name_map(self) -> dict[str, str]: ...
|
||||
@property
|
||||
def game_name_map(self) -> dict[str, str]: ...
|
||||
def game_name(self) -> str: ...
|
||||
@ -149,9 +132,6 @@ class _NamecardAssets(_AssetsService):
|
||||
|
||||
profile: ICON_TYPE
|
||||
"""个人资料名片背景"""
|
||||
|
||||
@property
|
||||
def honey_name_map(self) -> dict[str, str]: ...
|
||||
@property
|
||||
def game_name_map(self) -> dict[str, str]: ...
|
||||
def game_name(self) -> str: ...
|
||||
|
Loading…
Reference in New Issue
Block a user