[Enhance] Restrict download by user's purchase

- An option `DOWNLOAD_FORBID_WHEN_NO_ITEM` has been added to the config file to make that users cannot download the songs' files if they has not bought them when the `songlist` file exists. (Experimental)

#128
This commit is contained in:
Lost-MSth
2023-09-08 11:38:46 +08:00
parent 04c6d1a0e0
commit f373c7b052
6 changed files with 108 additions and 21 deletions

View File

@@ -30,15 +30,16 @@ def game_info():
@auth_required(request)
@arc_try
def download_song(user_id):
with Connect(in_memory=True) as c:
x = DownloadList(c, UserOnline(None, 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 RateLimit('You have reached the download limit.', 903)
with Connect(in_memory=True) as c_m:
with Connect() as c:
x = DownloadList(c_m, UserOnline(c, 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 RateLimit('You have reached the download limit.', 903)
x.add_songs()
return success_return(x.urls)
x.add_songs()
return success_return(x.urls)
@bp.route('/finale/progress', methods=['GET'])