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