Compare commits

..

No commits in common. "master" and "v.1.1.1" have entirely different histories.

4 changed files with 31 additions and 28 deletions

View File

@ -1,4 +1,4 @@
## [Install](https://gitea.dmcraft.online/justuser/getnetradio#0-install) | [Usage](https://gitea.dmcraft.online/justuser/getnetradio#1-usage) | [Telegram](https://t.me/getnetradio) | [Updates](https://gitea.dmcraft.online/justuser/getnetradio#contact-updates) | [Realeses](https://gitea.dmcraft.online/justuser/getnetradio/releases) ## [Install](https://gitlab.com/justuser31/getnetradio#0install) | [Usage](https://gitlab.com/justuser31/getnetradio#1usage) | [Telegram](https://t.me/getnetradio) | [Updates](https://gitlab.com/justuser31/getnetradio#contact-updates) | [Realeses](https://gitlab.com/justuser31/getnetradio/-/releases)
----- -----
@ -11,11 +11,8 @@ sudo pip3 install -U telegram-upload
#Check if all works(If not,READ MESSAGE) #Check if all works(If not,READ MESSAGE)
telegram-upload README.md telegram-upload README.md
#Audio bitrate check and convert #INSTALL LAME
pip3 install pydub #https://lame.sourceforge.io/links.php#Binaries
#INSTALL wget
# https://www.gnu.org/software/wget/
git clone https://notabug.org/Justuser/getnetradio.git git clone https://notabug.org/Justuser/getnetradio.git
cd getnetradio cd getnetradio
@ -68,6 +65,4 @@ git config --global credential.helper cache
python3 -m http.server python3 -m http.server
#Change repo #Change repo
git push --repo=https://gitlab.com/justuser31/getnetradio git push --repo=https://gitlab.com/justuser31/getnetradio
git clone --branch <branchname> <remote-repo-url>
``` ```

View File

@ -1,5 +1,3 @@
#DEV-MODE
dev=True
#Time in minutes #Time in minutes
time = "10" time = "10"
#Prefix for file save location( $prefix/your.mp3 ) #Prefix for file save location( $prefix/your.mp3 )

44
main.py
View File

@ -1,5 +1,6 @@
from os import listdir,system as ss from os import listdir,system as ss
from time import sleep from time import sleep
import subprocess
#Theards #Theards
import threading import threading
#Time&Date #Time&Date
@ -7,17 +8,16 @@ from datetime import date
import time import time
#Config #Config
import config import config
#Check bitrate and convert audio
from pydub import AudioSegment
from pydub.utils import mediainfo
#DEV-MODE#
dev = False
##########
#Import config #Import config
tw = int(config.time) tw = int(config.time)
prefix = config.prefix prefix = config.prefix
rad = config.radio rad = config.radio
dev = bool(config.dev)
###
if dev == False: if dev == False:
wait = tw*60 wait = tw*60
@ -25,14 +25,14 @@ else:
wait = tw wait = tw
#Check bitrate and upload #Check bitrate and upload
def tg(i,tim,group): def tg(i,tim,prefix,group):
bit = int(mediainfo(i)['bit_rate'])/1000 ss("rm t")
ss("ffprobe "+i+" 2> t")
if bit > 128: bit = int(subprocess.check_output("cat t | grep bitrate | grep Duration | awk -F \" \" '{print $6}'", shell=True))
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("telegram-upload "+i+" --to "+group+" --caption "+tim)
ss("mkdir "+prefix+tim) ss("mkdir "+prefix+tim)
@ -51,14 +51,24 @@ def upload():
pass pass
else: else:
print("SUCCESS") print("SUCCESS")
tg(i,tim,rad[i][1]) tg(i,tim,prefix,rad[i][1])
#Download function '''
def rad_down(ch): if i == "nashepunks.mp3":
ss("wget "+ch) 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: while True:
#Download function
def rad_down(ch):
ss("wget "+ch)
#Run download #Run download
for i in rad: for i in rad:
th = threading.Thread(target=rad_down, args=(rad[i][0],)) th = threading.Thread(target=rad_down, args=(rad[i][0],))

View File

@ -2,4 +2,4 @@ kl=$(ps aux | grep main.py | grep python3 | awk -F " " '{print $2}')
kill $kl kill $kl
killall wget killall wget
rm *.mp3 rm *.mp3
rm nohup.out #rm nohup.out