summaryrefslogtreecommitdiffstats
path: root/radio
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-03-16 21:15:22 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-03-16 21:15:22 +0100
commit23b45148a44c70b8587b27530836fcbd7093a20b (patch)
tree47be88939c0e900550a96625970872a1a81c2339 /radio
parentradio: more logging (diff)
downloadtravnik-23b45148a44c70b8587b27530836fcbd7093a20b.tar
travnik-23b45148a44c70b8587b27530836fcbd7093a20b.tar.gz
travnik-23b45148a44c70b8587b27530836fcbd7093a20b.tar.bz2
travnik-23b45148a44c70b8587b27530836fcbd7093a20b.tar.lz
travnik-23b45148a44c70b8587b27530836fcbd7093a20b.tar.xz
travnik-23b45148a44c70b8587b27530836fcbd7093a20b.tar.zst
travnik-23b45148a44c70b8587b27530836fcbd7093a20b.zip
Diffstat (limited to 'radio')
-rwxr-xr-xradio/milo.ls6
-rwxr-xr-xradio/radio.py22
2 files changed, 19 insertions, 9 deletions
diff --git a/radio/milo.ls b/radio/milo.ls
index 1b87eb5..61560fc 100755
--- a/radio/milo.ls
+++ b/radio/milo.ls
@@ -1,6 +1,6 @@
#!/usr/bin/env liquidsoap
set("server.socket", true)
set("server.socket.path", "/tmp/ls")
-radio = fallback([request.queue(id="request"), mksafe(input.http("http://kruljo.radiostudent.si:8000/ehiq"))], track_sensitive=false)
-out(radio)
-# output.icecast(%vorbis, host="tranzistor",port=8000,password="hackme", mount="radio_nolive.ogg", radio)
+radio = fallback([request.queue(id="request"), single("/home/z/tmp/rem.flac")], track_sensitive=false)
+# out(radio)
+output.icecast(%vorbis, host="tranzistor",port=8000,password="hackme", mount="radio_nolive.ogg", radio)
diff --git a/radio/radio.py b/radio/radio.py
index 9e0233c..5106813 100755
--- a/radio/radio.py
+++ b/radio/radio.py
@@ -82,22 +82,28 @@ def alerts(session, playstack, save_path, torrents):
if a.handle.get_file_priorities()[a.index] != 4:
print(f"alerts: IT LOOKS LIKE THIS FILE WAS CHECKED FROM CACHE")
continue
- fname = a.handle.torrent_file().files().file_path(a.index)
+ fname = path.abspath(save_path + "/" + a.handle.torrent_file().files().file_path(a.index))
playstack.append(fname)
- print("alerts: ADDED FILE {fname} to playstack")
+ print(f"alerts: ADDED FILE {fname} to playstack")
+ print(playstack)
if not random_file(a.handle, save_path):
session.remove_torrent(a.handle)
torrents.remove(a.handle)
continue
else:
a.handle.resume()
- if type(a) in [libtorrent.external_ip_alert, libtorrent.listen_succeeded_alert, libtorrent.dht_get_peers_alert, libtorrent.dht_outgoing_get_peers_alert, libtorrent.dht_reply_alert, libtorrent.torrent_added_alert, libtorrent.state_changed_alert, libtorrent.torrent_resumed_alert, libtorrent.stats_alert, libtorrent.torrent_checked_alert, libtorrent.peer_connect_alert, libtorrent.alert, libtorrent.peer_disconnected_alert, libtorrent.incoming_connection_alert, libtorrent.block_downloading_alert, libtorrent.dht_bootstrap_alert, libtorrent.dht_announce_alert, libtorrent.block_finished_alert, libtorrent.piece_finished_alert, libtorrent.peer_unsnubbed_alert, libtorrent.peer_snubbed_alert, libtorrent.portmap_error_alert, libtorrent.block_timeout_alert, libtorrent.block_uploaded_alert, libtorrent.performance_alert, libtorrent.cache_flushed_alert, libtorrent.dht_log_alert, libtorrent.portmap_log_alert, libtorrent.dht_pkt_alert, libtorrent.log_alert, libtorrent.peer_log_alert, libtorrent.picker_log_alert, libtorrent.torrent_log_alert, libtorrent.file_prio_alert, libtorrent.torrent_finished_alert]:
+ if type(a) in [libtorrent.external_ip_alert, libtorrent.listen_succeeded_alert, libtorrent.dht_get_peers_alert, libtorrent.dht_outgoing_get_peers_alert, libtorrent.dht_reply_alert, libtorrent.torrent_added_alert, libtorrent.state_changed_alert, libtorrent.torrent_resumed_alert, libtorrent.stats_alert, libtorrent.torrent_checked_alert, libtorrent.peer_connect_alert, libtorrent.alert, libtorrent.peer_disconnected_alert, libtorrent.incoming_connection_alert, libtorrent.block_downloading_alert, libtorrent.dht_bootstrap_alert, libtorrent.dht_announce_alert, libtorrent.block_finished_alert, libtorrent.piece_finished_alert, libtorrent.peer_unsnubbed_alert, libtorrent.peer_snubbed_alert, libtorrent.portmap_error_alert, libtorrent.block_timeout_alert, libtorrent.block_uploaded_alert, libtorrent.performance_alert, libtorrent.cache_flushed_alert, libtorrent.dht_log_alert, libtorrent.portmap_log_alert, libtorrent.dht_pkt_alert, libtorrent.log_alert, libtorrent.peer_log_alert, libtorrent.picker_log_alert, libtorrent.torrent_log_alert, libtorrent.file_prio_alert, libtorrent.torrent_finished_alert, libtorrent.invalid_request_alert]:
continue
print(f"{type(a)} | {a}")
def stream(playstack, unix=None):
if type(unix) is str:
while True:
+ if len(playstack) == 0:
+ # print("stream: no songs in playstack")
+ print(playstack)
+ sleep(1)
+ continue
# sock = socket(AF_INET, SOCK_STREAM)
# sock.connect("tranzistor", 1234)
sock = socket(AF_UNIX, SOCK_STREAM)
@@ -105,18 +111,22 @@ def stream(playstack, unix=None):
sock.sendall(b"request.alive\r\n")
sleep(1)
data = sock.recv(256)
+ print(f"stream: remote said {data}")
a = data.split(b"\r")[0]
- if a == b"":
+ if a == b"" or a == b"0":
komad = playstack.pop()
- sock.sendall(b"request.push " + bytes(komad, encoding="utf-8"))
+ # komad = "/tmp/o.flac"
+ 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:
while True:
if len(playstack) == 0:
sleep(1)
continue
- song = AudioSegment.from_file(path.abspath(playstack.pop()), "flac")
+ song = AudioSegment.from_file((playstack.pop()), "flac")
play(song)
sleep(1)