You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
#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)
|