mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Adding playlists, various bufixes and installation scripts
Adding playlists, various bufixes and installation scripts Fixing Rename KUUUURWA Install script music bot fx Fix ? fix Synchro test test Undo tst test tst Undo changes test fx tst fx Test commit of two files priority queue.
This commit is contained in:
@@ -45,7 +45,7 @@ def create_playlist():
|
||||
Reads a JSON file containing a playlist and writes the playlist items to a text file.
|
||||
|
||||
The JSON file path is '/home/pi/Conjurer/playlist.json',
|
||||
and the text file path is '/home/pi/Conjurer/all_playlist.txt'.
|
||||
and the text file path is '/home/pi/Conjurer/all_playlist.playlist'.
|
||||
|
||||
Raises:
|
||||
JSONDecodeError: If the JSON file cannot be decoded.
|
||||
@@ -53,7 +53,7 @@ def create_playlist():
|
||||
"""
|
||||
with open("/home/pi/Conjurer/playlist.json", "r+", encoding="utf-8") as r_file:
|
||||
with open(
|
||||
"/home/pi/Conjurer/all_playlist.txt", "w", encoding="utf-8"
|
||||
"/home/pi/Conjurer/all_playlist.playlist", "w", encoding="utf-8"
|
||||
) as w_file:
|
||||
try:
|
||||
playlist = json.load(r_file)
|
||||
@@ -202,7 +202,7 @@ 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", "w", encoding="utf-8"
|
||||
"/home/pi/Conjurer/priority_queue.playlist", "r+", encoding="utf-8"
|
||||
) as s_file:
|
||||
s_file.write(search_weight[itr][1])
|
||||
break
|
||||
@@ -212,11 +212,13 @@ def wyszukaj(word_list, how_many, _logger=None, return_to_bot=True):
|
||||
search_weight.sort(key=lambda x: x[0], reverse=True)
|
||||
return_list.extend(search_weight[: int(how_many)])
|
||||
if not return_to_bot:
|
||||
for item in return_list:
|
||||
with open(
|
||||
"/home/pi/Conjurer/priority_queue.playlist", "w", encoding="utf-8"
|
||||
) as s_file:
|
||||
s_file.write(item[1])
|
||||
|
||||
with open(
|
||||
"/home/pi/Conjurer/priority_queue.playlist", "r+", encoding="utf-8"
|
||||
) as s_file:
|
||||
s_file.truncate(0)
|
||||
for item in return_list:
|
||||
s_file.write(item[1] + "\n")
|
||||
return return_list
|
||||
|
||||
|
||||
@@ -249,7 +251,7 @@ def remove_characters(string, character):
|
||||
|
||||
|
||||
@app.route("/stream", methods=["GET"])
|
||||
def stream_music_hls():
|
||||
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
|
||||
@@ -257,6 +259,11 @@ def stream_music_hls():
|
||||
"""
|
||||
return send_from_directory("/tmp/hls", "stream.m3u8")
|
||||
|
||||
@app.route('/<string:file_name>')
|
||||
def stream(file_name):
|
||||
video_dir = '/tmp/hls'
|
||||
return send_from_directory(video_dir, file_name)
|
||||
|
||||
|
||||
@app.route("/stream_mp3", methods=["GET"])
|
||||
def stream_music_mp3():
|
||||
@@ -268,6 +275,22 @@ def stream_music_mp3():
|
||||
return redirect("http://www.example.com", code=302)
|
||||
|
||||
|
||||
@app.route("/clear_pr_pls", methods=["GET"])
|
||||
def clear_pr_pls():
|
||||
"""
|
||||
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`.
|
||||
"""
|
||||
with open(
|
||||
"/home/pi/Conjurer/priority_queue.playlist", "w", encoding="utf-8"
|
||||
) 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():
|
||||
"""
|
||||
@@ -315,7 +338,31 @@ 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)
|
||||
return_data = wyszukaj(record["lista_slow"], record["dlugosc_plejlisty"], app.logger, True)
|
||||
|
||||
return_data = (
|
||||
jsonify(isError=False, message="Success", statusCode=200, data=return_data),
|
||||
200,
|
||||
)
|
||||
return return_data
|
||||
|
||||
@app.route("/add_to_priority", methods=["POST"])
|
||||
def add_to_priority():
|
||||
"""
|
||||
The function `update_music_list` receives a POST request with a JSON payload, logs the received
|
||||
item, adds it to a music file list, and returns a success message along with the updated record.
|
||||
:return: The function `update_music_list` is returning a tuple containing a JSON response and a
|
||||
status code. The JSON response includes keys `isError`, `message`, `statusCode`, and `data`,
|
||||
with values indicating the success of the operation and the data that was
|
||||
received and added to the `music_file_list`.
|
||||
The status code returned is 200, indicating a successful response.
|
||||
"""
|
||||
record = json.loads(request.data)
|
||||
app.logger.info(record)
|
||||
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 = (
|
||||
jsonify(isError=False, message="Success", statusCode=200, data=return_data),
|
||||
@@ -1,6 +1,10 @@
|
||||
let json.parse credentials = file.contents("/home/pi/Conjurer/icecast_credentials.json")
|
||||
enable_replaygain_metadata()
|
||||
s = replaygain(playlist(reload_mode="watch", "/home/pi/Conjurer/all_playlist.playlist"))
|
||||
|
||||
s1 = replaygain(playlist(reload_mode="watch", "/home/pi/Conjurer/all_playlist.playlist"))
|
||||
s2 = replaygain(playlist(reload_mode="watch", "/home/pi/Conjurer/priority_queue.playlist"))
|
||||
|
||||
s = random(id="randomizer", weights=[7000, 100], [s2, s1])
|
||||
|
||||
interactive.harbor(port = 9999)
|
||||
f = interactive.float("f", description="Frequency", min=0., max=1000.,unit="Hz", 200.)
|
||||
@@ -17,7 +21,8 @@ s = amplify(a,s)
|
||||
s = blank.skip(max_blank=2., s)
|
||||
|
||||
emergency = single("/home/pi/RetroPie/mp3/Youtube/Dr. Peacock - Trip to Ireland [GvrvQTUbUcA].mp3")
|
||||
radio = fallback([s,emergency])
|
||||
radio = fallback(id="switcher",track_sensitive = false, [s, emergency])
|
||||
|
||||
handle_metadata = fun (m) -> begin
|
||||
print(m["title"])
|
||||
print(m["artist"])
|
||||
@@ -26,5 +31,18 @@ end
|
||||
radio.on_metadata(handle_metadata)
|
||||
interactive.persistent("script.params")
|
||||
|
||||
log_to_stdout = true
|
||||
log_to_file = true
|
||||
logpath = "/home/pi/Conjurer/radio_log.log"
|
||||
loglevel = 3
|
||||
|
||||
# Enable logging on Standard Output and set logging level.
|
||||
set("log.stdout",log_to_stdout)
|
||||
set("log.level",loglevel)
|
||||
|
||||
# Enable logging to file. See variable: logpath
|
||||
set("log.file",log_to_file)
|
||||
set("log.file.path",logpath)
|
||||
|
||||
output.file.hls("/tmp/hls",[("mp3-low", %mp3(bitrate=96)), ("mp3-hi", %mp3(bitrate=160))],radio)
|
||||
output.icecast(%mp3, host="retropie", port=8000,password=credentials.password, icy_metadata="true", mount="mp3-stream", radio)
|
||||
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=radio_conjurer Liquidsoap daemon
|
||||
After=network.target
|
||||
Documentation=http://liquidsoap.fm/
|
||||
|
||||
[Service]
|
||||
User=pi
|
||||
WorkingDirectory=/home/pi/Conjurer/
|
||||
ExecStart=/home/pi/.opam/4.13.0/bin/liquidsoap /home/pi/Conjurer/radio_conjurer.liq
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Alias=radio_conjurer-liquidsoap.service
|
||||
+2
-1
@@ -2,5 +2,6 @@
|
||||
cd ./conjurer
|
||||
git pull
|
||||
cd ..
|
||||
cp ./conjurer/file_webservice/conjurer_musician.py ./Conjurer
|
||||
cp ./conjurer/conjurer_musician/conjurer_musician.py ./Conjurer
|
||||
sudo systemctl restart conjurer_musician.service
|
||||
sudo systemctl restart radio_service.service
|
||||
@@ -0,0 +1,6 @@
|
||||
cd ./conjurer
|
||||
git pull
|
||||
cd ..
|
||||
cp ./conjurer/conjurer_musician/radio_conjurer.liq ./Conjurer
|
||||
cd ./Conjurer
|
||||
liquidsoap radio_conjurer.liq
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
python3 -m venv /home/pi/Conjurer-service/conjurer/file_webservice
|
||||
source ./bin/activate
|
||||
./bin/python3 -m pip install --upgrade pip
|
||||
./bin/python3 -m pip install -r requirements_musician.txt
|
||||
deactivate
|
||||
|
||||
sudo cp ./conjurer_musician.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl start conjurer_musician.service
|
||||
sudo systemctl enable conjurer_musician.service
|
||||
@@ -1,11 +0,0 @@
|
||||
[Unit]
|
||||
Description=Radio_conjurer
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/home/pi/Conjurer/ liquidsoap /home/pi/Conjurer/radio_conjurer.liq
|
||||
Restart=on-abort
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Regular → Executable
+15
-5
@@ -1,16 +1,26 @@
|
||||
#!/bin/bash
|
||||
cd /home/pi
|
||||
mdkir Conjurer
|
||||
mkdir Conjurer
|
||||
cd Conjurer
|
||||
python3 -m venv /home/pi/Conjurer/env
|
||||
source ./env/bin/activate
|
||||
cp /home/pi/conjurer/conjurer_musician/requirements_bot.txt /home/pi/Conjurer/
|
||||
source /home/pi/Conjurer/env/bin/activate
|
||||
cp /home/pi/conjurer/conjurer_musician/requirements_musician.txt /home/pi/Conjurer/
|
||||
cp /home/pi/conjurer/conjurer_musician/conjurer_musician.py /home/pi/Conjurer/
|
||||
cp /home/pi/conjurer/conjurer_musician/radio_conjurer.liq /home/pi/Conjurer/
|
||||
touch /home/pi/Conjurer/discord_mus_service.log
|
||||
touch /home/pi/Conjurer/all_playlist.txt
|
||||
touch /home/pi/Conjurer/playlist.json
|
||||
touch /home/pi/Conjurer/priority_queue.playlist
|
||||
touch /home/pi/Conjurer/radio_log.log
|
||||
./env/bin/python3 -m pip install --upgrade pip
|
||||
./env/bin/python3 -m pip install -r requirements_bot.txt
|
||||
./env/bin/python3 -m pip install -r requirements_musician.txt
|
||||
deactivate
|
||||
sudo cp ./file_webservice/conjurer_musician.service /etc/systemd/system/
|
||||
sudo cp /home/pi/conjurer/conjurer_musician/conjurer_musician.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl start conjurer_musician.service
|
||||
sudo systemctl enable conjurer_musician.service
|
||||
|
||||
sudo cp /home/pi/conjurer/conjurer_musician/radio_service.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl start radio_service.service
|
||||
sudo systemctl enable radio_service.service
|
||||
|
||||
Reference in New Issue
Block a user