diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-03-19 23:08:44 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-03-19 23:08:44 +0100 |
commit | 907ad4d0d911f12ddbde1ff5847d808d84d6027d (patch) | |
tree | dcde4f89ee1bd8709c8d271e69c8e0b6cf7649c0 /radio/radio.py | |
parent | začetki rusta (diff) | |
parent | radio.php (diff) | |
download | travnik-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 |
Diffstat (limited to 'radio/radio.py')
-rwxr-xr-x | radio/radio.py | 15 |
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__": |