summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-03-19 23:08:44 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-03-19 23:08:44 +0100
commit907ad4d0d911f12ddbde1ff5847d808d84d6027d (patch)
treedcde4f89ee1bd8709c8d271e69c8e0b6cf7649c0
parentzačetki rusta (diff)
parentradio.php (diff)
downloadtravnik-907ad4d0d911f12ddbde1ff5847d808d84d6027d.tar
travnik-907ad4d0d911f12ddbde1ff5847d808d84d6027d.tar.gz
travnik-907ad4d0d911f12ddbde1ff5847d808d84d6027d.tar.bz2
travnik-907ad4d0d911f12ddbde1ff5847d808d84d6027d.tar.lz
travnik-907ad4d0d911f12ddbde1ff5847d808d84d6027d.tar.xz
travnik-907ad4d0d911f12ddbde1ff5847d808d84d6027d.tar.zst
travnik-907ad4d0d911f12ddbde1ff5847d808d84d6027d.zip
-rwxr-xr-xradio/milo.ls11
-rw-r--r--radio/radio.php67
-rwxr-xr-xradio/radio.py15
3 files changed, 84 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..28eecc0
--- /dev/null
+++ b/radio/radio.php
@@ -0,0 +1,67 @@
+<?php
+if ($_SERVER["REQUEST_SCHEME"] == "https") {
+ header("location: http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
+}
+$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\nquit\r\n");
+$buf = "";
+while (!feof($sock)) {
+ $buf .= fread($sock, 200000);
+}
+$metadata = str_replace("\r", "", trim(str_replace("Bye!", "", str_replace("END", "", $buf))));
+?>
+<meta name=viewport content='width=device-width, initial-scale=1.0'>
+pretok v najvišji kvaliteti brez izgub (FLAC) -- prenaša veliko podatkov:
+<br>
+<audio controls>
+ <source src=http://tranzistor.sijanec.eu:8000/travnik type="audio/ogg">
+</audio>
+<br>
+pretok v kompresirani kvaliteti (OPUS) -- manj prenesenih podatkov:
+<br>
+<audio controls>
+ <source src=http://tranzistor.sijanec.eu:8000/travnik.opus type="audio/ogg">
+</audio>
+<br>
+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 (preberi pravila spodaj)" />
+</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
+} else {
+?>
+pravila preskakovanja -- kdaj je dovoljeno preskočiti komad:
+<ul>
+<li> če se ne predvaja glasba, temveč govor
+<li> če je posnetek slabe kvalitete (slabi posnetki iz kaset, slabi live/nestudijski posnetki, ...)
+<li> če si edini poslušalec radia (preveri <a href=http://tranzistor.sijanec.eu:8000>tukaj</a>)
+<li> če je na števcu do konca komada več kot 5 minut (pred pritiskom gumba <a href=?>ozveži stran</a>, da se prikaže posodobljen števec)
+</ul>
+radio namreč lahko posluša več ljudi, preskok komada pa se seveda zgodi pri vseh, kar je lahko moteče. v primeru prevelikega subjektivnega ocenjevanja bom funkcijo odstranil.
+<?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__":