This is a method for downloading an iPlayer file using a MediaSelector url (e.g. obtained from
http://www.bbc.co.uk/radio/aod/avail...adio4extra.xml ).
The code, below, is the content for the file
Download.htm (a file which runs Javascript).
Create an empty text file using NOTEPAD.EXE and copy-and-paste the HTML code below into it. This type of Javascript requires Internet Explorer. Run the .HTM file from your hard disk, in Internet Explorer; it won't run if you upload it to the internet.
To run it successfully, the user need only change the MediaSelector url highlighted in red (i.e. substitute the MediaSelector url of the iPlayer radio show you want to download).
The .HTM file creates a .BAT (batch) file on your Desktop. Put RTMPDUMP.EXE in the directory C:\Program Files\rtmpdump in order to run this .BAT file.
It downloads a media file with the extension .mp4 so you must alter that file's extension from .mp4 to .flv (and play it in GOM Player, or in Winamp 5.60 or later). The media file is an AAC file at 128 kbps (the highest quality used by the radio iPlayer). MP4 Audio using AAC at 128 kbps is an iTunes format file.
Note - I have only been able to test this method using Internet Explorer 8, on a borrowed laptop running Windows 7.
Code:
<html>
<head>
<title>Parse XML File</title>
<!-- Downloading from a BBC iPlayer page -->
<!-- This parses the elements in a MediaSelector xml page -->
<SCRIPT>
// Target XML file's URL address [MediaSelector URL]
var url = "http://www.bbc.co.uk/mediaselector/4/mtis/stream/b01by95r" ;
var xmlDoc;
window.open('','_self');
function loadxml()
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.onreadystatechange = readXML;
xmlDoc.load(url);
}
function readXML()
{
if(xmlDoc.readyState == 4) {
// This function is called on statechange
// When the state reaches 4 this function reads the xml document
// Create a Text File
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("MediaSelector.bat", true);
for(i=0; i<xmlDoc.getElementsByTagName("media").length; i++) {
bitrate = xmlDoc.getElementsByTagName("media")[i].attributes.getNamedItem("bitrate").nodeValue ;
encoding = xmlDoc.getElementsByTagName("media")[i].attributes.getNamedItem("encoding").nodeValue ;
if ( bitrate==128 && encoding=="aac" ){
fh.WriteLine( ':: Media tag #' + [i] );
fh.WriteLine( '' );
fh.WriteLine( 'SET rtmpdump=C:\\Program Files\\rtmpdump\\rtmpdump.exe' );
fh.WriteLine( '' );
fh.WriteLine( 'SET server=' +
xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("server").nodeValue );
fh.WriteLine( '' );
fh.WriteLine( 'SET application=' +
xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("application").nodeValue );
fh.WriteLine( '' );
fh.WriteLine( 'SET identifier=' +
xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("identifier").nodeValue );
fh.WriteLine( '' );
var str1=xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("authString").nodeValue ;
fh.WriteLine( 'SET authString=' + str1.replace(/&/g,"^&") );
fh.WriteLine( '' );
var str2=xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("identifier").nodeValue ;
fh.WriteLine( '"%rtmpdump%" --protocol 0 --host "%server%" -a "%application%?%authString%" ' +
'-y "%identifier%" -o ' + str2.slice(28,999) );
fh.WriteLine( '' );
fh.WriteLine( 'pause' );
}
}
fh.Close();
}
}
</SCRIPT>
</head>
<body onload="loadxml();window.close()"> </body>
</html>