mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-13 03:27:26 +08:00
Update to v2.3.2
This commit is contained in:
@@ -42,7 +42,7 @@ def get_url(file_path, **kwargs):
|
||||
return url_for('download', file_path=file_path, t=t, _external=True)
|
||||
|
||||
|
||||
def get_one_song(c, user_id, song_id, file_dir='./database/songs'):
|
||||
def get_one_song(c, user_id, song_id, file_dir='./database/songs', url_flag=True):
|
||||
# 获取一首歌的下载链接,返回字典
|
||||
dir_list = os.listdir(os.path.join(file_dir, song_id))
|
||||
re = {}
|
||||
@@ -64,8 +64,12 @@ def get_one_song(c, user_id, song_id, file_dir='./database/songs'):
|
||||
else:
|
||||
checksum = get_file_md5(os.path.join(
|
||||
file_dir, song_id, 'base.ogg'))
|
||||
re['audio'] = {"checksum": checksum, "url": get_url(
|
||||
file_path=song_id+'/base.ogg', t=token)}
|
||||
|
||||
if url_flag:
|
||||
re['audio'] = {"checksum": checksum, "url": get_url(
|
||||
file_path=song_id+'/base.ogg', t=token)}
|
||||
else:
|
||||
re['audio'] = {"checksum": checksum}
|
||||
else:
|
||||
if 'chart' not in re:
|
||||
re['chart'] = {}
|
||||
@@ -76,23 +80,28 @@ def get_one_song(c, user_id, song_id, file_dir='./database/songs'):
|
||||
checksum = x[0]
|
||||
else:
|
||||
checksum = get_file_md5(os.path.join(file_dir, song_id, i))
|
||||
re['chart'][i[0]] = {"checksum": checksum, "url": get_url(
|
||||
file_path=song_id+'/'+i, t=token)}
|
||||
|
||||
c.execute('''insert into download_token values(:a,:b,:c,:d,:e)''', {
|
||||
'a': user_id, 'b': song_id, 'c': i, 'd': token, 'e': now})
|
||||
if url_flag:
|
||||
re['chart'][i[0]] = {"checksum": checksum, "url": get_url(
|
||||
file_path=song_id+'/'+i, t=token)}
|
||||
else:
|
||||
re['chart'][i[0]] = {"checksum": checksum}
|
||||
|
||||
if url_flag:
|
||||
c.execute('''insert into download_token values(:a,:b,:c,:d,:e)''', {
|
||||
'a': user_id, 'b': song_id, 'c': i, 'd': token, 'e': now})
|
||||
|
||||
return {song_id: re}
|
||||
|
||||
|
||||
def get_all_songs(user_id, file_dir='./database/songs'):
|
||||
def get_all_songs(user_id, file_dir='./database/songs', url_flag=True):
|
||||
# 获取所有歌的下载链接,返回字典
|
||||
dir_list = os.listdir(file_dir)
|
||||
re = {}
|
||||
with Connect() as c:
|
||||
for i in dir_list:
|
||||
if os.path.isdir(os.path.join(file_dir, i)):
|
||||
re.update(get_one_song(c, user_id, i, file_dir))
|
||||
re.update(get_one_song(c, user_id, i, file_dir, url_flag))
|
||||
|
||||
return re
|
||||
|
||||
|
||||
@@ -569,6 +569,14 @@ def arc_score_check(user_id, song_id, difficulty, score, shiny_perfect_count, pe
|
||||
if abs(ascore - score) >= 5:
|
||||
return False
|
||||
|
||||
with Connect() as c: # 歌曲谱面MD5检查,服务器没有谱面就不管了
|
||||
c.execute('''select md5 from songfile where song_id=:a and file_type=:b''', {
|
||||
'a': song_id, 'b': int(difficulty)})
|
||||
x = c.fetchone()
|
||||
if x:
|
||||
if x[0] != song_hash:
|
||||
return False
|
||||
|
||||
x = song_token + song_hash + song_id + str(difficulty) + str(score) + str(shiny_perfect_count) + str(
|
||||
perfect_count) + str(near_count) + str(miss_count) + str(health) + str(modifier) + str(clear_type)
|
||||
y = str(user_id) + song_hash
|
||||
|
||||
@@ -168,9 +168,10 @@ def auth_required(request):
|
||||
user_id = None
|
||||
with Connect() as c:
|
||||
headers = request.headers
|
||||
token = headers['Authorization']
|
||||
token = token[7:]
|
||||
user_id = token_get_id(token)
|
||||
if 'Authorization' in headers:
|
||||
token = headers['Authorization']
|
||||
token = token[7:]
|
||||
user_id = token_get_id(token)
|
||||
|
||||
if user_id is not None:
|
||||
return view(user_id, *args, **kwargs)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from server.sql import Connect
|
||||
import server.arcworld
|
||||
import server.arcpurchase
|
||||
import server.arcdownload
|
||||
import time
|
||||
from setting import Config
|
||||
|
||||
@@ -198,7 +199,7 @@ def get_value_0(c, user_id):
|
||||
"max_stamina_ts": 1586274871917,
|
||||
"stamina": 12,
|
||||
"world_unlocks": ["scenery_chap1", "scenery_chap2", "scenery_chap3", "scenery_chap4", "scenery_chap5"],
|
||||
"world_songs": ["babaroque", "shadesoflight", "kanagawa", "lucifer", "anokumene", "ignotus", "rabbitintheblackroom", "qualia", "redandblue", "bookmaker", "darakunosono", "espebranch", "blacklotus", "givemeanightmare", "vividtheory", "onefr", "gekka", "vexaria3", "infinityheaven3", "fairytale3", "goodtek3", "suomi", "rugie", "faintlight", "harutopia", "goodtek", "dreaminattraction", "syro", "diode", "freefall", "grimheart", "blaster", "cyberneciacatharsis", "monochromeprincess", "revixy", "vector", "supernova", "nhelv", "purgatorium3", "dement3", "crossover", "guardina", "axiumcrisis", "worldvanquisher", "sheriruth", "pragmatism", "gloryroad", "etherstrike", "corpssansorganes", "lostdesire", "blrink", "essenceoftwilight", "lapis", "solitarydream", "lumia3", "purpleverse", "moonheart3", "glow", "enchantedlove", "take"],
|
||||
"world_songs": ["babaroque", "shadesoflight", "kanagawa", "lucifer", "anokumene", "ignotus", "rabbitintheblackroom", "qualia", "redandblue", "bookmaker", "darakunosono", "espebranch", "blacklotus", "givemeanightmare", "vividtheory", "onefr", "gekka", "vexaria3", "infinityheaven3", "fairytale3", "goodtek3", "suomi", "rugie", "faintlight", "harutopia", "goodtek", "dreaminattraction", "syro", "diode", "freefall", "grimheart", "blaster", "cyberneciacatharsis", "monochromeprincess", "revixy", "vector", "supernova", "nhelv", "purgatorium3", "dement3", "crossover", "guardina", "axiumcrisis", "worldvanquisher", "sheriruth", "pragmatism", "gloryroad", "etherstrike", "corpssansorganes", "lostdesire", "blrink", "essenceoftwilight", "lapis", "solitarydream", "lumia3", "purpleverse", "moonheart3", "glow", "enchantedlove", "take", "lifeispiano"],
|
||||
"singles": get_user_singles(c, user_id),
|
||||
"packs": get_user_packs(c, user_id),
|
||||
"characters": characters,
|
||||
@@ -226,7 +227,7 @@ def arc_aggregate_small(user_id):
|
||||
|
||||
|
||||
def arc_aggregate_big(user_id):
|
||||
# 返回用户数据和地图歌曲信息
|
||||
# 返回比较全的用户数据
|
||||
r = {"success": False}
|
||||
with Connect() as c:
|
||||
r = {"success": True,
|
||||
@@ -238,7 +239,7 @@ def arc_aggregate_big(user_id):
|
||||
"value": server.arcpurchase.get_item(c, 'pack')
|
||||
}, {
|
||||
"id": 2,
|
||||
"value": {}
|
||||
"value": server.arcdownload.get_all_songs(user_id, url_flag=False)
|
||||
}, {
|
||||
"id": 3,
|
||||
"value": {
|
||||
|
||||
29
latest version/server/init.py
Normal file
29
latest version/server/init.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
|
||||
|
||||
def check_before_run(app):
|
||||
# 运行前检查关键文件,返回布尔值,其实是因为有人经常忘了
|
||||
|
||||
f = True
|
||||
|
||||
if not os.path.exists('setting.py'):
|
||||
app.logger.warning('File `setting.py` is missing.')
|
||||
f = False
|
||||
|
||||
if not os.path.exists('database'):
|
||||
app.logger.warning('Folder `database` is missing.')
|
||||
f = False
|
||||
|
||||
if not os.path.exists('database/songs'):
|
||||
app.logger.warning('Folder `database/songs` is missing.')
|
||||
f = False
|
||||
|
||||
if not os.path.exists('database/arcaea_database.db'):
|
||||
app.logger.warning('File `database/arcaea_database.db` is missing.')
|
||||
f = False
|
||||
|
||||
if not os.path.exists('database/arcsong.db'):
|
||||
app.logger.warning('File `database/arcsong.db` is missing.')
|
||||
f = False
|
||||
|
||||
return f
|
||||
Reference in New Issue
Block a user