mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-13 19:57:26 +08:00
Add an option
This commit is contained in:
@@ -59,9 +59,10 @@ It is just so interesting. What it can do is under exploration.
|
|||||||
## 更新日志 Update log
|
## 更新日志 Update log
|
||||||
只保留最新版本 Only keep the latest version.
|
只保留最新版本 Only keep the latest version.
|
||||||
|
|
||||||
> 提醒:更新时请注意保留原先的数据库,以防数据丢失
|
> 提醒:更新时请注意保留原先的数据库,以防数据丢失。使用前请先运行**database_initialize.py**以获得初始数据库。
|
||||||
>
|
>
|
||||||
> Tips: When updating, please keep the original database in case of data loss.
|
> Tips: When updating, please keep the original database in case of data loss.
|
||||||
|
> Before using, please run **database_initialize.py** to get the initial database.
|
||||||
|
|
||||||
### Version 2.3.1
|
### Version 2.3.1
|
||||||
- 适用于Arcaea 3.5.3版本 For Arcaea 3.5.3
|
- 适用于Arcaea 3.5.3版本 For Arcaea 3.5.3
|
||||||
|
|||||||
Binary file not shown.
@@ -25,6 +25,23 @@ def get_file_md5(file_path):
|
|||||||
return myhash.hexdigest()
|
return myhash.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def get_url(file_path, **kwargs):
|
||||||
|
# 获取下载地址
|
||||||
|
|
||||||
|
t = ''
|
||||||
|
if 't' in kwargs:
|
||||||
|
t = kwargs['t']
|
||||||
|
|
||||||
|
if Config.DOWNLOAD_LINK_PREFIX:
|
||||||
|
prefix = Config.DOWNLOAD_LINK_PREFIX
|
||||||
|
if prefix[-1] != '/':
|
||||||
|
prefix += '/'
|
||||||
|
|
||||||
|
return prefix + file_path + '?t=' + t
|
||||||
|
else:
|
||||||
|
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'):
|
||||||
# 获取一首歌的下载链接,返回字典
|
# 获取一首歌的下载链接,返回字典
|
||||||
dir_list = os.listdir(os.path.join(file_dir, song_id))
|
dir_list = os.listdir(os.path.join(file_dir, song_id))
|
||||||
@@ -37,7 +54,6 @@ def get_one_song(c, user_id, song_id, file_dir='./database/songs'):
|
|||||||
if os.path.isfile(os.path.join(file_dir, song_id, i)) and i in ['0.aff', '1.aff', '2.aff', '3.aff', 'base.ogg']:
|
if os.path.isfile(os.path.join(file_dir, song_id, i)) and i in ['0.aff', '1.aff', '2.aff', '3.aff', 'base.ogg']:
|
||||||
token = hashlib.md5(
|
token = hashlib.md5(
|
||||||
(str(user_id) + song_id + i + str(now)).encode(encoding='UTF-8')).hexdigest()
|
(str(user_id) + song_id + i + str(now)).encode(encoding='UTF-8')).hexdigest()
|
||||||
token = token[:8]
|
|
||||||
|
|
||||||
if i == 'base.ogg':
|
if i == 'base.ogg':
|
||||||
c.execute(
|
c.execute(
|
||||||
@@ -48,8 +64,8 @@ def get_one_song(c, user_id, song_id, file_dir='./database/songs'):
|
|||||||
else:
|
else:
|
||||||
checksum = get_file_md5(os.path.join(
|
checksum = get_file_md5(os.path.join(
|
||||||
file_dir, song_id, 'base.ogg'))
|
file_dir, song_id, 'base.ogg'))
|
||||||
re['audio'] = {"checksum": checksum,
|
re['audio'] = {"checksum": checksum, "url": get_url(
|
||||||
"url": url_for('download', file_path=song_id+'/base.ogg', t=token, _external=True)}
|
file_path=song_id+'/base.ogg', t=token)}
|
||||||
else:
|
else:
|
||||||
if 'chart' not in re:
|
if 'chart' not in re:
|
||||||
re['chart'] = {}
|
re['chart'] = {}
|
||||||
@@ -60,8 +76,8 @@ def get_one_song(c, user_id, song_id, file_dir='./database/songs'):
|
|||||||
checksum = x[0]
|
checksum = x[0]
|
||||||
else:
|
else:
|
||||||
checksum = get_file_md5(os.path.join(file_dir, song_id, i))
|
checksum = get_file_md5(os.path.join(file_dir, song_id, i))
|
||||||
re['chart'][i[0]] = {"checksum": checksum,
|
re['chart'][i[0]] = {"checksum": checksum, "url": get_url(
|
||||||
"url": url_for('download', file_path=song_id+'/'+i, t=token, _external=True)}
|
file_path=song_id+'/'+i, t=token)}
|
||||||
|
|
||||||
c.execute('''insert into download_token values(:a,:b,:c,:d,:e)''', {
|
c.execute('''insert into download_token values(:a,:b,:c,:d,:e)''', {
|
||||||
'a': user_id, 'b': song_id, 'c': i, 'd': token, 'e': now})
|
'a': user_id, 'b': song_id, 'c': i, 'd': token, 'e': now})
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ class Config():
|
|||||||
SSL certificate path
|
SSL certificate path
|
||||||
If left blank, use HTTP.
|
If left blank, use HTTP.
|
||||||
'''
|
'''
|
||||||
SSL_CERT = '' # *.pem
|
SSL_CERT = '' # *.pem
|
||||||
SSL_KEY = '' # *.key
|
SSL_KEY = '' # *.key
|
||||||
'''
|
'''
|
||||||
--------------------
|
--------------------
|
||||||
'''
|
'''
|
||||||
@@ -59,6 +59,17 @@ class Config():
|
|||||||
--------------------
|
--------------------
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
'''
|
||||||
|
--------------------
|
||||||
|
歌曲下载地址前缀,留空则自动获取
|
||||||
|
Song download address prefix
|
||||||
|
If left blank, it will be obtained automatically.
|
||||||
|
'''
|
||||||
|
DOWNLOAD_LINK_PREFIX = '' # http://***.com/download/
|
||||||
|
'''
|
||||||
|
--------------------
|
||||||
|
'''
|
||||||
|
|
||||||
'''
|
'''
|
||||||
--------------------
|
--------------------
|
||||||
玩家歌曲下载的24小时次数限制,每个文件算一次
|
玩家歌曲下载的24小时次数限制,每个文件算一次
|
||||||
|
|||||||
Reference in New Issue
Block a user