From fbb1bf5266b08fe32091e300f759115ed5f1b428 Mon Sep 17 00:00:00 2001 From: UnitedAirforce Date: Sun, 11 May 2025 20:37:22 +0800 Subject: [PATCH] Adaptions for new server codebase --- 7001.py | 33 +++++++++---------- .../config/avatar_list.json | 0 .../config/exp_unlocked_songs.json | 0 item_list.json => api/config/item_list.json | 0 song_list.json => api/config/song_list.json | 0 config.py => config_old.py | 0 6 files changed, 16 insertions(+), 17 deletions(-) rename avatar_list.json => api/config/avatar_list.json (100%) rename exp_unlocked_songs.json => api/config/exp_unlocked_songs.json (100%) rename item_list.json => api/config/item_list.json (100%) rename song_list.json => api/config/song_list.json (100%) rename config.py => config_old.py (100%) diff --git a/7001.py b/7001.py index a6cad9f..62e2081 100644 --- a/7001.py +++ b/7001.py @@ -1,5 +1,5 @@ from flask import Flask, request, jsonify, send_file -from config import Config +from config_old import Config import os import sqlite3 import binascii @@ -13,19 +13,19 @@ import json import requests try: - with open("song_list.json", 'r', encoding="utf-8") as file: + with open("api/config/song_list.json", 'r', encoding="utf-8") as file: song_list = json.load(file) except Exception as e: print(f"An unexpected error occurred when loading song_list.json: {e}") try: - with open("avatar_list.json", 'r', encoding="utf-8") as file: + with open("api/config/avatar_list.json", 'r', encoding="utf-8") as file: avatar_list = json.load(file) except Exception as e: print(f"An unexpected error occurred when loading avatar_list.json: {e}") try: - with open("item_list.json", 'r', encoding="utf-8") as file: + with open("api/config/item_list.json", 'r', encoding="utf-8") as file: item_list = json.load(file) except Exception as e: print(f"An unexpected error occurred when loading item_list.json: {e}") @@ -64,7 +64,7 @@ exclude_stage_exp = [121,134,166,167,168,169,170,213,214,215,225,277] # 134 and exclude_avatar_exp = [28,29] try: - with open("exp_unlocked_songs.json", 'r', encoding="utf-8") as file: + with open("api/config/exp_unlocked_songs.json", 'r', encoding="utf-8") as file: exp_unlocked_songs = json.load(file) except Exception as e: print(f"An unexpected error occurred when loading exp_unlocked_songs.json: {e}") @@ -330,9 +330,7 @@ def inform_page(text, mode): with open("files/inform.html", "r") as file: return file.read().format(text=text, img=mode) -#Serving CDN files root_folder = os.path.dirname(os.path.abspath(__file__)) -allowed_folders = ["files"] @app.route('/info.php', methods=['GET']) def info(): @@ -579,9 +577,6 @@ def bonus(): daily_reward_elem = root.find(".//login_bonus") last_count_elem = daily_reward_elem.find("last_count") - - - if last_count_elem is None or not last_count_elem.text.isdigit(): return jsonify({"error": "Invalid or missing last_count in XML"}), 500 last_count = int(last_count_elem.text) @@ -590,14 +585,14 @@ def bonus(): cursor = connection.cursor() # Check for an existing row - cursor.execute("SELECT day, timestamp, my_avatar, my_stage FROM daily_reward WHERE device_id = ?", (device_id,)) + cursor.execute("SELECT day, timestamp FROM daily_reward WHERE device_id = ?", (device_id,)) row = cursor.fetchone() time = datetime.now() formatted_time = time.strftime("%Y-%m-%d %H:%M:%S") if row is not None: - current_day, last_timestamp, my_avatar, my_stage = row + current_day, last_timestamp = row last_date = datetime.strptime(last_timestamp, "%Y-%m-%d %H:%M:%S") # Check if one day has passed @@ -626,7 +621,7 @@ def bonus(): my_avatar = json.dumps(list(avatars)) # Update the table - cursor.execute("""UPDATE daily_reward SET timestamp = ?, day = ?, my_avatar = ?, my_stage = ? WHERE device_id = ?""", (formatted_time, current_day, my_avatar, my_stage, device_id)) + cursor.execute("""UPDATE daily_reward SET timestamp = ?, day = ? WHERE device_id = ?""", (formatted_time, current_day, device_id)) # return 0 obj xml_response = "0" @@ -1264,7 +1259,7 @@ def ranking_detail(): row_content.append(f"""
{label}
""") else: encrypted_mass = encryptAES(("vid=" + device_id + "&song_id=" + str(song_id) + "&mode=" + str(mode_value) + "&dummy=").encode("utf-8")) - row_content.append(f"""{label}""") + row_content.append(f"""{label}""") if len(row_content) == 3: html += row_start + ''.join(row_content) + row_end @@ -1466,7 +1461,7 @@ def ranking_detail(): encrypted_mass = encryptAES(("vid=" + device_id + "&dummy=").encode("utf-8")) html += f""" - + Go Back """ @@ -1541,7 +1536,7 @@ def status(): else: encrypted_mass = encryptAES(f"vid={device_id}&page_id={i}&dummy=".encode("utf-8")) buttons_html += f""" - + {page_name[i]} """ @@ -1821,6 +1816,10 @@ def delete_account(): # this only tricks the client to clear its local data for now return """0""" +#Serving CDN files +root_folder = os.path.dirname(os.path.abspath(__file__)) +allowed_folders = ["files"] + @app.route('/', methods=['GET']) def get_file(path): file_path = os.path.join(root_folder, path) @@ -1837,4 +1836,4 @@ if __name__ == '__main__': if app.config['SSL_CERT'] and app.config['SSL_KEY']: app.run(host=app.config['HOST'], port=app.config['PORT'], debug=app.config['DEBUG'], ssl_context=(app.config['SSL_CERT'], app.config['SSL_KEY'])) else: - app.run(host=app.config['HOST'], port=app.config['PORT'], debug=app.config['DEBUG']) + app.run(host=app.config['HOST'], port=app.config['PORT'], debug=app.config['DEBUG']) \ No newline at end of file diff --git a/avatar_list.json b/api/config/avatar_list.json similarity index 100% rename from avatar_list.json rename to api/config/avatar_list.json diff --git a/exp_unlocked_songs.json b/api/config/exp_unlocked_songs.json similarity index 100% rename from exp_unlocked_songs.json rename to api/config/exp_unlocked_songs.json diff --git a/item_list.json b/api/config/item_list.json similarity index 100% rename from item_list.json rename to api/config/item_list.json diff --git a/song_list.json b/api/config/song_list.json similarity index 100% rename from song_list.json rename to api/config/song_list.json diff --git a/config.py b/config_old.py similarity index 100% rename from config.py rename to config_old.py