diff --git a/main.py b/main.py new file mode 100644 index 0000000..1af7bf5 --- /dev/null +++ b/main.py @@ -0,0 +1,63 @@ +from os import listdir,system as ss +from time import sleep +#Theards +import threading +#Time&Date +from datetime import date +import time + +#RADIO STATIONS +rad = [ +"https://nashe1.hostingradio.ru:18000/nashepunks.mp3", +"https://ic7.101.ru:8000/v1_1 -O nrj.mp3" +] +### + +#TIME(IN MINUTES) +tw = 3 +wait = tw +### + +#Save location +prefix = "~/ARCHIVE/" +### + +#Upload in telegram +def upload(): + today = date.today() + files = listdir() + #Set date&time + tim = today.strftime("%d.%m.%Y_"+time.strftime("%H:%M", time.localtime())) + + for i in files: + if i == "nashepunks.mp3": + ss("telegram-upload "+i+" --to https://t.me/getnetradio_nashe0punk --caption "+tim) + ss("mkdir "+prefix+tim) + ss("mv "+i+" "+prefix+tim+"/") + elif i == "nrj.mp3": + ss("telegram-upload "+i+" --to https://t.me/getnetradio_nrj --caption "+tim) + ss("mkdir "+prefix+tim) + ss("mv "+i+" "+prefix+tim+"/") + else: + pass + + +while True: + #Download function + def rad_down(ch): + ss("wget "+i) + #Run download + for i in rad: + th = threading.Thread(target=rad_down, args=(i,)) + th.start() + + #Wait + sleep(wait) + + #Stop download + ss("killall wget") + + #Upload + upload() + + break diff --git a/run.sh b/run.sh deleted file mode 100755 index 7f9c50e..0000000 --- a/run.sh +++ /dev/null @@ -1,13 +0,0 @@ -while : -do - wget https://nashe1.hostingradio.ru:18000/nashepunks.mp3 & - th1=$! - wget https://ic7.101.ru:8000/v1_1 -O nrj.mp3 & - th2=$! - - sleep 30m - kill -9 $th1 - kill -9 $th2 - - python3 up.py -done diff --git a/stop.sh b/stop.sh index e195c07..9520edc 100755 --- a/stop.sh +++ b/stop.sh @@ -1,5 +1,5 @@ -kl=$(ps aux | grep run.sh | grep bin | awk -F " " '{print $2}') +kl=$(ps aux | grep main.py | grep python3 | awk -F " " '{print $2}') kill $kl killall wget rm *.mp3 -rm nohup.out +#rm nohup.out diff --git a/up.py b/up.py deleted file mode 100644 index 40c7049..0000000 --- a/up.py +++ /dev/null @@ -1,24 +0,0 @@ -from os import listdir,system as ss -from datetime import date -import time - -today = date.today() -files = listdir() -prefix = "~/ARCHIVE/" - -for i in files: - tim = today.strftime("%d.%m.%Y_"+time.strftime("%H:%M", time.localtime())) - - #Check type,no need for this - #tp = i[i.find('.') + 1:] - - if i == "nashepunks.mp3": - ss("telegram-upload "+i+" --to https://t.me/getnetradio_nashe0punk --caption "+tim) - ss("mkdir "+prefix+tim) - ss("mv "+i+" "+prefix+tim+"/") - elif i == "nrj.mp3": - ss("telegram-upload "+i+" --to https://t.me/getnetradio_nrj --caption "+tim) - ss("mkdir "+prefix+tim) - ss("mv "+i+" "+prefix+tim+"/") - else: - pass