(These can also be easily adapted to retrieve the programs for IRLP)
This application for asterisk is developed from my bigger picture thinking about the integration/migration of Asterisk and IRLP
This idea was formed from a local need. A remote repeater that still uses their autopatch to call long distance and play Amateur Radio Newsline. Unfortunately this system's controller is limited and not multi port. However on site happens to be a network connection. If one could manage to have an PBX extension that plays Newsline, a simple analog telephone adaptor (ATA) could save some telephone charges.
NOTE: It is possible and more sensible if you have IRLP hardware and a computer to provision the IRLP system to play Newsline. It's done in a similar manner. KC6HUR has some nice scripts for just this. I took from that idea to create this one. The possible advantage to this route is, you don't need IRLP hardware. This functions off controller with autopatch. You need a controller capable of more that one port to support IRLP, not everyone has this. Lastly, the Asterisk server computer in this situation need not be at the same site as the radio repeater, whereas the IRLP computer would have to be.
First off, there are a few tools you may need to install on your Asterisk system
lynx
mpg123
lame (optional)
Newsline
Step one is to make an automated cron entry that will download a fresh copy of Newsline each week. Then we need to convert the MP3 to the native format of Asterisk, gsm. Unfortunately I had to do this in two steps. Note: Your supposed to be able to play a MP3 directly using the syntax "MP3Player(location)". It requires mpg123.
You can create a file called newsline, change permissions to 755 and place it in /etc/cron.weekly or you can create a custom cron. A new newsline is available each Saturday.
# MM HH DD MO DOW 0=sun, 1=mon
0 9 * * 6
You can convert it to .wav using mpg123 and then to gsm using sox. Or
you can try playing the MP3 directly after some conversion with lame:
lame --silent --mp3input --scale 2.5 --abr 32 -m m -h /tmp/newsline.mp3 /tmp/resampled-newsline.mp3
#My script
/usr/bin/lynx -source -dump ftp://ftp.arnewsline.org/quincy/News/news.mp3 >
/tmp/newsline.mp3
mpg123 -q -w /tmp/newsline.wav --mono /tmp/newsline.mp3
sox /tmp/newsline.wav -c1 -r8000 -w /var/lib/asterisk/sounds/newsline.gsm
chown "asterisk":"asterisk" /var/lib/asterisk/sounds/newsline.gsm
chmod 755 /var/lib/asterisk/sounds/newsline.gsm
/bin/rm /tmp/newsline.*
The next step is to add an entry in the /etc/asterisk/extensions_custom.conf file.
[custom-newsline]
exten => s,1,Answer
exten => s,2,Wait(2)
exten => s,3,Playback(newsline)
exten => s,4,hangup
Another option is to have the extension syntax make a System call to download the file, convert it, and then use the MP3Player syntax to play it
If you run a GUI such as with Trixbox (phpconfig for Asterisk PBX), you'll need to have the configuration editor re-read the configs, after you edit and append to this file.
Lastly is how to assign a numerical extension. This is probably best added into the extensions_additional.conf file. Most people are probably using a web front end like FreePBX or the one in AsteriskNOW to manage extensions.
The issue I've noticed is that changes really need to be made via the GUI. This is because the GUI doesn't check or re-read the underlying asterisk conf files. So what I'm saying is if you add code to the extensions_additional.conf or other files manually from the shell, you; 1) Won't see these under the GUI, and will have no GUI way to manage them. 2.) The changes you make from the shell won't be read until you force the system to do so, like is necessary above.
So I'll explain how to provision it through the GUI. It's kind of crude, but I did it under FreePBX, by adding a ring group. In my case I had Ring group 181 ring extension 181 for a ring time of 1 second. I set the Destination if no answer to the Custom App "custom-newsline,s,1"
Future expansion of this idea could involve podcasts
I'm not sure yet if there is a RSS command line tool that would allow one to have "this week in tech" or binary revolution" downloaded in a similar manner.
http://michigantelephone.mi.org/blog/2006/06/using-asterisk-and-freepbx-as-podcast_14.html
This Week In Amateur Radio
Here is my derivative to download This Week In Amateur Radio : twiar.agi
Syntax for /etc/asterisk/extensions_custom.conf
[custom-twiar]
exten => s,1,Answer
exten => s,2,AGI(twiar.agi)
exten => s,3,hangup
ARRL Audio News
I tried to retrieve the ARRL Audio News as a podcast like I did with other podcasts. This was unsuccessful. Looking at their pointer files source code I noticed that the link element is missing. (Last I checked that was part of the RSS 2.0 spec). I'm not sure what possessed someone at the ARRL to try to cram three pieces of data into one tag. (However I should note AAN RRS works fine with iTunes and other podcast aggregators.)
This is the key piece of info that the perl script looks for.
$url = $data->{channel}->{item}->[0]->{link};
It can be modified to look at the enclosure by replacing with this line:
$url = $data->{'channel'}->{'item'}->{'enclosure'}->{'url'};
Here is the finished product: arrl.agi
Syntax for /etc/asterisk/extensions_custom.conf
[custom-twiar]
exten => s,1,Answer
exten => s,2,AGI(arrl.agi)
exten => s,3,hangup
There is also downloadable MP3 file on the site. The problem is the file name changes a bit each week to indicate it's release date
You could set a cron-job to grab it like so:
# Cron for ARRL Audio News, This has to run on Friday. Do at 9:15 AM
15 9 * * 5 (/home/irlp/custom/GetARRL > /dev/null 2>&1)
#!/bin/bash
DATE=`date +%m%d`
/usr/bin/lynx -source -dump http://www.arrl.org/arrlletter/audio/arrl/aan`echo
"$DATE"`.mp3 > /tmp/arrlnews.mp3
To grab the latest file without a cron or date checking routine:
URL=`/usr/bin/lynx -dump http://www.arrl.org/arrlletter/audio/ |grep
".mp3" | head -1 | cut -d " " -f4`
/usr/bin/lynx -dump `echo "$URL"` > /tmp/arrlnews.mp3
I should note that these are all very long podcasts that callers have to wait
for it to first download, and then be converted to a format that Asterisk can
play back (Asterisk is really picky about what it will play). But that's
only true for the first caller to get a new podcast, subsequent callers should
get it instantly. If that's objectionable, the only thing I can suggest is
to set up some sort of background task on a timed schedule to check for a new
podcast and if one is found, download it and do the audio conversion (basically
all but the last couple of $AGI lines), then when someone calls let Asterisk
just play the resulting MP3 file. The downside of that is it will download
each new podcast, even if no one ever calls to hear it, and there may be a
slight delay before new podcasts become available to callers.
(Note that the format conversion delay may be less if you have a screaming fast
system, or much greater if you're using hardware that's pretty long in the
tooth).