summaryrefslogtreecommitdiffstats
path: root/radio
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-03-16 16:06:31 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-03-16 16:06:31 +0100
commitae313370e5720883fe8feafc341a010fa2cd87f4 (patch)
tree608826881b798b03f8b475b4a05c2cd899212477 /radio
parentfirst radio test (diff)
downloadtravnik-ae313370e5720883fe8feafc341a010fa2cd87f4.tar
travnik-ae313370e5720883fe8feafc341a010fa2cd87f4.tar.gz
travnik-ae313370e5720883fe8feafc341a010fa2cd87f4.tar.bz2
travnik-ae313370e5720883fe8feafc341a010fa2cd87f4.tar.lz
travnik-ae313370e5720883fe8feafc341a010fa2cd87f4.tar.xz
travnik-ae313370e5720883fe8feafc341a010fa2cd87f4.tar.zst
travnik-ae313370e5720883fe8feafc341a010fa2cd87f4.zip
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()