Logging + playlist + plans

Fix logger
This commit is contained in:
2024-04-10 20:42:00 +02:00
committed by migatu
parent 5cb51fb296
commit 1caecceb10
2 changed files with 22 additions and 2 deletions
+22 -2
View File
@@ -34,7 +34,7 @@ if platform in ("linux", "linux2"):
NETRC_FILE = "/home/pi/.netrc"
LOGSTORE = "/home/pi/RetroPie/logs/"
ENCODING = "utf-8"
MUSIC_FOLDER = "/home/pi/RetroPie/mp3/"
music_file_list = []
@@ -49,6 +49,14 @@ def rescan():
if platform == "win32":
temp_music_file = temp_music_file.replace("/", "\\")
music_file_list.append(temp_music_file)
with open("playlist.json", "r+", encoding="utf-8") as s_file:
database = music_file_list
#self.app.logger.info("DUMPING DATA")
s_file.truncate(0)
s_file.seek(0)
json.dump(database, s_file)
#TODO: Zobaczyć czy losowo, itp. lepiej po stronie pythona czy po stronei liquidsoapa. Tak samo modyfikowanie playlisty itp. itd.
#TODO: Ale zacząć od odtwarzania playlisty z tego pliku json (może np. się format nie zgadzać albo coś)
def thread_rescan():
"""
@@ -62,7 +70,8 @@ def thread_rescan():
rescan()
app = Flask(__name__)
#TODO: Parametry ustalające czy dajemy zwrotkę do bota czy do streamera ? W każdej z funkcji?
#TODO: Odpalić wyszukiwarki w wątkach i dopiero po wszystkim zsumować wyszukiwanie.
def wyszukaj(word_list, how_many):
logger = logging.getLogger()
return_list = []
@@ -118,6 +127,7 @@ def wyszukaj(word_list, how_many):
else:
skip = 4
matched_times = 1
#TODO: To do wątków albo for asynchroniczny
for itm in all_words[skip:]:
pingu += 1
pattern = ".*" + word + ".*"
@@ -181,6 +191,16 @@ def remove_characters(string, character):
"""
return string.replace(character, "")
@app.route("/stream", methods=["GET"])
def stream_music():
"""
The function `get_music_list` returns a JSON object containing a list of music files.
:return: A JSON response containing a key "music_file_list" with the value of the variable
`music_file_list`.
"""
return jsonify({"music_file_list": music_file_list})
@app.route("/mp3", methods=["GET"])
def get_music_list():
View File