mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-25 09:37:30 +00:00
🐛 Fix honey impact data parse error
Signed-off-by: Karako <karakohear@gmail.com>
This commit is contained in:
parent
ac879cc353
commit
6efddb364a
@ -472,6 +472,7 @@ class _NamecardAssets(_AssetsService):
|
||||
|
||||
def __call__(self, target: int) -> "_NamecardAssets":
|
||||
result = _NamecardAssets(self.client)
|
||||
target = int(target) if not isinstance(target, int) else target
|
||||
if target > 10000000:
|
||||
target = self._get_id_from_avatar_id(target)
|
||||
result.id = target
|
||||
|
@ -18,7 +18,6 @@ try:
|
||||
except ImportError:
|
||||
import json as jsonlib
|
||||
|
||||
|
||||
__all__ = ["Model", "WikiModel", "HONEY_HOST"]
|
||||
|
||||
HONEY_HOST = URL("https://genshin.honeyhunterworld.com/")
|
||||
@ -208,7 +207,7 @@ class WikiModel(Model):
|
||||
chaos_data = re.findall(r"sortable_data\.push\((.*?)\);\s*sortable_cur_page", response.text)[0]
|
||||
json_data = jsonlib.loads(chaos_data) # 转为 json
|
||||
for data in json_data: # 遍历 json
|
||||
data_name = re.findall(r">(.*)<", data[1])[0].replace("\r", "") # 获取 Model 的名称
|
||||
data_name = re.findall(r">(.*)<", data[1])[0].strip() # 获取 Model 的名称
|
||||
if with_url: # 如果需要返回对应的 url
|
||||
data_url = HONEY_HOST.join(re.findall(r"\"(.*?)\"", data[0])[0])
|
||||
await queue.put((data_name, data_url))
|
||||
|
@ -230,7 +230,7 @@ class DailyMaterial(Plugin):
|
||||
logger.info("正在获取每日素材缓存")
|
||||
self.data = await self._refresh_data()
|
||||
for domain, sche in self.data.items():
|
||||
area = DOMAIN_AREA_MAP[domain] # 获取秘境所在的区域
|
||||
area = DOMAIN_AREA_MAP[domain := domain.strip()] # 获取秘境所在的区域
|
||||
type_ = "avatar" if DOMAINS.index(domain) < 4 else "weapon" # 获取秘境的培养素材的类型:是天赋书还是武器突破材料
|
||||
# 将读取到的数据存入 local_data 中
|
||||
local_data[type_].append({"name": area, "materials": sche[weekday][0], "items": sche[weekday][1]})
|
||||
@ -387,7 +387,7 @@ class DailyMaterial(Plugin):
|
||||
for tag in calendar:
|
||||
tag: Tag
|
||||
if tag.name == "span": # 如果是秘境
|
||||
key = tag.find("a").text
|
||||
key = tag.find("a").text.strip()
|
||||
result[key] = [[[], []] for _ in range(7)]
|
||||
for day, div in enumerate(tag.find_all("div")):
|
||||
result[key][day][0] = []
|
||||
@ -462,6 +462,17 @@ class DailyMaterial(Plugin):
|
||||
new_items.append(ITEM)
|
||||
task_list.append(task(*ITEM))
|
||||
await asyncio.gather(*task_list) # 等待所有任务执行完成
|
||||
try:
|
||||
await message.edit_text(
|
||||
"\n".join(message.text_html.split("\n")[:2] + ["图标素材下载完成!"]), parse_mode=ParseMode.HTML
|
||||
)
|
||||
except RetryAfter as e:
|
||||
await asyncio.sleep(e.retry_after)
|
||||
await message.edit_text(
|
||||
"\n".join(message.text_html.split("\n")[:2] + ["图标素材下载完成!"]), parse_mode=ParseMode.HTML
|
||||
)
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
|
||||
logger.info("图标素材下载完成")
|
||||
return the_time.value
|
||||
|
@ -1,15 +1,14 @@
|
||||
import asyncio
|
||||
import random
|
||||
from datetime import datetime, timedelta, time
|
||||
from typing import Optional, Tuple, Union, TYPE_CHECKING
|
||||
from datetime import datetime, time, timedelta
|
||||
from typing import Optional, TYPE_CHECKING, Tuple, Union
|
||||
|
||||
import genshin
|
||||
from genshin.errors import GenshinException
|
||||
from genshin.models import BaseCharacter
|
||||
from genshin.models import CalculatorCharacterDetails
|
||||
from genshin.models import BaseCharacter, CalculatorCharacterDetails
|
||||
from pydantic import ValidationError
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from sqlmodel import SQLModel, Field, String, Column, Integer, BigInteger, select, DateTime, func, delete, Index
|
||||
from sqlmodel import BigInteger, Column, DateTime, Field, Index, Integer, SQLModel, String, delete, func, select
|
||||
from telegram.ext import ContextTypes
|
||||
|
||||
from core.basemodel import RegionEnum
|
||||
@ -29,7 +28,7 @@ if TYPE_CHECKING:
|
||||
from sqlalchemy import Table
|
||||
from genshin import Client as GenshinClient
|
||||
|
||||
__all__ = ("GenshinHelper", "PlayerNotFoundError", "CookiesNotFoundError")
|
||||
__all__ = ("GenshinHelper", "PlayerNotFoundError", "CookiesNotFoundError", "CharacterDetails")
|
||||
|
||||
|
||||
class PlayerNotFoundError(Exception):
|
||||
|
Loading…
Reference in New Issue
Block a user