Skip to content

Commit

Permalink
fix songname bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MoYoez committed Jul 24, 2023
1 parent 0c793ba commit 7da51f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 7 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
# init

BestsRender.read_difficulty("difficulty.csv")
BestsRender.read_playerInfo("info.csv")


@app.route('/', methods=["GET"])
@app.route("/", methods=["GET"])
def index():
return jsonify({"message": "Hello World! Phigros API SERVICE IS ALIVE!"})


@app.route('/api/phi/bests', methods=["GET"])
@app.route("/api/phi/bests", methods=["GET"])
def get_bests():
session = request.args.get("session")
overflow = request.args.get("overflow")
Expand All @@ -25,21 +26,21 @@ def get_bests():
else:
overflow = int(overflow)
try:
bests,isphi = BestsRender.get_bests(session, overflow)
bests, isphi = BestsRender.get_bests(session, overflow)
is_phi = {"phi": isphi}
best_list_args = {"bests": bests}
best_list = {**is_phi, **best_list_args}
get_formatData = BestsRender.get_formatData(session)
status = "true"
content = {**best_list, **get_formatData}
data = {"status": status, "content": content}
data = json.dumps(data, ensure_ascii=False).encode('utf-8')
data = json.dumps(data, ensure_ascii=False).encode("utf-8")
data = make_response(data)
data.headers['Content-Type'] = 'application/json; charset=utf-8'
data.headers["Content-Type"] = "application/json; charset=utf-8"
except Exception as e:
return jsonify({"message": str(e)})
return data


if __name__ == '__main__':
if __name__ == "__main__":
app.run(debug=True)
12 changes: 6 additions & 6 deletions method.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def readRecord(self, songId):
fc = self.data[self.position]
self.position += 1
diff = difficulty[songId]
song_names = info[songId]
records = []
song_names = info[songId]
for level in range(len(diff)):
if getBool(exists, level):
scoreAcc = self.readScoreAcc()
scoreAcc["level"] = levels[level]
scoreAcc["fc"] = getBool(fc, level)
scoreAcc["songId"] = songId
scoreAcc["songname"] = songId.split(".")[0]
scoreAcc["songname"] = song_names
scoreAcc["difficulty"] = diff[level]
scoreAcc["rks"] = (scoreAcc["acc"] - 55) / 45
scoreAcc["rks"] = (
Expand Down Expand Up @@ -98,8 +98,8 @@ def parse_render_bests(gameRecord, overflow: int):
records = []
if overflow < 0:
overflow = 0
if overflow > 20:
overflow = 20
if overflow > 21:
overflow = 21
reader = ByteReader(gameRecord)
for i in range(reader.readVarShort()):
songId = reader.readString()[:-2]
Expand Down Expand Up @@ -142,8 +142,8 @@ def read_playerInfo(path):
line = line[:-1].split("\\")
infos = []
for i in range(1, len(line)):
infos.append(float(line[i]))
info[line[0]] = infos[1]
infos.append(str(line[i]))
info[line[0]] = infos[0]

@staticmethod
def get_playerId(sessionToken):
Expand Down

0 comments on commit 7da51f5

Please sign in to comment.