🍱 更新原神3.6版本的metadata

This commit is contained in:
Wuyi无疑 2023-04-12 00:58:10 +08:00
parent 77ea2a02e7
commit 7808c2b06e
26 changed files with 2696 additions and 2484 deletions

1
.gitignore vendored
View File

@ -683,6 +683,7 @@ event.jpg
gacha.jpg
help.png
review.json
gs_data
### Debug ###
testnb2/

View File

@ -9,7 +9,6 @@ import qrcode
from gsuid_core.bot import Bot
from qrcode import ERROR_CORRECT_L
from gsuid_core.logger import logger
from gsuid_core.models import Message
from gsuid_core.segment import MessageSegment
from ..utils.mys_api import mys_api
@ -137,7 +136,9 @@ async def topup_(
item_icon_url = goods_data['goods_icon'] # 图标
item_id = goods_data['goods_id'] # 商品内部id
item_pay_url = order['encode_order'] # 支付链接
item_name_full = f"{goods_data['goods_name']}×{goods_data['goods_unit']}"
item_name_full = (
f"{goods_data['goods_name']}×{goods_data['goods_unit']}"
)
# 物品名字(非月卡)
item_name = (
item_name_full
@ -145,7 +146,9 @@ async def topup_(
else goods_data["goods_name"]
)
# 物品名字
item_price: str = order["currency"] + str(int(order["amount"]) / 100) # 价格
item_price: str = order["currency"] + str(
int(order["amount"]) / 100
) # 价格
item_order_no = order['order_no'] # 订单号
item_create_time = order['create_time'] # 创建时间
timestamp = strftime(

View File

@ -134,7 +134,7 @@ async def qrcode_login(bot: Bot, ev: Event, user_id: str) -> str:
# 没有在gsuid绑定uid的情况
if not uid_bind:
logger.warning('game_token获取失败')
im = '你还没有绑定uid,请输入[绑定uid123456]绑定你的uid再发送[扫码登录]进行绑定'
im = '你还没有绑定uid, 请输入[绑定uid123456]绑定你的uid, 再发送[扫码登录]进行绑定'
return await send_msg(im)
if isinstance(cookie_token, int):
return await send_msg('获取CK失败...')
@ -150,8 +150,11 @@ async def qrcode_login(bot: Bot, ev: Event, user_id: str) -> str:
).output(header='', sep=';')
else:
logger.warning('game_token获取失败')
im = 'game_token获取失败被非绑定指定uid用户扫取取消绑定请重新发送[扫码登录]登录账号'
im = (
f'检测到扫码登录UID{uid_check}与绑定UID{uid_bind}不同, '
'gametoken获取失败, 请重新发送[扫码登录]进行登录!'
)
else:
logger.warning('game_token获取失败')
im = 'game_token获取失败二维码已过期'
im = 'game_token获取失败: 二维码已过期'
return await send_msg(im)

View File

@ -92,8 +92,20 @@ async def send_weapon_cost(bot: Bot, ev: Event):
@sv_wiki_text.on_prefix(('角色命座'))
async def send_polar(bot: Bot, ev: Event):
num = int(re.findall(r'\d+', ev.text)[0])
m = ''.join(re.findall('[\u4e00-\u9fa5]', ev.text))
num_re = re.findall(r'\d+', ev.text)
if num_re:
num = int(num_re[0])
else:
return
'''
if gsconfig.get_config('PicWiki').data:
return await bot.send(await get_constellation_wiki_img(m))
else:
return await bot.send('请输入正确的命座数,例如 角色命座申鹤2!')
'''
if num <= 0 or num > 6:
return await bot.send('你家{}{}命?'.format(m, num))
im = await constellation_wiki(m, num)

View File

@ -0,0 +1,161 @@
from pathlib import Path
from typing import Dict, Tuple, Union
from PIL import Image, ImageDraw
from ..utils.colors import first_color
from ..utils.error_reply import get_error
from ..utils.resource.download_url import download
from ..utils.map.name_covert import name_to_avatar_id
from ..utils.map.GS_MAP_PATH import avatarName2Element
from ..utils.image.convert import str_lenth, convert_img
from ..utils.fonts.genshin_fonts import gs_font_20, gs_font_28
from ..gsuid_utils.api.minigg.request import get_constellation_info
from ..utils.image.image_tools import get_color_bg, draw_pic_with_ring
from ..utils.resource.RESOURCE_PATH import (
CHAR_PATH,
ICON_PATH,
CONSTELLATION_PATH,
)
from ..gsuid_utils.api.minigg.models import (
CharacterConstellation,
CharacterConstellations,
)
R_PATH = Path(__file__).parents[0]
TEXT_PATH = R_PATH / 'texture2D'
COLOR_MAP = {
'Anemo': (0, 145, 137),
'Cryo': (4, 126, 152),
'Dendro': (28, 145, 0),
'Electro': (133, 12, 159),
'Geo': (147, 112, 3),
'Hydro': (51, 73, 162),
'Pyro': (136, 28, 33),
}
async def get_constellation_wiki_img(name: str) -> Union[str, bytes]:
data = await get_constellation_info(name)
if isinstance(data, int):
return get_error(data)
else:
pass
'''
full_name = data['name']
path = CONSTELLATION_PATH / f'{full_name}.jpg'
if path.exists():
async with aiofiles.open(path, 'rb') as f:
return await f.read()
'''
img = await draw_constellation_wiki_img(data)
return img
async def draw_single_constellation(
data: CharacterConstellation,
image: str,
num: int,
color: Tuple[int, int, int],
) -> Image.Image:
# 计算长度
effect = data['effect']
for i in range(1, 10):
if i % 2 != 0:
effect = effect.replace('**', '', 1)
else:
effect = effect.replace('**', '', 1)
effect = '  ' + effect.replace('\n', '\n  ')
effect = await str_lenth(effect, 20, 465)
effect += '\n'
img1 = Image.new('RGBA', (600, 1400))
img1_draw = ImageDraw.Draw(img1)
_, _, _, y1 = img1_draw.textbbox((0, 0), effect, gs_font_20)
y = 110 + y1
img = Image.new('RGBA', (600, y))
img_draw = ImageDraw.Draw(img)
img_draw.rounded_rectangle(
(45, 18, 555, y),
fill=(255, 255, 255, 125),
radius=20,
)
icon_name = image.split('/')[-1]
path = ICON_PATH / icon_name
if not path.exists():
await download(image, 8, icon_name)
icon = Image.open(path).resize((51, 51))
img.paste(icon, (60, 28), icon)
img_draw.text(
(128, 52),
f'{num}命 | {data["name"]}',
color,
gs_font_28,
'lm',
)
# line = '·' * 25 + '\n'
# img_draw.text((300, 95), line, (243, 180, 133), gs_font_20, 'mm')
img_draw.text((60, 95), effect, first_color, gs_font_20)
# img_draw.text((300, 120 + y1), line, (243, 180, 133), gs_font_20, 'mm')
return img
async def draw_constellation_wiki_img(data: CharacterConstellations) -> bytes:
img_list: Dict[int, Tuple[Image.Image, int]] = {}
element = avatarName2Element[data['name']]
bg_color = COLOR_MAP[element]
y = 0
for i in range(1, 7):
_img = await draw_single_constellation(
data[f'c{i}'], data['images'][f'c{i}'], i, bg_color
)
img_list[i] = (_img, _img.size[1])
y += _img.size[1]
title = Image.open(TEXT_PATH / 'con_title.png')
avatar_id = await name_to_avatar_id(data['name'])
char_img = Image.open(CHAR_PATH / f'{avatar_id}.png')
icon = await draw_pic_with_ring(char_img, 210)
title.paste(icon, (192, 44), icon)
title_draw = ImageDraw.Draw(title)
title_draw.text(
(300, 296), f'{data["name"]}命座', bg_color, gs_font_28, 'mm'
)
'''
overlay = Image.open(TEXT_PATH / 'wiki_grad_black.png').resize(
(600, y + 400)
)
color_img = Image.new('RGBA', overlay.size, bg_color)
img = ImageChops.difference(color_img, overlay)
'''
img = await get_color_bg(600, y + 400)
'''
gacha_img = Image.open(GACHA_IMG_PATH / f'{data["name"]}.png')
gacha_img.putalpha(
gacha_img.getchannel('A').point(
lambda x: round(x * 0.2) if x > 0 else 0
)
)
img.paste(gacha_img, (-724, 275), gacha_img)
'''
temp = 365
for index in img_list:
_img = img_list[index][0]
img.paste(_img, (0, temp), _img)
temp += img_list[index][1]
img.paste(title, (0, 0), title)
img = img.convert('RGB')
img.save(
CONSTELLATION_PATH / '{}.jpg'.format(data['name']),
format='JPEG',
quality=100,
subsampling=0,
)
return await convert_img(img)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

File diff suppressed because it is too large Load Diff

View File

@ -59,6 +59,11 @@ async def str_lenth(r: str, size: int, limit: int = 540) -> str:
result = ''
temp = 0
for i in r:
if i == '\n':
temp = 0
result += i
continue
if temp >= limit:
result += '\n' + i
temp = 0
@ -76,3 +81,8 @@ async def str_lenth(r: str, size: int, limit: int = 540) -> str:
else:
temp += size
return result
def get_height(content: str, size: int) -> int:
line_count = content.count('\n')
return (line_count + 1) * size

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -24,6 +24,7 @@ CARD_PATH = RESOURCE_PATH / 'card'
GUIDE_PATH = WIKI_PATH / 'guide'
REF_PATH = WIKI_PATH / 'ref'
WIKI_REL_PATH = WIKI_PATH / 'artifacts'
CONSTELLATION_PATH = WIKI_PATH / 'constellation'
TEXT2D_PATH = Path(__file__).parent / 'texture2d'
PLAYER_PATH = MAIN_PATH / 'players'
@ -52,6 +53,7 @@ def init_dir():
REF_PATH,
CHAR_CARD_PATH,
WIKI_REL_PATH,
CONSTELLATION_PATH,
]:
i.mkdir(parents=True, exist_ok=True)

View File

@ -1,2 +1,2 @@
GenshinUID_version = '3.1.0'
Genshin_version = '3.5.0'
Genshin_version = '3.6.0'

51
poetry.lock generated
View File

@ -615,14 +615,14 @@ test = ["anyio[trio] (>=3.2.1,<4.0.0)", "black (==23.1.0)", "coverage[toml] (>=6
[[package]]
name = "fastapi-amis-admin"
version = "0.5.3"
version = "0.5.4"
description = "FastAPI-Amis-Admin is a high-performance, efficient and easily extensible FastAPI admin framework. Inspired by Django-admin, and has as many powerful functions as Django-admin. "
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "fastapi_amis_admin-0.5.3-py3-none-any.whl", hash = "sha256:7ade9226c03b9a4d533eb41b9ead0680825a89c24a2cf47d010debb55df7ef8d"},
{file = "fastapi_amis_admin-0.5.3.tar.gz", hash = "sha256:5a5556d9a404f758a9c1780d464c3f769084ab3e339e4556a43254bb46eeb2d9"},
{file = "fastapi_amis_admin-0.5.4-py3-none-any.whl", hash = "sha256:1cacef8681c35dbaa12a9ee7136161eca57b3f449cba18a885410ede00ced9d7"},
{file = "fastapi_amis_admin-0.5.4.tar.gz", hash = "sha256:0d56c53a8766672b54de0e779b02c321bdd6fd09c754a1a99212bf5da24fc04f"},
]
[package.dependencies]
@ -901,14 +901,14 @@ files = [
[[package]]
name = "httpcore"
version = "0.16.3"
version = "0.17.0"
description = "A minimal low-level HTTP client."
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "httpcore-0.16.3-py3-none-any.whl", hash = "sha256:da1fb708784a938aa084bde4feb8317056c55037247c787bd7e19eb2c2949dc0"},
{file = "httpcore-0.16.3.tar.gz", hash = "sha256:c5d6f04e2fc530f39e0c077e6a30caa53f1451096120f1f38b954afd0b17c0cb"},
{file = "httpcore-0.17.0-py3-none-any.whl", hash = "sha256:0fdfea45e94f0c9fd96eab9286077f9ff788dd186635ae61b312693e4d943599"},
{file = "httpcore-0.17.0.tar.gz", hash = "sha256:cc045a3241afbf60ce056202301b4d8b6af08845e3294055eb26b09913ef903c"},
]
[package.dependencies]
@ -923,25 +923,25 @@ socks = ["socksio (>=1.0.0,<2.0.0)"]
[[package]]
name = "httpx"
version = "0.23.3"
version = "0.24.0"
description = "The next generation HTTP client."
category = "main"
optional = false
python-versions = ">=3.7"
files = [
{file = "httpx-0.23.3-py3-none-any.whl", hash = "sha256:a211fcce9b1254ea24f0cd6af9869b3d29aba40154e947d2a07bb499b3e310d6"},
{file = "httpx-0.23.3.tar.gz", hash = "sha256:9818458eb565bb54898ccb9b8b251a28785dd4a55afbc23d0eb410754fe7d0f9"},
{file = "httpx-0.24.0-py3-none-any.whl", hash = "sha256:447556b50c1921c351ea54b4fe79d91b724ed2b027462ab9a329465d147d5a4e"},
{file = "httpx-0.24.0.tar.gz", hash = "sha256:507d676fc3e26110d41df7d35ebd8b3b8585052450f4097401c9be59d928c63e"},
]
[package.dependencies]
certifi = "*"
httpcore = ">=0.15.0,<0.17.0"
rfc3986 = {version = ">=1.3,<2", extras = ["idna2008"]}
httpcore = ">=0.15.0,<0.18.0"
idna = "*"
sniffio = "*"
[package.extras]
brotli = ["brotli", "brotlicffi"]
cli = ["click (>=8.0.0,<9.0.0)", "pygments (>=2.0.0,<3.0.0)", "rich (>=10,<13)"]
cli = ["click (>=8.0.0,<9.0.0)", "pygments (>=2.0.0,<3.0.0)", "rich (>=10,<14)"]
http2 = ["h2 (>=3,<5)"]
socks = ["socksio (>=1.0.0,<2.0.0)"]
@ -1705,18 +1705,17 @@ files = [
[[package]]
name = "pytest"
version = "7.2.2"
version = "7.3.0"
description = "pytest: simple powerful testing with Python"
category = "dev"
optional = false
python-versions = ">=3.7"
files = [
{file = "pytest-7.2.2-py3-none-any.whl", hash = "sha256:130328f552dcfac0b1cec75c12e3f005619dc5f874f0a06e8ff7263f0ee6225e"},
{file = "pytest-7.2.2.tar.gz", hash = "sha256:c99ab0c73aceb050f68929bc93af19ab6db0558791c6a0715723abe9d0ade9d4"},
{file = "pytest-7.3.0-py3-none-any.whl", hash = "sha256:933051fa1bfbd38a21e73c3960cebdad4cf59483ddba7696c48509727e17f201"},
{file = "pytest-7.3.0.tar.gz", hash = "sha256:58ecc27ebf0ea643ebfdf7fb1249335da761a00c9f955bcd922349bcb68ee57d"},
]
[package.dependencies]
attrs = ">=19.2.0"
colorama = {version = "*", markers = "sys_platform == \"win32\""}
exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""}
iniconfig = "*"
@ -1725,7 +1724,7 @@ pluggy = ">=0.12,<2.0"
tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
[package.extras]
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
[[package]]
name = "pytest-asyncio"
@ -1901,24 +1900,6 @@ urllib3 = ">=1.21.1,<1.27"
socks = ["PySocks (>=1.5.6,!=1.5.7)"]
use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
[[package]]
name = "rfc3986"
version = "1.5.0"
description = "Validating URI References per RFC 3986"
category = "main"
optional = false
python-versions = "*"
files = [
{file = "rfc3986-1.5.0-py2.py3-none-any.whl", hash = "sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97"},
{file = "rfc3986-1.5.0.tar.gz", hash = "sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835"},
]
[package.dependencies]
idna = {version = "*", optional = true, markers = "extra == \"idna2008\""}
[package.extras]
idna2008 = ["idna"]
[[package]]
name = "setuptools"
version = "67.6.1"

