Archived
1
0
Fork 0

update arcaea module

This commit is contained in:
yzhh 2021-12-25 17:32:41 +08:00
parent 9f6e1c1cc2
commit b2dbc8bfbc
3 changed files with 75 additions and 49 deletions

View file

@ -53,7 +53,13 @@ async def _(msg: MessageSession):
@arc.handle('initialize', required_superuser=True)
async def _(msg: MessageSession):
return await arcb30init(msg)
assets_apk = os.path.abspath('./assets/arc.apk')
if not os.path.exists(assets_apk):
await msg.sendMessage('未找到arc.apk')
return
result = await arcb30init()
if result:
await msg.sendMessage('成功初始化!')
@arc.handle('download {获取最新版本的游戏apk}')

View file

@ -1,3 +1,4 @@
import asyncio
import os
import uuid
@ -32,32 +33,38 @@ async def getb30(usercode):
ptts = {}
scores = {}
last5list = ''
run_lst = []
for x in loadjson["content"]["best30_list"]:
d = d + 1
async with session.get(url + "song/info?songname=" + x['song_id'], headers=headers) as name:
b = await name.text()
loadname = json.loads(b)
if x['difficulty'] == 0:
difficulty = 'PST'
if x['difficulty'] == 1:
difficulty = 'PRS'
if x['difficulty'] == 2:
difficulty = 'FTR'
if x['difficulty'] == 3:
difficulty = 'BYD'
trackname = loadname['content']['title_localized']['en']
tracknames[x['song_id'] + difficulty] = trackname + f' ({difficulty})'
imgpath = f'{assets_path}/songimg/{x["song_id"]}.jpg'
realptt = loadname['content']['difficulties'][x['difficulty']]['ratingReal']
realptts[x['song_id'] + difficulty] = realptt
ptt = x['rating']
ptts[x['song_id'] + difficulty] = ptt
score = x['score']
scores[x['song_id'] + difficulty] = score
if not os.path.exists(imgpath):
imgpath = f'{assets_path}/songimg/random.jpg'
dsimg(os.path.abspath(imgpath), d, trackname, x['difficulty'], score, ptt, realptt,
x['perfect_count'], x['near_count'], x['miss_count'], x['time_played'], newdir)
async def draw_jacket(x, d):
async with session.get(url + "song/info?songname=" + x['song_id'], headers=headers) as name:
loadname = await name.json()
if x['difficulty'] == 0:
difficulty = 'PST'
if x['difficulty'] == 1:
difficulty = 'PRS'
if x['difficulty'] == 2:
difficulty = 'FTR'
if x['difficulty'] == 3:
difficulty = 'BYD'
trackname = loadname['content']['title_localized']['en']
tracknames[x['song_id'] + difficulty] = trackname + f' ({difficulty})'
imgpath = f'{assets_path}/songimg/{x["song_id"]}_{str(x["difficulty"])}.jpg'
if not os.path.exists(imgpath):
imgpath = f'{assets_path}/songimg/{x["song_id"]}.jpg'
realptt = loadname['content']['difficulties'][x['difficulty']]['ratingReal']
realptts[x['song_id'] + difficulty] = realptt
ptt = x['rating']
ptts[x['song_id'] + difficulty] = ptt
score = x['score']
scores[x['song_id'] + difficulty] = score
if not os.path.exists(imgpath):
imgpath = f'{assets_path}/songimg/random.jpg'
dsimg(os.path.abspath(imgpath), d, trackname, x['difficulty'], score, ptt, realptt,
x['perfect_count'], x['near_count'], x['miss_count'], x['time_played'], newdir)
run_lst.append(draw_jacket(x, d))
await asyncio.gather(*run_lst)
print(tracknames)
for last5 in loadjson["content"]["best30_list"][-5:]:
last5rank += 1

View file

