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