mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-19 08:12:09 +00:00
Tag: 1.3
Intermediate commits (oldest → newest): - Almost deployment versio - for full deployment change parameteres in search_bot - Preparation for deployment - Main bot (#1) - Search webservice (#2) - Music service (#3) - FIx
This commit is contained in:
@@ -14,6 +14,7 @@ from sys import platform
|
||||
import logging
|
||||
from flask import Flask, jsonify, request
|
||||
from waitress import serve
|
||||
from logging import handlers
|
||||
|
||||
|
||||
HOST_ADDRESS = "192.168.1.15"
|
||||
@@ -26,21 +27,15 @@ if platform in ("linux", "linux2"):
|
||||
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_FOLDER = "/home/pi/RetroPie/mp3/"
|
||||
|
||||
|
||||
|
||||
music_file_list = []
|
||||
@@ -188,6 +183,22 @@ def remove_characters(string, character):
|
||||
return string.replace(character, "")
|
||||
|
||||
|
||||
@app.route("/stream", methods=["GET"])
|
||||
async 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`.
|
||||
"""
|
||||
try:
|
||||
m3u8 = Path("/tmp/hls/stream.m3u8")
|
||||
r = Response(m3u8)
|
||||
r.headers["Content-Type"] = "application/mpegURL"
|
||||
return r, 200
|
||||
except FileNotFoundError:
|
||||
return jsonify({"error": "No stream available"}), 404
|
||||
|
||||
|
||||
@app.route("/mp3", methods=["GET"])
|
||||
def get_music_list():
|
||||
"""
|
||||
@@ -261,6 +272,17 @@ def waitress_run():
|
||||
if __name__ == "__main__":
|
||||
logger = logging.getLogger('conjurer_musician')
|
||||
logger.setLevel(logging.DEBUG)
|
||||
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
handler = handlers.RotatingFileHandler(
|
||||
filename=LOGFILE,
|
||||
encoding=ENCODING,
|
||||
mode="a",
|
||||
maxBytes=6 * 1024 * 1024,
|
||||
backupCount=6,
|
||||
)
|
||||
handler.setFormatter(formatter)
|
||||
logger.addHandler(handler)
|
||||
|
||||
rescan()
|
||||
logger.info("Started")
|
||||
threads = []
|
||||
@@ -272,5 +294,3 @@ if __name__ == "__main__":
|
||||
|
||||
for worker in threads:
|
||||
worker.join()
|
||||
|
||||
#TODO: Inne pliki - sadox, dokumenty naukowe itp.
|
||||
|
||||
@@ -4,7 +4,7 @@ After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/home/pi/Conjurer-service/conjurer/file_webservice/bin/python3 /home/pi/Conjurer-service/conjurer/file_webservice/conjurer_musician.py
|
||||
ExecStart=/home/pi/Conjurer/env/bin/python3 /home/pi/Conjurer/conjurer_musician.py
|
||||
Restart=on-abort
|
||||
|
||||
[Install]
|
||||
|
||||
Reference in New Issue
Block a user