id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	confirmation	distro	engine	distro_ver	engine_version	svn_rev
529	Module to play specific audio files from the web on demand	caribou7	nobody	I would like to see a module that allows you to define\r\ncertain extensions or codes (e.g. *30) so that they\r\nwill do the following:\r\n\r\n- Play ringing tone to the caller\r\n\r\n- Download an audio file from a specific fixed location\r\nOR extract the location URL from a "podcast" XML file\r\nand download that audio file (but, in the case of a\r\npodcast file, don't download the file again if we\r\nalready have it from a previous call and it hasn't been\r\nupdated - just play the one we previously downloaded).\r\n\r\n- When a new file is completely downloaded, call sox to\r\nconvert the file to a format asterisk is capable of\r\nplaying (if necessary)\r\n\r\n- answer the call (stop the ringing tone)\r\n\r\n- play the file to the caller\r\n\r\n- hangup\r\n\r\n- Delete the file, unless it's a podcast file in which\r\ncase save it (until a newer one is available to\r\noverwrite it) because someone else may want to hear it.\r\n\r\nWhen I first started playing with Asterisk, I did it\r\nthis way (this does NOT work anymore, because of some\r\nchange in how Asterisk 2.7 handles shell scripts):\r\n\r\nIn extensions_custom.conf:\r\n{{{\r\nexten => *30,1,ringing\r\nexten => *30,2,System(/var/lib/asterisk/batch/getmsnbc.sh)\r\nexten => *30,3,Wait(1)\r\nexten => *30,4,Answer\r\nexten => *30,5,MP3Player(/tmp/msnbc.mp3)\r\nexten => *30,6,Hangup\r\n}}}\r\nThen in getmsnbc.sh (don't laugh too hard, it was my\r\nfirst Linux script and it took me hours to write, but\r\nin the end it worked, although it probably does some\r\nthings that don't need to be done):\r\n{{{\r\nif [ -a /var/lib/asterisk/batch/msnbc.xml ]\r\nthen\r\nmv -f /var/lib/asterisk/batch/msnbc.xml\r\n/var/lib/asterisk/batch/msnbc2.xml\r\nfi\r\n/usr/bin/curl -s\r\nhttp://podcast.msnbc.com/audio/podcast/MSNBC-Headlines.xml\r\n> /var/lib/asterisk/batch/msnbc.xml\r\nif cmp -s /var/lib/asterisk/batch/msnbc.xml\r\n/var/lib/asterisk/batch/msnbc2.xml\r\nthen\r\nexit 0\r\nelse\r\ngrep -m 1  "http://podcast.msnbc.com/audio/podcast/vh"\r\n/var/lib/asterisk/batch/msnbc.xml | sed 's/^[\r\n\\t]*<link>/\\/usr\\/bin\\/curl -s /;s/<\\/link>/ >\r\n\\/tmp\\/msnbc.mp3\\nexit 0\\n/' >\r\n/var/lib/asterisk/batch/msnbcurl.sh\r\nchmod 744 /var/lib/asterisk/batch/msnbcurl.sh\r\n/var/lib/asterisk/batch/msnbcurl.sh\r\nfi\r\nexit 0\r\n}}}\r\nYes, this really did write a second shell script, then\r\njumped into it.  Sorry but as I say, this was my first\r\nattempt at trying to make a shell script. In\r\nAsterisk@Home 2.4 it would execute both scripts, and\r\nonly then return to\r\nexten => *30,3,Wait(1)\r\nBut in 2.7 it seems to fire off the shell script and\r\ncontinue blindly on, without waiting for the script to\r\nfinish.  The scripts themselves still work, but A@H\r\ndoesn't wait for them to finish.\r\n\r\nSo, in the module it should ask for these things:\r\n\r\nThe extension number you want to assign this to (could\r\nbe a * code also)\r\n\r\nThe full path and filename of the audio file or podcast\r\n(xml format) file.\r\n\r\nSelect ("radio button") whether it's a direct link to\r\nan audio file or a podcast XML file (if this can't be\r\ndetermined automatically - note that podcasts do not\r\nalways use a file with an XML extension, so you can't\r\nnecessarily go by extension)\r\n\r\nAnd, for XML-format files, the XML tag containing the\r\npath to the actual file.  This could be a little tricky\r\nbecause, for example, in this case you're looking for\r\nthe tag "<enclosure url=" but the data you want is\r\nINSIDE the tag, such as this:\r\n{{{\r\n<enclosure\r\nurl="http://podcast.msnbc.com/audio/podcast/vh-03-25-2006-161811.mp3"\r\nlength="108239" type="audio/mpeg"/>\r\n}}}\r\nPoint is, you need some way to explicitly declare where\r\nto look in the file for the URL of the file to download\r\nand play. I am led to believe "<enclosure url=" is a\r\nnormal tag for a podcast BUT I can imagine that in some\r\nother cases the desired URL would be bracketed by\r\nspecific tags (not part of the tag itself). Also there\r\nmay be times when you might want to extract a URL from\r\na regular HTML page.\r\n\r\nBonus points for allowing playback of formats other\r\nthan MP3. TRIPLE bonus points if you manage to play the\r\ndreaded WMA format and its ilk.\r\n\r\nNote we are NOT talking about playing STREAMING audio\r\nhere, though that could certainly be another option. \r\nThese are for things like one or two minute newscasts,\r\nweather reports or whatever.  Just an idea (since it's\r\nmuch easier to pick up a phone and punch in a few\r\ndigits than to go to a computer, fire up a web browser,\r\nfind what you want to listen to, and try to launch it).	Feature Requests	assigned	minor	Undetermined	Web interface	Eventually	None			Unreviewed		All			
