[Enhance][Bug fix] Improve setting file & ...

- Fix a small bug that `best30` of API cannot have scores whose songs are not in database
- At present the setting file can be a module or a file with some of options
- Limiter can have multiple rules together now
This commit is contained in:
Lost-MSth
2022-10-16 15:49:49 +08:00
parent 68a83a29d2
commit ba36190f30
23 changed files with 458 additions and 86 deletions

View File

@@ -1,5 +1,5 @@
from core.config_manager import Config
from flask import Blueprint
from setting import Config
from . import (auth, course, friend, multiplayer, others, present, purchase,
score, user, world)

View File

@@ -1,11 +1,11 @@
import base64
from functools import wraps
from core.config_manager import Config
from core.error import ArcError, NoAccess
from core.sql import Connect
from core.user import UserAuth, UserLogin
from flask import Blueprint, jsonify, request
from setting import Config
from .func import arc_try, error_return

View File

@@ -1,9 +1,9 @@
from functools import wraps
from traceback import format_exc
from core.config_manager import Config
from core.error import ArcError
from flask import current_app, jsonify
from setting import Config
default_error = ArcError('Unknown Error', status=500)

View File

@@ -25,10 +25,6 @@ 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

View File

@@ -1,8 +1,8 @@
from core.config_manager import Config
from core.error import ArcError
from core.linkplay import Player, RemoteMultiPlayer, Room
from core.sql import Connect
from flask import Blueprint, request
from setting import Config
from .auth import auth_required
from .func import arc_try, success_return

View File

@@ -2,7 +2,7 @@ import json
from urllib.parse import parse_qs, urlparse
from core.download import DownloadList
from core.error import ArcError
from core.error import RateLimit
from core.sql import Connect
from core.system import GameInfo
from core.user import UserOnline
@@ -34,7 +34,7 @@ def download_song(user_id):
x.song_ids = request.args.getlist('sid')
x.url_flag = json.loads(request.args.get('url', 'true'))
if x.url_flag and x.is_limited:
raise ArcError('You have reached the download limit.', 903)
raise RateLimit('You have reached the download limit.', 903)
x.add_songs()
return success_return(x.urls)

View File

@@ -1,11 +1,11 @@
from core.character import UserCharacter
from core.config_manager import Config
from core.error import ArcError, NoAccess
from core.item import ItemCore
from core.save import SaveData
from core.sql import Connect
from core.user import User, UserLogin, UserOnline, UserRegister
from flask import Blueprint, request
from setting import Config
from .auth import auth_required
from .func import arc_try, success_return