This commit is contained in:
2024-03-29 23:12:37 +01:00
parent c4368244e8
commit ca21ac49ae
+7 -5
View File
@@ -4,7 +4,7 @@ from platform import uname
import threading
import time
from sys import platform
import logging
from flask import Flask, jsonify, request
if platform in ("linux", "linux2"):
@@ -33,7 +33,8 @@ if platform in ("linux", "linux2"):
music_file_list = []
def rescan(logger):
def rescan():
logger = logging.getLogger("conjurer_musician")
logger.info("Rescan triggered")
for mp3_item in Path.glob(Path(MUSIC_FOLDER), "**/*.mp3"):
temp_music_file = mp3_item.as_posix()
@@ -41,7 +42,8 @@ def rescan(logger):
temp_music_file = temp_music_file.replace("/", "\\")
music_file_list.append(temp_music_file)
def thread_rescan(name,logger):
def thread_rescan(name):
logger = logging.getLogger("conjurer_musician")
logger.info(f"Starting filesystemupdater {name}")
while True:
time.sleep(60*60*24)
@@ -69,8 +71,8 @@ def update_music_list():
if __name__ == "__main__":
print(app.logger.name)
rescan(app.logger.getChild("BGtask"))
thread = threading.Thread(target=thread_rescan, args=["Updater",app.logger.getChild("BGtask")])
rescan()
thread = threading.Thread(target=thread_rescan, args=(1,))
thread.start()
app.run(debug=True, host="0.0.0.0")
#from waitress import serve