@ -9,12 +9,11 @@ from PIL import Image, ImageFilter, ImageEnhance, ImageDraw
from core.elements import MessageSession
async def arcb30init(msg: MessageSession):
async def arcb30init():
cache = os.path.abspath('./cache')
assets_apk = os.path.abspath('./assets/arc.apk')
if not os.path.exists(assets_apk):
await msg.sendMessage('未找到arc.apk')
return
return False
assets = os.path.abspath('./assets/arcaea')
if os.path.exists(assets):
shutil.rmtree(assets)
@ -25,41 +24,55 @@ async def arcb30init(msg: MessageSession):
fz.extract(file, cache)
copysongpath = cache + '/assets/songs'
songdirs = os.listdir(copysongpath)
jacket_output = os.path.abspath('./cache/jacket_output/')
if not os.path.exists(jacket_output):
os.makedirs(jacket_output)
for file in songdirs:
filename = os.path.abspath(f'{copysongpath}/{file}')
print(filename)
if os.path.isdir(filename):
output = os.path.abspath('./cache/songoutput/')
if not os.path.exists(output):
os.makedirs(output)
file = re.sub('dl_', '', file)
filename = filename + '/base.jpg'
if os.path.exists(filename):
shutil.copy(filename, f'{output}/{file}.jpg')
filename_base = filename + '/base.jpg'
if os.path.exists(filename_base):
shutil.copy(filename_base, f'{jacket_output}/{file}.jpg')
filename_0 = filename + '/0.jpg'
if os.path.exists(filename_0):
shutil.copy(filename_0, f'{jacket_output}/{file}_0.jpg')
filename_1 = filename + '/1.jpg'
if os.path.exists(filename_1):
shutil.copy(filename_1, f'{jacket_output}/{file}_1.jpg')
filename_2 = filename + '/2.jpg'
if os.path.exists(filename_2):
shutil.copy(filename_2, f'{jacket_output}/{file}_2.jpg')
filename_3 = filename + '/3.jpg'
if os.path.exists(filename_3):
shutil.copy(filename_3, f'{jacket_output}/{file}_3.jpg')
files = os.listdir(output)
outputpath = os.path.abspath('./cache/bluroutput')
if not os.path.exists(outputpath):
os.makedirs(outputpath)
shutil.copytree(jacket_output, assets + '/jacket')
files = os.listdir(jacket_output)
bluroutputpath = os.path.abspath('./cache/bluroutput')
if not os.path.exists(bluroutputpath):
os.makedirs(bluroutputpath)
for file in files:
img = Image.open(f'{output}/{file}')
img = Image.open(f'{jacket_output}/{file}')
img2 = img.filter(ImageFilter.GaussianBlur(radius=2))
downlight = ImageEnhance.Brightness(img2)
d2 = downlight.enhance(0.65)
if not os.path.exists(outputpath):
os.makedirs(outputpath)
d2.save(f'{outputpath}/{file}')
if not os.path.exists(bluroutputpath):
os.makedirs(bluroutputpath)
d2.save(f'{bluroutputpath}/{file}')
files = os.listdir(outputpath)
songimgdir = assets + '/songimg'
if not os.path.exists(songimgdir):
os.makedirs(songimgdir)
files = os.listdir(bluroutputpath)
b30background_imgdir = assets + '/b30background_img'
if not os.path.exists(b30background_imgdir):
os.makedirs(b30background_imgdir)
for file in files:
img = Image.open(os.path.abspath(f'{outputpath}/{file}'))
img = Image.open(os.path.abspath(f'{bluroutputpath}/{file}'))
img1 = img.resize((325, 325))
img2 = img1.crop((0, 62, 325, 263))
img2.save(os.path.abspath(f'{songimgdir}/{file}'))
img2.save(os.path.abspath(f'{b30background_imgdir}/{file}'))
shutil.copytree(cache + '/assets/char', assets + '/char')
shutil.copytree(cache + '/assets/Fonts', assets + '/Fonts')
@ -89,7 +102,7 @@ async def arcb30init(msg: MessageSession):
cd = cd.rotate(180).transpose(Image.FLIP_LEFT_RIGHT)
cd.save(os.path.abspath(f'{assets}/{ds}.png'))
await msg.sendMessage('成功初始化!')
return True
class Rotate(object):