with current_track_id.get_lock():
current_track_id.value = 1
-audio_path = "/home/stream/critters/audio/"
-cover_path = "/home/stream/critters/cover/"
-icon_path = "/home/stream/critters/icon/"
-upload_path = "/home/stream/critters/upload/"
-template_path = "/home/stream/critters/critters-api/templates/"
+critters_path = os.environ["CRITTERS_PATH"]
+audio_path = critters_path + "/audio/"
+cover_path = critters_path + "/cover/"
+icon_path = critters_path + "/icon/"
+upload_path = critters_path + "/upload/"
+templates_path = critters_path + "/critters-api/templates/"
+db_path = critters_path + "/../metadata.db"
def check_files(track_id):
return {
"icon_path": url_for("get_icon", track_id=track_id)
}
-with open("/home/stream/critters/secrets.json", "r") as f:
+with open(critters_path + "/secrets.json", "r") as f:
users = json.loads(f.read())
users = {k: generate_password_hash(v) for (k, v) in users.items()}
# Homepage
@app.route("/")
def homepage():
- with open(template_path + "home.html","r") as f:
+ with open(templates_path + "home.html", "r") as f:
page = render_template_string(f.read())
return Response(page, mimetype="text/html")
@auth.login_required
def admin():
if request.method == "POST":
- con = sqlite3.connect("/home/stream/metadata.db")
+ con = sqlite3.connect(db_path)
cur = con.cursor()
try: commit_id = int(request.form["id"])
else:
playing = "false"
+ print(playing)
+
# Get the new track id if neccicary
if commit_id == 0:
tracks = cur.execute(f"SELECT id FROM critters").fetchall()
os.system(f"convert {file_path} -scale 32x32! {icon_path}{commit_id}.png &")
os.system(f"convert {file_path} -scale 600x600! {cover_path}{commit_id}.png &")
- with open(template_path + "admin.html", "r") as f:
+ with open(templates_path + "admin.html", "r") as f:
page = render_template_string(f.read(), user = auth.current_user())
return Response(page, mimetype="text/html")
current_album = ""
current_artist = ""
- con = sqlite3.connect("/home/stream/metadata.db")
+ con = sqlite3.connect(db_path)
cur = con.cursor()
track = cur.execute(f"SELECT album, artist FROM critters WHERE id={track_id}").fetchone()
}
responce_data = [track_data]
- con = sqlite3.connect("/home/stream/metadata.db")
+ con = sqlite3.connect(db_path)
cur = con.cursor()
tracks = cur.execute(f"SELECT * FROM critters").fetchall()
if tracks is not None:
if track_id == 0:
with current_track_id.get_lock():
track_id = current_track_id.value
- con = sqlite3.connect("/home/stream/metadata.db")
+ con = sqlite3.connect(db_path)
cur = con.cursor()
track = cur.execute(f"SELECT * FROM critters WHERE id={track_id}").fetchone()
track_data = {
track_id = current_track_id.value
result = "Unknown"
if feild in db_keys:
- con = sqlite3.connect("/home/stream/metadata.db")
+ con = sqlite3.connect(db_path)
cur = con.cursor()
track = cur.execute(f"SELECT {feild} FROM critters WHERE id={track_id}").fetchone()
if track is not None: