From ae313370e5720883fe8feafc341a010fa2cd87f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Thu, 16 Mar 2023 16:06:31 +0100 Subject: control radio --- radio/radio.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/radio/radio.py b/radio/radio.py index d562627..38689ca 100755 --- a/radio/radio.py +++ b/radio/radio.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -from sys import path +from sys import path, argv path.append("..") from travnik import Torrent import inotify.adapters @@ -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="/tmp/", active_torrents=10): +def watcher(session, torrents, s, d, active_torrents=10): i = inotify.adapters.Inotify() i.add_watch(d) for event in i.event_gen(yield_nones=False): @@ -92,8 +92,8 @@ def alerts(session, playstack, save_path, torrents): continue print(f"{type(a)} | {a}") -def stream(playstack): - if False: +def stream(playstack, unix=None): + if type(unix) is str: while True: # sock = socket(AF_INET, SOCK_STREAM) # sock.connect("tranzistor", 1234) @@ -127,10 +127,18 @@ if __name__ == "__main__": torrents = [] playstack = [] save_path = "." - w = Thread(target=watcher, args=(session, torrents, save_path)) + torrents_path = "." + unix = None + if len(argv) > 1: + save_path = argv[1] + if len(argv) > 2: + torrents_path = argv[2] + if len(argv) > 3: + unix = argv[3] + w = Thread(target=watcher, args=(session, torrents, save_path, torrents_path)) a = Thread(target=alerts, args=(session, playstack, save_path, torrents)) p = Thread(target=progress, args=(session, torrents)) - s = Thread(target=stream, args=(playstack,)) + s = Thread(target=stream, args=(playstack, unix)) w.start() a.start() p.start() -- cgit v1.2.3