Code refactoring

- Code refactoring
- Fix a bug that the other player will not become the host of the room at once, when the player disconnect in link play.

> Maybe add many unknown bugs. XD
> The song database `arcsong.db` will not used in the future. You can use a tool in `tool` folder to import old data.
This commit is contained in:
Lost-MSth
2022-07-04 18:36:30 +08:00
parent 9de62d3645
commit 6fcca17918
49 changed files with 3663 additions and 3660 deletions

View File

@@ -1,14 +1,13 @@
from server.sql import Connect
from server.sql import Sql
import time
from core.sql import Connect
from core.sql import Sql
def get_song_info(song_id):
# 查询指定歌曲信息,返回字典
r = {}
with Connect('./database/arcsong.db') as c:
c.execute('''select * from songs where sid=:a''', {'a': song_id})
with Connect('') as c:
c.execute('''select * from chart where song_id=:a''', {'a': song_id})
x = c.fetchone()
if x:
r = {'song_id': x[0],
@@ -34,8 +33,8 @@ def get_songs(query=None):
# 查询全部歌曲信息,返回字典列表
r = []
with Connect('./database/arcsong.db') as c:
x = Sql.select(c, 'songs', [], query)
with Connect('') as c:
x = Sql.select(c, 'chart', [], query)
if x:
for i in x: