-
Notifications
You must be signed in to change notification settings - Fork 7
/
run.py
39 lines (38 loc) · 1.17 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from jukebox import app
import os
if __name__ == "__main__":
# cleanup leftovers
if os.path.exists("mpv.socket"):
os.remove("mpv.socket")
# create database if it doesn't exists
if not os.path.exists(app.config["DATABASE_PATH"]):
app.logger.info("Databse nonexistent, creating schema")
import sqlite3
conn = sqlite3.connect(app.config["DATABASE_PATH"])
c = conn.cursor()
c.execute("""
CREATE TABLE "users" (
"user" TEXT NOT NULL PRIMARY KEY,
"pass" TEXT
);
""")
c.execute("""CREATE TABLE "track_info" (
"url" TEXT NOT NULL,
"track" TEXT,
"artist" TEXT,
"album" TEXT,
"duration" TEXT,
"albumart_url" TEXT
);
""")
c.execute("""CREATE TABLE log (
"id" INTEGER PRIMARY KEY,
"track" TEXT NOT NULL,
"time" INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
"user" TEXT NOT NULL
);
""")
conn.commit()
conn.close()
# run the flask app
app.run(host=app.config["LISTEN_ADDR"], port=app.config["LISTEN_PORT"])