View File

@ -15,7 +15,7 @@ colorama==0.4.6 ; python_full_version >= "3.8.1" and python_version < "4.0" and
dnspython==2.3.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
email-validator==1.3.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
et-xmlfile==1.1.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi-amis-admin==0.5.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi-amis-admin==0.5.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi-user-auth==0.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
fastapi==0.95.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
frozenlist==1.3.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
@ -23,8 +23,8 @@ gitdb==4.0.10 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
gitpython==3.1.31 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
greenlet==2.0.2 ; python_full_version >= "3.8.1" and platform_machine == "aarch64" and python_full_version < "4.0.0" or python_full_version >= "3.8.1" and platform_machine == "ppc64le" and python_full_version < "4.0.0" or python_full_version >= "3.8.1" and platform_machine == "x86_64" and python_full_version < "4.0.0" or python_full_version >= "3.8.1" and platform_machine == "amd64" and python_full_version < "4.0.0" or python_full_version >= "3.8.1" and platform_machine == "AMD64" and python_full_version < "4.0.0" or python_full_version >= "3.8.1" and platform_machine == "win32" and python_full_version < "4.0.0" or python_full_version >= "3.8.1" and platform_machine == "WIN32" and python_full_version < "4.0.0"
h11==0.14.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
httpcore==0.16.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
httpx==0.23.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
httpcore==0.17.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
httpx==0.24.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
idna==3.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
loguru==0.6.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
lxml==4.9.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
@ -44,7 +44,6 @@ python-multipart==0.0.6 ; python_full_version >= "3.8.1" and python_full_version
pytz-deprecation-shim==0.1.0.post0 ; python_full_version >= "3.8.1" and python_version < "4.0"
pytz==2023.3 ; python_full_version >= "3.8.1" and python_version < "4.0"
qrcode[pil]==7.4.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
rfc3986[idna2008]==1.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
setuptools==67.6.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
six==1.16.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
smmap==5.0.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"