Change lame to pydub module,small fixes.
This commit is contained in:
parent
1c9e98d57d
commit
6eb51aa241
@ -1,3 +1,5 @@
|
||||
#DEV-MODE
|
||||
dev=True
|
||||
#Time in minutes
|
||||
time = "10"
|
||||
#Prefix for file save location( $prefix/your.mp3 )
|
||||
|
44
main.py
44
main.py
@ -1,6 +1,5 @@
|
||||
from os import listdir,system as ss
|
||||
from time import sleep
|
||||
import subprocess
|
||||
#Theards
|
||||
import threading
|
||||
#Time&Date
|
||||
@ -8,16 +7,17 @@ from datetime import date
|
||||
import time
|
||||
#Config
|
||||
import config
|
||||
#Check bitrate and convert audio
|
||||
from pydub import AudioSegment
|
||||
from pydub.utils import mediainfo
|
||||
|
||||
|
||||
#DEV-MODE#
|
||||
dev = False
|
||||
##########
|
||||
|
||||
#Import config
|
||||
tw = int(config.time)
|
||||
prefix = config.prefix
|
||||
rad = config.radio
|
||||
dev = bool(config.dev)
|
||||
###
|
||||
|
||||
if dev == False:
|
||||
wait = tw*60
|
||||
@ -25,14 +25,14 @@ else:
|
||||
wait = tw
|
||||
|
||||
#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))
|
||||
def tg(i,tim,group):
|
||||
bit = int(mediainfo(i)['bit_rate'])/1000
|
||||
|
||||
if bit > 128:
|
||||
sound = AudioSegment.from_file(i)
|
||||
sound.export("tt.mp3", format="mp3", bitrate="128k")
|
||||
ss("mv tt.mp3 "+i)
|
||||
|
||||
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)
|
||||
@ -51,24 +51,14 @@ def upload():
|
||||
pass
|
||||
else:
|
||||
print("SUCCESS")
|
||||
tg(i,tim,prefix,rad[i][1])
|
||||
'''
|
||||
if i == "nashepunks.mp3":
|
||||
tg(i,tim,prefix,"https://t.me/getnetradio_nashe0punk")
|
||||
tg(i,tim,rad[i][1])
|
||||
#Download function
|
||||
def rad_down(ch):
|
||||
ss("wget "+ch)
|
||||
|
||||
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 "+ch)
|
||||
|
||||
#Run download
|
||||
for i in rad:
|
||||
th = threading.Thread(target=rad_down, args=(rad[i][0],))
|
||||
|
Loading…
Reference in New Issue
Block a user