Here are two scripts to retrieve airport METAR and TAF data from the National Weather Service website and then send this data to an Icecast server to update stream metadata.
You can get the scripts here (use wget from a Linux command line):
Save them with whatever names you'd like (probably imetar[AirportName].py). In each script enter the server/stream information and modify the script to download your desired station name. Then run a cron job every hour (or whatever interval you choose) to update your stream metadata with the airport METAR and TAF data.
The python scripts below will add the ability to update Icecast feed metadata via the Raspberry Pi. They are compatible with Uniden Scanners including:
Functionality could be added for other Uniden scanners such as the 780XLT, 785D, 796D, and 898T, but as of now I don't have access to any of these models for testing.
To implement the script, download the script by right clicking on the appropriate link below and click "Save As". You can do this from the Raspberry Pi or from another computer and use any number of tools such as ssh and scp to copy the file to your desired location on your Raspberry Pi.
(The -O option allows you to give the file location and filename for the downloaded file - in this case it's saved in your home directory under the name metaPy.py or metaPy8.py.)
Once downloaded, use a text editor such as nano or vi to change the configuration section at the top of the script to match your settings:
'''-----------------USER CONFIGURATION-----------------'''
port = "/dev/ttyUSB0" #enter scanner USB/serial port in quotes here
baudrate = 115200 #enter scanner baudrate here
icecastUser = "username" #enter icecast username in quotes here (for RR feed use "source")
icecastPass = "hackme" #enter icecast password in quotes here
icecastServerAddress = "192.168.1.100:8000" #enter icecast server IP Address (and port if necessary) here
icecastMountpoint = "mymountpoint" #enter icecast mountpoint in quotes here - don't add leading '/'
'''-----------------END USER CONFIGURATION---------------'''
'''----------UNNECESSARY TO MODIFY SCRIPT BELOW----------'''
To connect your scanner you'll need a USB to serial adapter. If it's the first one connected, it should show up as /dev/ttyUSB0. You can check and see by going to /dev and list the files and look for ttyUSB0 or something similar. Also make sure that the baudrate in the script is the same as the baudrate set in your scanner.
The script uses two Python modules requests and serial that may or may not be installed on your Raspberry Pi. You can install these packages by using apt-get:
To run the script, change directories to the location the script is saved. Then type python metaPy.py to begin the script. If it is running, you will see it print out talkgroup information, time information and an update status:
Davis County Sim 11232 Syracuse PD 2 C
Thu Jun 13 21:07:03 2013
Icecast Update OK
Davis County Sim 10688 Davis Ops 2
Thu Jun 13 21:07:21 2013
Icecast Update OK
The script can be placed in the background by typing ctrl-z and then bg. It can be brought back to the foreground by typing fg.
You can also start the script detached from the console by adding an & to the end of the command: python metaPy.py & .
To stop the script, simply type ctrl-c, or find the process and kill it.
By using Darkice to feed the audio and this metaPy.py script to feed the alpha tags, you now have a 5W streaming media box to stream both scanner audio and text alpha tags.