Michigan Telephone, VoIP and Broadband blog - Using Asterisk and FreePBX as a podcast player

The start URL is dead:
http://michigantelephone.mi.org/blog/2006/06/using-asterisk-and-freepbx-as-podcast.html

http://michigantelephone.wordpress.com/2006/06/14/using-asterisk-and-freepbx-as-a-podcast-player-part-2-of-3/

http://michigantelephone.wordpress.com/2006/06/14/using-asterisk-and-freepbx-as-a-podcast-player-part-3-of-3/

 


Install script:

#!/bin/sh
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/Test-Simple-0.62.tar.gz
tar xzvf Test-Simple-0.62.tar.gz
cd Test-Simple-0.62
perl Makefile.PL
make install

cd /tmp
wget http://search.cpan.org/CPAN/authors/id/R/RG/RGARCIA/Test-LongString-0.09.tar.gz
tar xzvf Test-LongString-0.09.tar.gz
cd Test-LongString-0.09
perl Makefile.PL
make install

cd /tmp
wget http://search.cpan.org/CPAN/authors/id/P/PE/PETDANCE/WWW-Mechanize-1.18.tar.gz
tar xzvf WWW-Mechanize-1.18.tar.gz
cd WWW-Mechanize-1.18
perl Makefile.PL
make install

cd /tmp
#wget http://search.cpan.org/CPAN/authors/id/G/GR/GRANTM/XML-Simple-2.14.tar.gz
#The above  was found dead try:
http://search.cpan.org/CPAN/authors/id/G/GR/GRANTM/XML-Simple-2.18.tar.gz
tar xzvf XML-Simple-2.14.tar.gz
cd XML-Simple-2.14
perl Makefile.PL
make install

cd /tmp
wget http://search.cpan.org/CPAN/authors/id/G/GS/GSAR/Tie-IxHash-1.21.tar.gz
tar xzvf Tie-IxHash-1.21.tar.gz
cd Tie-IxHash-1.21
perl Makefile.PL
make install

Also required is lame and mpg123 


msnbcnews.agi

#!/usr/bin/perl

use XML::Simple;
use Asterisk::AGI;
use LWP::Simple;

$AGI = new Asterisk::AGI;
$xml = new XML::Simple;
$noext = "/tmp/arrl";
$resampled = "/tmp/msnbc.mp3";

$AGI->verbose("Getting XML file\n");
$data = $xml->XMLin(get("http://podcast.msnbc.com/audio/podcast/MSNBC-Headlines.xml"));
$url = $data->{'channel'}->{'item'}->{'enclosure'}->{'url'};
$AGI->verbose("Extracted URL $url from XML file");
$url =~ m#(?:.*/)(.*)$#;
$podcast = "/tmp/" . $1;
if ((-s $podcast) && (-s $resampled))
{
$AGI->verbose("$podcast already exists - skipping download\n");
}
else
{
system("rm /tmp/vh-*.mp3");
$AGI->verbose("Getting $url\n");
getstore("$url", "$podcast") or die "Could not retrieve podcast";
$AGI->verbose("$podcast retrived\n");
system("lame --silent --mp3input --scale 2.5 --abr 32 -m m -h $podcast $resampled")==0 or die "Could not convert file";
$AGI->verbose("$pd converted to $resampled\n");
}
$AGI->answer;
$AGI->exec('Playback',$noext);
exit;

cnn.agi
#!/usr/bin/perl

use XML::Simple;
use Asterisk::AGI;
use LWP::Simple;

$AGI = new Asterisk::AGI;
$xml = new XML::Simple;
$noext = "/tmp/newscnn";
$resampled = "/tmp/newscnn.mp3";

$AGI->verbose("Getting XML file\n");
$data = $xml->XMLin(get("http://www.cnn.com/services/podcasting/newscast/rss.xml"));
$url = $data->{channel}->{item}->[0]->{link};
$AGI->verbose("Extracted URL $url from XML file");
$url =~ m#(?:.*/)(.*)$#;
$podcast = "/tmp/" . $1;
if ((-s $podcast) && (-s $resampled))
{
$AGI->verbose("$podcast already exists - skipping download\n");
}
else
{
system("rm /tmp/CNN-News*.mp3");
$AGI->verbose("Getting $url\n");
getstore("$url", "$podcast") or die "Could not retrieve podcast";
$AGI->verbose("$podcast retrived\n");
system("/usr/local/bin/lame --silent --mp3input --scale 2.5 --abr 32 -m m -h $podcast $resampled")==0 or die 
"Could not convert file";
$AGI->verbose("$pd converted to $resampled\n");
}
$AGI->answer;
$AGI->exec('Playback',$noext);
#$AGI->exec('MP3Player',$resampled);
exit;


 

Return to Main Page