Compare commits

..

13 Commits

Author SHA1 Message Date
justuser
a3cc6a9bf8 Update 'README.md' 2023-03-11 12:52:28 +03:00
justuser
e3a60bba82 Update 'README.md' 2023-03-11 12:50:45 +03:00
d14addd72e Update README.md 2022-10-08 15:13:48 +00:00
9b8cf4dcd2 Update 2022-10-07 12:44:30 +03:00
6eb51aa241 Change lame to pydub module,small fixes. 2022-10-07 12:43:11 +03:00
1c9e98d57d Update README.md 2022-10-07 09:41:57 +00:00
26f9c15cfd Update README.md 2022-10-06 19:32:09 +00:00
44e1960a5e Update README.md 2022-10-06 19:30:30 +00:00
00d7d0c582 Update README.md 2022-10-06 19:29:49 +00:00
8b372a4ed4 New config! More easier. 2022-10-06 22:28:51 +03:00
883307b9d4 Merge branch 'master' of https://gitlab.com/justuser31/getnetradio 2022-10-06 20:03:58 +03:00
0c47043168 Add check bitrate and convert. 2022-10-06 20:03:49 +03:00
b40b367280 Update README.md 2022-10-06 17:01:38 +00:00
4 changed files with 73 additions and 37 deletions

View File

@ -1,4 +1,4 @@
## [Install](https://gitlab.com/justuser31/getnetradio/-/blob/master/README.md#0install) | [Usage](https://gitlab.com/justuser31/getnetradio/-/blob/master/README.md#1usage) | [Telegram](https://t.me/getnetradio) | [Updates](https://gitlab.com/justuser31/getnetradio/-/blob/master/README.md#contact-updates) | [Realeses](https://gitlab.com/justuser31/getnetradio/-/releases)
## [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)
-----
@ -11,20 +11,25 @@ sudo pip3 install -U telegram-upload
#Check if all works(If not,READ MESSAGE)
telegram-upload README.md
#Audio bitrate check and convert
pip3 install pydub
#INSTALL wget
# https://www.gnu.org/software/wget/
git clone https://notabug.org/Justuser/getnetradio.git
cd getnetradio
```
### 1.Usage
```
#Config your stations and audio time in run.sh
#Config upload audio file to teelegram in up.py
--to https://t.me/getnetradio_nashe0punk
#Here your link telegram channel
#ALL CONFIGS IN config.py
#Start(nohup and "&" for work in background)
nohup python3 main.py &
#Stop
./stop.sh
#Or just kill main.py and wget
```
@ -45,6 +50,9 @@ nohup python3 main.py &
> 06.10.2022 - Merge st.sh and up.py, new release.
> 06.10.2022 - Add check bitrate and convert with "lame".
> 06.10.2022 - New config,more easier.
-----
@ -60,4 +68,6 @@ git config --global credential.helper cache
python3 -m http.server
#Change repo
git push --repo=https://gitlab.com/justuser31/getnetradio
git clone --branch <branchname> <remote-repo-url>
```

17
config.py Normal file
View File

@ -0,0 +1,17 @@
#DEV-MODE
dev=True
#Time in minutes
time = "10"
#Prefix for file save location( $prefix/your.mp3 )
prefix= "~/ARCHIVE/"
#Your radio
radio = {
#name_of_file.mp3 : ["https://link_to_radio.mp3","https://link_to_telegram"]
#"-O name.mp3" after link to change name(look for example \/ )
"nashepunks.mp3" : ["https://nashe1.hostingradio.ru:18000/nashepunks.mp3","https://t.me/getnetradio_nashe0punk"],
"nrj.mp3" : ["https://ic7.101.ru:8000/v1_1 -O nrj.mp3","https://t.me/getnetradio_nrj"],
"retrofm.mp3" : ["https://emgregion.hostingradio.ru:8064/moscow.retrofm.mp3 -O retrofm.mp3","https://t.me/getnetradio_retrofm"]
}

71
main.py
View File

@ -5,23 +5,39 @@ import threading
#Time&Date
from datetime import date
import time
#Config
import config
#Check bitrate and convert audio
from pydub import AudioSegment
from pydub.utils import mediainfo
#RADIO STATIONS
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"
]
#Import config
tw = int(config.time)
prefix = config.prefix
rad = config.radio
dev = bool(config.dev)
###
#TIME(IN MINUTES)
tw = 3
wait = tw
###
if dev == False:
wait = tw*60
else:
wait = tw
#Check bitrate and upload
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)
ss("telegram-upload "+i+" --to "+group+" --caption "+tim)
ss("mkdir "+prefix+tim)
ss("mv "+i+" "+prefix+tim+"/")
#Save location
prefix = "~/ARCHIVE/"
###
#Upload in telegram
def upload():
@ -31,29 +47,21 @@ def upload():
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+"/")
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+"/")
else:
if rad.get(i) == None:
pass
else:
print("SUCCESS")
tg(i,tim,rad[i][1])
#Download function
def rad_down(ch):
ss("wget "+ch)
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 = threading.Thread(target=rad_down, args=(rad[i][0],))
th.start()
#Wait
@ -65,4 +73,5 @@ while True:
#Upload
upload()
break
if dev == True:
break

View File

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