first commit
This commit is contained in:
commit
0967093920
6
make_all.m3u.py
Executable file
6
make_all.m3u.py
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
import glob
|
||||||
|
f = open("all.m3u", "w")
|
||||||
|
for file in glob.iglob("/home/pi/radio_project/sounds/*"):
|
||||||
|
f.write(file)
|
||||||
|
f.write("\n")
|
||||||
|
f.close()
|
16
make_m3u.py
Executable file
16
make_m3u.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#! python3
|
||||||
|
import glob
|
||||||
|
m3u = input("Filename> ")
|
||||||
|
m3u = m3u + ".m3u"
|
||||||
|
f = open(m3u, "w")
|
||||||
|
|
||||||
|
for file in glob.iglob("/home/pi/radio_project/sounds/*"):
|
||||||
|
print(file + ": Do you want to add this?")
|
||||||
|
yn = input("y/n> ")
|
||||||
|
yn = str(yn)
|
||||||
|
if yn == "y":
|
||||||
|
f.write(file)
|
||||||
|
f.write("\n")
|
||||||
|
if yn == "n":
|
||||||
|
pass
|
||||||
|
f.close()
|
32
radio.py
Executable file
32
radio.py
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#William, hvis du redigerer denne: ikke legg til norske symboler det fungerer ikke
|
||||||
|
|
||||||
|
import os, glob
|
||||||
|
|
||||||
|
print("Use python3")
|
||||||
|
playlist = "/home/pi/radio_project/all.m3u"
|
||||||
|
playlist = input("Playlist file> ")
|
||||||
|
station_name = "105FM"
|
||||||
|
station_id = "BEEF" #hex number 0123456789ABCDEF use uppercase
|
||||||
|
frequency = "105" #in MHZ float stored as string; do not change var type
|
||||||
|
|
||||||
|
#WARNING! WARNING!: Do not set PS aka: program type to 30 or 31. 30 and 31 are for emergency alert system broadcasts
|
||||||
|
program_type = "9" #MUST NOT be 30 or 31. See above comment
|
||||||
|
|
||||||
|
def m3u(playlist):
|
||||||
|
with open(playlist) as f:
|
||||||
|
lines = f.read().splitlines()
|
||||||
|
print(lines)
|
||||||
|
return lines
|
||||||
|
|
||||||
|
while True:
|
||||||
|
for filename in m3u(playlist):
|
||||||
|
songname = filename.replace("/home/pi/radio_project/sounds/", "")
|
||||||
|
songname = songname.replace(".wav", "")
|
||||||
|
songname = songname.replace(".mp3", "")
|
||||||
|
cmd_to_execute = "sox \"" + filename + "\" -t wav - | /home/pi/radio_project/pifm --freq " + frequency + " --pi " + station_id + " --audio - --ps " + station_name + " --rt \"" + songname + "\" --pty " + program_type + " --power 0 --wait 0"
|
||||||
|
print("=================================")
|
||||||
|
print("Spiller av: ")
|
||||||
|
print(songname)
|
||||||
|
print(cmd_to_execute)
|
||||||
|
print("=================================")
|
||||||
|
os.system(cmd_to_execute)
|
Loading…
Reference in New Issue
Block a user