Complete backend redesign to using SQLite #4
1 changed files with 6 additions and 2 deletions
|
|
@ -73,9 +73,13 @@ def playQueuedSongs():
|
||||||
songNext = None
|
songNext = None
|
||||||
player.stop()
|
player.stop()
|
||||||
elif len(playlist)<1 and (partyMode == True):
|
elif len(playlist)<1 and (partyMode == True):
|
||||||
|
fileofDB = sql.connect("songDatabase.db")
|
||||||
|
songDatabase = fileofDB.cursor()
|
||||||
|
songDatabase.execute("SELECT * FROM songs ORDER BY RANDOM() LIMIT 1;")
|
||||||
|
result = songDatabase.fetchall()
|
||||||
# adds the random songs for party mode
|
# adds the random songs for party mode
|
||||||
# the above 2 means this only applies if (a song is playing (or paused)) and the queue is empty
|
# the above 2 means this only applies if (a song is playing (or paused)) and the queue is empty
|
||||||
playlist.append(random.choice(songDatabaseList)["file"])
|
playlist.append(result[0][0])
|
||||||
# check for new songs every second
|
# check for new songs every second
|
||||||
# I just didn't want to eat too much processing looping
|
# I just didn't want to eat too much processing looping
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
@ -174,7 +178,7 @@ def getPlaylist():
|
||||||
tempPlaylist.append({songNext:temp})
|
tempPlaylist.append({songNext:temp})
|
||||||
for i in playlist:
|
for i in playlist:
|
||||||
songDatabase.execute("SELECT * FROM songs WHERE filename = ?",[i])
|
songDatabase.execute("SELECT * FROM songs WHERE filename = ?",[i])
|
||||||
result = songDatabase.fetchall()
|
result = songDatabase.fetchall()[0]
|
||||||
k = {
|
k = {
|
||||||
"title": result[1],
|
"title": result[1],
|
||||||
"artist": result[2],
|
"artist": result[2],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue