mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Test
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from platform import uname
|
||||
import threading
|
||||
import time
|
||||
from sys import platform
|
||||
|
||||
from flask import Flask, jsonify, request
|
||||
|
||||
MUSIC_FOLDER = ""
|
||||
if platform in ("linux", "linux2"):
|
||||
SEPARATOR_FILE_PATH = "/"
|
||||
if "microsoft-standard" in uname().release:
|
||||
@@ -30,22 +31,30 @@ if platform in ("linux", "linux2"):
|
||||
GRAPHICS_PATH = "/home/pi/RetroPie/Conjurer_graphics/"
|
||||
DIR_PATH_SADOX = "/home/pi/RetroPie/Fansadox/"
|
||||
|
||||
|
||||
music_file_list = []
|
||||
for mp3_item in Path.glob(Path(MUSIC_FOLDER), "**/*.mp3"):
|
||||
temp_music_file = mp3_item.as_posix()
|
||||
if platform == "win32":
|
||||
temp_music_file = temp_music_file.replace("/", "\\")
|
||||
music_file_list.append(temp_music_file)
|
||||
|
||||
def rescan():
|
||||
for mp3_item in Path.glob(Path(MUSIC_FOLDER), "**/*.mp3"):
|
||||
temp_music_file = mp3_item.as_posix()
|
||||
if platform == "win32":
|
||||
temp_music_file = temp_music_file.replace("/", "\\")
|
||||
music_file_list.append(temp_music_file)
|
||||
|
||||
def thread_rescan(name,logger):
|
||||
logger.info(f"Starting filesystemupdater {name}")
|
||||
while True:
|
||||
time.sleep(60)
|
||||
logger.info("Rescan triggered {name}")
|
||||
rescan()
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route("/mp3", methods=["GET"])
|
||||
def get_music_list():
|
||||
return jsonify({"music_file_list": music_file_list})
|
||||
|
||||
|
||||
# TODO: Przyjecie informacji o zmianie i dodanie pliku saute
|
||||
@app.route("/update_mp3", methods=["POST"])
|
||||
def update_music_list():
|
||||
record = json.loads(request.data)
|
||||
@@ -59,12 +68,9 @@ def update_music_list():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
#app.run(debug=True, host="0.0.0.0")
|
||||
from waitress import serve
|
||||
serve(app, host="0.0.0.0", port=5000)
|
||||
thread = threading.Thread(target=thread_rescan, args=("Updater",app.logger))
|
||||
app.run(debug=True, host="0.0.0.0")
|
||||
#from waitress import serve
|
||||
#serve(app, host="0.0.0.0", port=5000)
|
||||
|
||||
# TODO: Reskan co 24h
|
||||
|
||||
# TODO: Informacja o zmianie i update
|
||||
|
||||
# TODO: Move download Youtube i Spotify tutaj (bedzie potrzebny wtedy rest w obie strony)
|
||||
#TODO: Inne pliki - sadox, dokumenty naukowe itp.
|
||||
|
||||
+2
-1
@@ -9,4 +9,5 @@ pdf2image
|
||||
PyPDF2
|
||||
requests
|
||||
spotipy
|
||||
tiktoken
|
||||
tiktoken
|
||||
PyNaCl
|
||||
Reference in New Issue
Block a user