summaryrefslogtreecommitdiffstats
path: root/radio/radio.py
diff options
context:
space:
mode:
Diffstat (limited to 'radio/radio.py')
-rwxr-xr-xradio/radio.py22
1 files changed, 16 insertions, 6 deletions
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)