summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-03-17 21:08:58 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-03-17 21:08:58 +0100
commit8708bd0fe27077115de254e71b51e7192ff58f74 (patch)
treef07622077d548ec045853b55098e537dea188d83
parentfixes on z for radio -- now works (diff)
downloadtravnik-8708bd0fe27077115de254e71b51e7192ff58f74.tar
travnik-8708bd0fe27077115de254e71b51e7192ff58f74.tar.gz
travnik-8708bd0fe27077115de254e71b51e7192ff58f74.tar.bz2
travnik-8708bd0fe27077115de254e71b51e7192ff58f74.tar.lz
travnik-8708bd0fe27077115de254e71b51e7192ff58f74.tar.xz
travnik-8708bd0fe27077115de254e71b51e7192ff58f74.tar.zst
travnik-8708bd0fe27077115de254e71b51e7192ff58f74.zip
-rwxr-xr-xradio/milo.ls11
-rw-r--r--radio/radio.php38
-rwxr-xr-xradio/radio.py15
3 files changed, 55 insertions, 9 deletions
diff --git a/radio/milo.ls b/radio/milo.ls
index 61560fc..fa47b72 100755
--- a/radio/milo.ls
+++ b/radio/milo.ls
@@ -1,6 +1,13 @@
#!/usr/bin/env liquidsoap
set("server.socket", true)
set("server.socket.path", "/tmp/ls")
-radio = fallback([request.queue(id="request"), single("/home/z/tmp/rem.flac")], track_sensitive=false)
+# radio = fallback([request.queue(id="request"), single("/home/z/tmp/rem.flac")], track_sensitive=false)
+radio = request.queue(id="request")
+radio = normalize(radio)
+radio = crossfade(radio)
+radio = skip_blank(radio)
+# radio = sine()
# out(radio)
-output.icecast(%vorbis, host="tranzistor",port=8000,password="hackme", mount="radio_nolive.ogg", radio)
+radio = fallback([radio, single("/home/z/tmp/rem.flac")], track_sensitive=false)
+output.icecast(%ogg(%flac(compression=8)), host="tranzistor", port=8000, password="hackme", mount="travnik", radio)
+output.icecast(%opus, host="tranzistor", port=8000, password="hackme", mount="travnik.opus", radio)
diff --git a/radio/radio.php b/radio/radio.php
new file mode 100644
index 0000000..4c8bf3f
--- /dev/null
+++ b/radio/radio.php
@@ -0,0 +1,38 @@
+<?php
+$sock = stream_socket_client("unix:///tmp/ls", $errno, $errstr);
+if (!empty($_REQUEST["s"])) {
+ fwrite($sock, "travnik.skip\r\n");
+ header("location: ?p=1");
+ exit("preusmeritev na ?p=1");
+}
+fwrite($sock, "uptime\r\n");
+usleep(100000);
+$uptime = trim(str_replace("END", "", fread($sock, 256)));
+fwrite($sock, "travnik.remaining\r\n");
+usleep(100000);
+$remaining = trim(str_replace("END", "", fread($sock, 256)));
+fwrite($sock, "travnik.metadata\r\n");
+usleep(100000);
+$metadata = str_replace("\r", "", trim(str_replace("END", "", fread($sock, 65536))));
+fwrite($sock, "quit\r\n");
+?>
+radijski pretok neprestano teče že <?= htmlspecialchars($uptime) ?>
+<br>
+do konca komada je še <?= gmdate("H:i:s", intval($remaining)) ?>.
+<br>
+<form method=post>
+<input type=submit name=s value="preskoči na naslednji komad" />
+</form>
+<?php
+if (!empty($_REQUEST["p"])) {
+?>
+<b>poročilo: zahteva za preskok komada je bila uspešno poslana. počakaj nekaj sekund, da se zgodi crossfade. preveri, da si na koncu pretoka!</b>
+<?php
+}
+?>
+<br>
+metapodatki o komadu in o prej predvajanih komadih:
+<br>
+<pre>
+<?= htmlspecialchars(implode("\n", array_reverse(explode("\n", $metadata)))) ?>
+</pre>
diff --git a/radio/radio.py b/radio/radio.py
index 5106813..c9fd156 100755
--- a/radio/radio.py
+++ b/radio/radio.py
@@ -53,7 +53,7 @@ def random_file(torrent, save_path, endung=".flac"):
print(f"random file {torrent.torrent_file().files().file_path(get_index_from_endung(chosen))} chosen to download")
return True
-def watcher(session, torrents, s, d, active_torrents=10):
+def watcher(session, torrents, s, d, active_torrents=1):
i = inotify.adapters.Inotify()
i.add_watch(d)
for event in i.event_gen(yield_nones=False):
@@ -101,7 +101,7 @@ def stream(playstack, unix=None):
while True:
if len(playstack) == 0:
# print("stream: no songs in playstack")
- print(playstack)
+ # print(playstack)
sleep(1)
continue
# sock = socket(AF_INET, SOCK_STREAM)
@@ -111,16 +111,17 @@ def stream(playstack, unix=None):
sock.sendall(b"request.alive\r\n")
sleep(1)
data = sock.recv(256)
- print(f"stream: remote said {data}")
+ # print(f"stream: remote said {data}")
a = data.split(b"\r")[0]
- if a == b"" or a == b"0":
+ if len(a.split(b" ")) < 3:
komad = playstack.pop()
# komad = "/tmp/o.flac"
+ # sock.sendall(b"request.push annotate:filename=\"" + bytes(komad, encoding="utf-8") + b"\":" + bytes(komad, encoding="utf-8") + b"\r\n")
sock.sendall(b"request.push " + bytes(komad, encoding="utf-8") + b"\r\n")
print(f"stream: REQUESTING PLAYBACK of {komad}")
sleep(1)
- else:
- print(f"stream: remote returned that {a} is playing")
+ # else:
+ # print(f"stream: remote returned that {a} is playing")
else:
while True:
if len(playstack) == 0:
@@ -134,7 +135,7 @@ def progress(session, torrents):
while True:
for torr in torrents:
s = torr.status()
- print(torr.torrent_file().name() + '\t%.2f%% complete (down: %.1f kB/s up: %.1f kB/s peers: %d) %s' % (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, s.num_peers, s.state))
+ # print(torr.torrent_file().name() + '\t%.2f%% complete (down: %.1f kB/s up: %.1f kB/s peers: %d) %s' % (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, s.num_peers, s.state))
sleep(1)
if __name__ == "__main__":