login | register
Fri 09 of Jan, 2009 [02:16 UTC]

voip-info.org

History

PodCast

Created by: ZX81,Last modification on Wed 05 of Sep, 2007 [20:22 UTC] by sbright
Ok, so first up, you will need this or something similar in your extensions.conf:

[podcast]
exten => s,1,Answer()
exten => s,2,Background(podcast)
exten => s,3,goto(2)

; === Security
exten => 1,1,Set(url=http://SecurityWireWeekly.blogspot.com/atom.xml)
exten => 1,2,Agi(mytest)
exten => 1,3,Set(url=http://www.codesermon.org/portals/15/podcast.xml)
exten => 1,4,Agi(mytest)
exten => 1,5,Goto(s,2)

; === VoIP
exten => 2,1,Set(url=http://vonradio.pulver.com/podcasts/audiorss.xml)
exten => 2,2,Agi(mytest)
exten => 2,3,Goto(s,2)

; === Comedy
exten => 3,1,Set(url=http://extrafancy.net/blog/wp-rss2.php)
exten => 3,2,Agi(mytest)
exten => 3,3,Set(url=http://podcast.dailystupid.com/blueg/index.xml)
exten => 3,4,Agi(mytest)
exten => 3,5,Set(url=http://feeds.feedburner.com/TripleParadoxPodcast)
exten => 3,6,Agi(mytest)
exten => 3,7,Goto(s,2)

And you will also need the AGI file:

#!/usr/local/bin/php -q
<?
       require "phpagi.php";

       $agi = new AGI();

       function read() {
               global $in, $debug, $stdlog;
               $input = str_replace("\n", "", fgets($in, 4096));
               if ($debug) fputs($stdlog, "read: $input\n");
               return $input;
       }

       $url2 = $agi->get_var("url");

       require_once('/var/lib/asterisk/agi-bin/magpierss/rss_fetch.inc');

       echo "VERBOSE \"[" . $url2 . "]\"\n";
       $rss = fetch_rss($url2);
       $x=0;
       foreach ($rss->items as $item) {
               if ($x < 1) {
                       $x++;
                       $dat = $item['atom_content'];
                       $dat2= $item['guid'];
                       $dat3= $item['enclosure'][0]['url'];
                       $title = $item['title'];
                       echo "VERBOSE \"URL: ".$dat3."\"\n";
                       if (strlen($dat3) > 0){
                               $dom3 = $dat3;
                       } else  if (strpos($dat2,"mp3") > 0) {
                               $dom3 = $dat2;
                       } else {
                               $dom = stristr($dat, '<a href="');
                               $dom2 = stristr($dom, '"');
                               if (strlen($dom2) > 0) {
                                       if (strpos($dom2,'"',1) - 1 > 0) {
                                               $dom3 = substr($dom2, 1, strpos($dom2, '"', 1) - 1);
                                       } else {
                                               $x--;
                                       }
                               } else {
                                       $x--;
                               }
                       }
               }
       }

       if (strpos($title,"VONradio")>-1) {
               $title="VON Radio";
       }

       echo "SET VARIABLE mytest \"" . $dom3 . "\"\n";
       echo "EXEC MP3Player " . $dom3 . "\n";
?>


You will also need to install magpie rss into the /var/lib/asterisk/agi-bin/magpierss/ directory.

Comments

Comments Filter
222

333Suggestions to get this to work

by qai, Saturday 29 of July, 2006 [07:38:20 UTC]
Ok. Some things I encountered using this application that may be evident to others.
1. Put context brackets around podcast when installing it into your extensions.conf file
2. Make sure that you have an audio file called podcast in your sounds directory
3. Replace the "1" in line 1 of the mytest.php file with a # sign
4. I had to remove the "/local" part of the pathname for php - read #!/usr/bin/php -q

So now with these changes, why does this still not work. Can you suggest a few strategic debug statements to put into the mytest.php file?