mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Liq radio + some comments and nice stuff
fix fix Fix ? fx Liquidsoap init test test2 test Tst tst fix PLS tst tst test test fix tst aa aa# Please enter the commit message for your changes. Lines starting Ping fix? fix fix Working version Upgrade Fix fix metadata test fix fix# Please enter the commit message for your changes. Lines starting Fix aa fix fix test FIx test test test fix fix fix? aa fix test Final v.00 HLS Serve
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# This Python file uses the following encoding: utf-8
|
||||
"""
|
||||
The provided Python script sets up a Flask web server to manage a list of music files, with
|
||||
functions for rescanning the music folder, updating the music list, and serving the music list via
|
||||
@@ -12,9 +13,10 @@ import time
|
||||
from datetime import datetime
|
||||
from sys import platform
|
||||
import logging
|
||||
from flask import Flask, jsonify, request
|
||||
from flask import Flask, Response, jsonify, request, send_file
|
||||
from waitress import serve
|
||||
from logging import handlers
|
||||
from json.decoder import JSONDecodeError
|
||||
|
||||
|
||||
HOST_ADDRESS = "192.168.1.15"
|
||||
@@ -38,6 +40,17 @@ if platform in ("linux", "linux2"):
|
||||
|
||||
|
||||
music_file_list = []
|
||||
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") as w_file:
|
||||
try:
|
||||
playlist = json.load(r_file)
|
||||
for item in playlist:
|
||||
w_file.write(item)
|
||||
w_file.write("\n")
|
||||
except JSONDecodeError:
|
||||
pass
|
||||
|
||||
def rescan():
|
||||
"""
|
||||
The `rescan` function logs a message, scans for mp3 files in a specified folder,
|
||||
@@ -49,14 +62,15 @@ def rescan():
|
||||
if platform == "win32":
|
||||
temp_music_file = temp_music_file.replace("/", "\\")
|
||||
music_file_list.append(temp_music_file)
|
||||
with open("playlist.json", "r+", encoding="utf-8") as s_file:
|
||||
with open("/home/pi/Conjurer/playlist.json", "r+", encoding="utf-8") as s_file:
|
||||
database = music_file_list
|
||||
#self.app.logger.info("DUMPING DATA")
|
||||
s_file.truncate(0)
|
||||
s_file.seek(0)
|
||||
json.dump(database, s_file)
|
||||
#TODO: Zobaczyć czy losowo, itp. lepiej po stronie pythona czy po stronei liquidsoapa. Tak samo modyfikowanie playlisty itp. itd.
|
||||
#TODO: Ale zacząć od odtwarzania playlisty z tego pliku json (może np. się format nie zgadzać albo coś)
|
||||
create_playlist()
|
||||
#TODO: Zobaczyc czy losowo, itp. lepiej po stronie pythona czy po stronei liquidsoapa. Tak samo modyfikowanie playlisty itp. itd.
|
||||
#TODO: Ale zaczac od odtwarzania playlisty z tego pliku json (moze np. sie format nie zgadzac albo cos)
|
||||
|
||||
def thread_rescan():
|
||||
"""
|
||||
@@ -198,8 +212,10 @@ def stream_music():
|
||||
:return: A JSON response containing a key "music_file_list" with the value of the variable
|
||||
`music_file_list`.
|
||||
"""
|
||||
return jsonify({"music_file_list": music_file_list})
|
||||
|
||||
m3u8 = Path("/tmp/hls/stream.m3u8")
|
||||
r = Response(m3u8)
|
||||
r.headers["Content-Type"] = "application/mpegURL"
|
||||
return r, 200
|
||||
|
||||
|
||||
@app.route("/mp3", methods=["GET"])
|
||||
|
||||
Regular → Executable
+34804
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
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"))
|
||||
|
||||
interactive.harbor(port = 9999)
|
||||
f = interactive.float("f", description="Frequency", min=0., max=1000.,unit="Hz", 200.)
|
||||
g = interactive.float("g", description="Gain", min=0., max=20.,unit="dB", 8.)
|
||||
b = bass_boost(frequency=f, gain=g, s)
|
||||
s = add([s, b])
|
||||
a = interactive.float("main_volume", min=0., max=20., 1.)
|
||||
s = compress.multiband.interactive(bands=3, s)
|
||||
|
||||
s = nrj(normalize (s))
|
||||
s = crossfade(fade_out=3., fade_in=3., duration=5., s)
|
||||
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])
|
||||
handle_metadata = fun (m) -> begin
|
||||
print(m["title"])
|
||||
print(m["artist"])
|
||||
print(m["filename"])
|
||||
end
|
||||
radio.on_metadata(handle_metadata)
|
||||
interactive.persistent("script.params")
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user