Changed song selection screen

This commit is contained in:
LoveEevee
2018-09-26 21:30:57 +03:00
parent 74a9813c14
commit 71e180c7d7
16 changed files with 1663 additions and 428 deletions

25
app.py
View File

@@ -69,6 +69,11 @@ def close_connection(exception):
@app.route('/api/songs')
def route_api_songs():
songs = query_db('select * from songs where enabled = 1')
raw_categories = query_db('select * from categories')
categories = {}
def_category = {'title': None, 'title_en': None}
for cat in raw_categories:
categories[cat[0]] = {'title': cat[1], 'title_en': cat[2]}
songs_out = []
for song in songs:
osus = [osu for osu in os.listdir('public/songs/%s' % song[0]) if osu in ['easy.osu', 'normal.osu', 'hard.osu', 'oni.osu']]
@@ -77,13 +82,19 @@ def route_api_songs():
preview = int(get_osu_key(osud, 'General', 'PreviewTime', 0))
else:
preview = 0
songs_out.append(
{'id': song[0], 'title': song[1], 'title_en': song[2], 'stars': {
'easy': song[3], 'normal': song[4],
'hard': song[5], 'oni': song[6]
}, 'preview': preview}
)
category_out = categories[song[8]] if song[8] in categories else def_category
songs_out.append({
'id': song[0],
'title': song[1],
'title_en': song[2],
'stars': [
song[3], song[4], song[5], song[6]
],
'preview': preview,
'category': category_out['title'],
'category_en': category_out['title_en']
})
return jsonify(songs_out)