Code:
import socket
import threading
import time
time.sleep(10)
UDP_IP = "127.0.0.1"
UDP_PORT = 5005
# Path to stations preset file
file = open('/home/pi/.kodi/addons/plugin.program.radioFM/resources/stations','r')
# Read the stations file into string and close it
data = file.readlines()
file.close()
# Take first line from station list and split it up by spaces
item = data[0]
requestedFrequency = item.split(' ')
# Use the first value of the split string for first station to tune radio to
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto("radio_tune_" + requestedFrequency[0] + "\0", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.sendto("radio_volume_plus", (UDP_IP, UDP_PORT))
sock.close()