summaryrefslogtreecommitdiffstats
path: root/radio
diff options
context:
space:
mode:
Diffstat (limited to 'radio')
-rwxr-xr-xradio/radio.py20
1 files 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()