mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-11 10:27:27 +08:00
[Enhance] Content bundle
- Add support for content bundles - For Arcaea 5.4.0 play store version and iOS version
This commit is contained in:
@@ -3,8 +3,9 @@ from traceback import format_exc
|
||||
|
||||
from flask import current_app, g, jsonify
|
||||
|
||||
from core.bundle import BundleParser
|
||||
from core.config_manager import Config
|
||||
from core.error import ArcError, NoAccess
|
||||
from core.error import ArcError, LowVersion, NoAccess
|
||||
|
||||
has_arc_hash = False
|
||||
try:
|
||||
@@ -22,7 +23,9 @@ def error_return(e: ArcError = default_error): # 错误返回
|
||||
# -4 您的账号已在别处登录
|
||||
# -3 无法连接至服务器
|
||||
# 2 Arcaea服务器正在维护
|
||||
# 5 请更新 Arcaea 到最新版本
|
||||
# 9 新版本请等待几分钟
|
||||
# 11 有游戏内容需要更新,即将返回主界面
|
||||
# 100 无法在此ip地址下登录游戏
|
||||
# 101 用户名占用
|
||||
# 102 电子邮箱已注册
|
||||
@@ -41,7 +44,7 @@ def error_return(e: ArcError = default_error): # 错误返回
|
||||
# 150 非常抱歉您已被限制使用此功能
|
||||
# 151 目前无法使用此功能
|
||||
# 160 账户未邮箱认证,请检查邮箱
|
||||
# 161 账户认证过期,请重新注册
|
||||
# 161 账户认证过期,请重新注册
|
||||
# 401 用户不存在
|
||||
# 403 无法连接至服务器
|
||||
# 501 502 -6 此物品目前无法获取
|
||||
@@ -65,7 +68,7 @@ def error_return(e: ArcError = default_error): # 错误返回
|
||||
# 9803 下载已取消
|
||||
# 9905 没有在云端发现任何数据
|
||||
# 9907 更新数据时发生了问题
|
||||
# 9908 服务器只支持最新的版本,请更新Arcaea
|
||||
# 9908 服务器只支持最新的版本,请更新 Arcaea
|
||||
# 其它 发生未知错误
|
||||
r = {"success": False, "error_code": e.error_code}
|
||||
if e.extra_data:
|
||||
@@ -106,7 +109,10 @@ def header_check(request) -> ArcError:
|
||||
headers = request.headers
|
||||
if Config.ALLOW_APPVERSION: # 版本检查
|
||||
if 'AppVersion' not in headers or headers['AppVersion'] not in Config.ALLOW_APPVERSION:
|
||||
return NoAccess('Invalid app version', 5)
|
||||
return LowVersion('Invalid app version', 5)
|
||||
|
||||
if 'ContentBundle' in headers and headers['ContentBundle'] != BundleParser.max_bundle_version[headers['AppVersion']]:
|
||||
return LowVersion('Invalid content bundle version', 11)
|
||||
|
||||
if has_arc_hash and not ArcHashChecker(request).check():
|
||||
return NoAccess('Invalid request')
|
||||
|
||||
@@ -4,6 +4,7 @@ from urllib.parse import parse_qs, urlparse
|
||||
from flask import Blueprint, jsonify, request
|
||||
from werkzeug.datastructures import ImmutableMultiDict
|
||||
|
||||
from core.bundle import BundleDownload
|
||||
from core.download import DownloadList
|
||||
from core.error import RateLimit
|
||||
from core.sql import Connect
|
||||
@@ -26,26 +27,19 @@ def game_info():
|
||||
return success_return(GameInfo().to_dict())
|
||||
|
||||
|
||||
# @bp.route('/game/content_bundle', methods=['GET']) # 热更新
|
||||
# def game_content_bundle():
|
||||
# app_version = request.headers.get('AppVersion')
|
||||
# bundle_version = request.headers.get('ContentBundle')
|
||||
# import os
|
||||
# if bundle_version != '5.4.0':
|
||||
# r = {'orderedResults': [
|
||||
# {
|
||||
# 'appVersion': '5.4.0',
|
||||
# 'contentBundleVersion': '5.4.0',
|
||||
# 'jsonUrl': 'http://192.168.0.110/bundle_download/bundle.json',
|
||||
# 'jsonSize': os.path.getsize('./database/bundle/bundle.json'),
|
||||
# 'bundleUrl': 'http://192.168.0.110/bundle_download/bundle',
|
||||
# 'bundleSize': os.path.getsize('./database/bundle/bundle')
|
||||
# },
|
||||
# ]
|
||||
# }
|
||||
# else:
|
||||
# r = {}
|
||||
# return success_return(r)
|
||||
@bp.route('/game/content_bundle', methods=['GET']) # 热更新
|
||||
@arc_try
|
||||
def game_content_bundle():
|
||||
# error code 5, 9 work
|
||||
app_version = request.headers.get('AppVersion')
|
||||
bundle_version = request.headers.get('ContentBundle')
|
||||
device_id = request.headers.get('DeviceId')
|
||||
with Connect(in_memory=True) as c_m:
|
||||
x = BundleDownload(c_m)
|
||||
x.set_client_info(app_version, bundle_version, device_id)
|
||||
return success_return({
|
||||
'orderedResults': x.get_bundle_list()
|
||||
})
|
||||
|
||||
|
||||
@bp.route('/serve/download/me/song', methods=['GET']) # 歌曲下载
|
||||
|
||||
Reference in New Issue
Block a user