From 0c4704316872ed0e005f730a7e0877d73ca566ac Mon Sep 17 00:00:00 2001 From: justuser31 Date: Thu, 6 Oct 2022 20:03:49 +0300 Subject: [PATCH] Add check bitrate and convert. --- main.py | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/main.py b/main.py index 653ec3c..98f679f 100644 --- a/main.py +++ b/main.py @@ -1,28 +1,48 @@ 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://ic7.101.ru:8000/v1_1 -O nrj.mp3", "https://emgregion.hostingradio.ru:8064/moscow.retrofm.mp3 -O retrofm.mp3" ] -### - #TIME(IN MINUTES) -tw = 3 -wait = tw -### - +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() @@ -31,18 +51,15 @@ def upload(): 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": - ss("telegram-upload "+i+" --to https://t.me/getnetradio_nashe0punk --caption "+tim) - ss("mkdir "+prefix+tim) - ss("mv "+i+" "+prefix+tim+"/") + tg(i,tim,prefix,"https://t.me/getnetradio_nashe0punk") + 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+"/") + tg(i,tim,prefix,"https://t.me/getnetradio_nrj") + elif i == "retrofm.mp3": - ss("telegram-upload "+i+" --to https://t.me/getnetradio_retrofm --caption "+tim) - ss("mkdir "+prefix+tim) - ss("mv "+i+" "+prefix+tim+"/") + tg(i,tim,prefix,"https://t.me/getnetradio_retrofm") else: pass @@ -65,4 +82,5 @@ while True: #Upload upload() - break + if dev == True: + break