mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
70 lines
2.4 KiB
Python
70 lines
2.4 KiB
Python
from pathlib import Path
|
|
from platform import uname
|
|
from sys import platform
|
|
import json
|
|
from flask import Flask, jsonify, request
|
|
import uuid
|
|
|
|
MUSIC_FOLDER = ""
|
|
if platform in ("linux", "linux2"):
|
|
SEPARATOR_FILE_PATH = "/"
|
|
if "microsoft-standard" in uname().release:
|
|
LOGFILE = "/home/mtuszowski/conjurer/discord_mus_service.log"
|
|
MUSIC_FOLDER = "/mnt/g/Muzyka/"
|
|
NETRC_FILE = "/home/mtuszowski/.netrc"
|
|
LOGSTORE = "/home/mtuszowski/conjurer/logs/"
|
|
ENCODING = "utf-8"
|
|
GRAPHICS_PATH = "/home/mtuszowski/conjurer/Conjurer_graphics/"
|
|
|
|
else:
|
|
LOGFILE = "/home/pi/Conjurer/discord_mus_service.log"
|
|
MEMORY_FIVE_SIARA = "/home/pi/Conjurer/pamiec.json"
|
|
SYSTEM_GPT_SETTINGS = "/home/pi/Conjurer/system_gpt_settings.json"
|
|
MEMORY_FIVE_MUZYKA = "/home/pi/Conjurer/pamiec_muzyki.json"
|
|
MUSIC_FOLDER = "/home/pi/RetroPie/mp3/"
|
|
SETTINGS_FILE = "/home/pi/Conjurer/settings.json"
|
|
NETRC_FILE = "/home/pi/.netrc"
|
|
LOGSTORE = "/home/pi/RetroPie/logs/"
|
|
ACCIDENT_LOG = "/home/pi/Conjurer/accident_log.json"
|
|
ENCODING = "utf-8"
|
|
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)
|
|
|
|
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)
|
|
print(record)
|
|
music_file_list.append(record["item"])
|
|
print("========================")
|
|
print(music_file_list[0])
|
|
print(music_file_list[1])
|
|
print(music_file_list[3])
|
|
print("========================")
|
|
return_data = jsonify(isError= False,
|
|
message= "Success",
|
|
statusCode= 200,
|
|
data= record), 200
|
|
return return_data
|
|
|
|
if __name__=='__main__':
|
|
app.run(debug=True, host="0.0.0.0")
|
|
|
|
#TODO: Reskan co 24h
|
|
|
|
#TODO: Informacja o zmianie i update
|
|
|
|
#TODO: Move download Youtube i Spotify tutaj (bedzie potrzebny wtedy rest w obie strony) |