mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Formatting of conjurer_musician
This commit is contained in:
@@ -41,6 +41,7 @@ if platform in ("linux", "linux2"):
|
||||
music_file_list = []
|
||||
priority_list = []
|
||||
|
||||
|
||||
def create_playlist():
|
||||
"""
|
||||
Reads a JSON file containing a playlist and writes the playlist items to a text file.
|
||||
@@ -65,9 +66,7 @@ def create_playlist():
|
||||
pass
|
||||
|
||||
with open("/home/pi/Conjurer/prio_playlist.json", "r+", encoding="utf-8") as r_file:
|
||||
with open(
|
||||
"/home/pi/Conjurer/hit.playlist", "w", encoding="utf-8"
|
||||
) as w_file:
|
||||
with open("/home/pi/Conjurer/hit.playlist", "w", encoding="utf-8") as w_file:
|
||||
try:
|
||||
playlist = json.load(r_file)
|
||||
for item in playlist:
|
||||
@@ -228,7 +227,9 @@ def wyszukaj(word_list, how_many, _logger=None, return_to_bot=True):
|
||||
return_list.append(search_weight[itr])
|
||||
if not return_to_bot:
|
||||
with open(
|
||||
"/home/pi/Conjurer/priority_queue.playlist", "r+", encoding="utf-8"
|
||||
"/home/pi/Conjurer/priority_queue.playlist",
|
||||
"r+",
|
||||
encoding="utf-8",
|
||||
) as s_file:
|
||||
s_file.write(search_weight[itr][1])
|
||||
break
|
||||
@@ -240,7 +241,7 @@ def wyszukaj(word_list, how_many, _logger=None, return_to_bot=True):
|
||||
if not return_to_bot:
|
||||
|
||||
with open(
|
||||
"/home/pi/Conjurer/priority_queue.playlist", "a", encoding="utf-8"
|
||||
"/home/pi/Conjurer/priority_queue.playlist", "a", encoding="utf-8"
|
||||
) as s_file:
|
||||
for item in return_list:
|
||||
s_file.write(item[1] + "\n")
|
||||
@@ -285,7 +286,8 @@ def stream_music():
|
||||
"""
|
||||
return send_from_directory("/tmp/hls", "stream.m3u8")
|
||||
|
||||
@app.route('/<string:file_name>')
|
||||
|
||||
@app.route("/<string:file_name>")
|
||||
def stream(file_name):
|
||||
"""
|
||||
Stream the specified file from the video directory.
|
||||
@@ -296,7 +298,7 @@ def stream(file_name):
|
||||
Returns:
|
||||
Response: The response containing the streamed file.
|
||||
"""
|
||||
video_dir = '/tmp/hls'
|
||||
video_dir = "/tmp/hls"
|
||||
return send_from_directory(video_dir, file_name)
|
||||
|
||||
|
||||
@@ -320,13 +322,12 @@ def clear_pr_pls():
|
||||
"""
|
||||
with open(
|
||||
"/home/pi/Conjurer/priority_queue.playlist", "w", encoding="utf-8"
|
||||
) as s_file:
|
||||
) as s_file:
|
||||
s_file.truncate(0)
|
||||
return_data = jsonify(isError=False, message="Success", statusCode=200, data=[])
|
||||
return return_data, 200
|
||||
|
||||
|
||||
|
||||
@app.route("/mp3", methods=["GET"])
|
||||
def get_music_list():
|
||||
"""
|
||||
@@ -374,7 +375,9 @@ def look_for_playlist():
|
||||
app.logger.info(record["lista_slow"])
|
||||
app.logger.info(record["UUID"])
|
||||
app.logger.info(record["dlugosc_plejlisty"])
|
||||
return_data = wyszukaj(record["lista_slow"], record["dlugosc_plejlisty"], app.logger, True)
|
||||
return_data = wyszukaj(
|
||||
record["lista_slow"], record["dlugosc_plejlisty"], app.logger, True
|
||||
)
|
||||
|
||||
return_data = (
|
||||
jsonify(isError=False, message="Success", statusCode=200, data=return_data),
|
||||
@@ -382,6 +385,7 @@ def look_for_playlist():
|
||||
)
|
||||
return return_data
|
||||
|
||||
|
||||
@app.route("/add_to_priority", methods=["POST"])
|
||||
def add_to_priority():
|
||||
"""
|
||||
@@ -398,7 +402,9 @@ def add_to_priority():
|
||||
app.logger.info(record["lista_slow"])
|
||||
app.logger.info(record["UUID"])
|
||||
app.logger.info(record["dlugosc_plejlisty"])
|
||||
return_data = wyszukaj(record["lista_slow"], record["dlugosc_plejlisty"], app.logger, False)
|
||||
return_data = wyszukaj(
|
||||
record["lista_slow"], record["dlugosc_plejlisty"], app.logger, False
|
||||
)
|
||||
|
||||
return_data = (
|
||||
jsonify(isError=False, message="Success", statusCode=200, data=return_data),
|
||||
@@ -453,7 +459,7 @@ if __name__ == "__main__":
|
||||
rescan()
|
||||
logger.info("Started")
|
||||
threads = []
|
||||
#threads.append(threading.Thread(target=flask_debug))
|
||||
# threads.append(threading.Thread(target=flask_debug))
|
||||
threads.append(threading.Thread(target=waitress_run))
|
||||
threads.append(threading.Thread(target=thread_rescan))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user