from os import listdir,system as ss from time import sleep import subprocess #Theards import threading #Time&Date from datetime import date import time #DEV-MODE# dev = False ########## #RADIO STATIONS #SET TELEGRAM IN upload() rad = [ "https://nashe1.hostingradio.ru:18000/nashepunks.mp3", "https://ic7.101.ru:8000/v1_1 -O nrj.mp3", "https://emgregion.hostingradio.ru:8064/moscow.retrofm.mp3 -O retrofm.mp3" ] #TIME(IN MINUTES) tw = 30 if dev == False: wait = tw*60 else: wait = tw #Save location prefix = "~/ARCHIVE/" ### #Check bitrate and upload def tg(i,tim,prefix,group): ss("rm t") ss("ffprobe "+i+" 2> t") bit = int(subprocess.check_output("cat t | grep bitrate | grep Duration | awk -F \" \" '{print $6}'", shell=True)) if bit != 128: ss("lame --mp3input -b 128 "+i+" tt") ss("mv tt "+i) ss("telegram-upload "+i+" --to "+group+" --caption "+tim) ss("mkdir "+prefix+tim) ss("mv "+i+" "+prefix+tim+"/") #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: #HERE SET YOUR TELEGRAM AND MP3 if i == "nashepunks.mp3": tg(i,tim,prefix,"https://t.me/getnetradio_nashe0punk") elif i == "nrj.mp3": tg(i,tim,prefix,"https://t.me/getnetradio_nrj") elif i == "retrofm.mp3": tg(i,tim,prefix,"https://t.me/getnetradio_retrofm") 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() if dev == True: break