PDA

View Full Version : RTMPDump v2.1d and BBC iPlayer


Ed999
08-19-2011, 02:57 AM
These are the three batch files I use for downloading 'Listen Again' radio shows from the BBC iPlayer, for station Radio 4 Extra (formerly Radio 7), using RTMPdump (http://all-streaming-media.com/record-video-stream/rtmpdump-freeware-console-RTMP-downloading-application.htm).exe and RTMPsrv.exe v2.1d :


Note : The only edit needed each time is in line 2 of the first file, replacing the 8 zero's with the 8 digit PID - Programme ID - from the URL address of the iPlayer page that plays the radio show you want.

Note : I set up these files on a test laptop that was running Windows 7. The HOSTS directory address on your computer may be different in earlier versions of Windows.

Note : I am including an attachment containing all three of these batch files, plus some other files that I find useful. You'll just need to extract the .zip file to an empty directory and add your preferred version of RTMPDump.exe and RTMPsrv.exe (use v2.1d or later).



Run #1 - Preliminary Matters + Start RTMPSRV.bat


@echo off
SET PID=00000000

:: ================================================== ====== ::

cls
SET open="C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE"

:: Open the Playlist page (to obtain Identifier) -
%open% http://www.bbc.co.uk/iplayer/playlist/%PID%

:: Create a URL for the MediaSelector page (to inject Identifier in) -
echo @echo off>> MediaSelector.bat
echo. >> MediaSelector.bat
echo "C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE" http://www.bbc.co.uk/mediaselector/4/mtis/stream/00000000>> MediaSelector.bat
echo. >> MediaSelector.bat
echo cls>> MediaSelector.bat
C:\WINDOWS\NOTEPAD.EXE MediaSelector.bat

:: ================================================== ====== ::

rem *** Create "Run #2" Link ***

IF EXIST Run#2*.PIF DEL Run#2*.PIF
IF EXIST "Run #2.url" DEL "Run #2.url"
IF EXIST "Run #2 - Play iPlayer.url" DEL "Run #2 - Play iPlayer.url"

echo @ECHO OFF>> "Run #2.bat"
echo "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://www.bbc.co.uk/iplayer/console/%PID%">> "Run #2.bat"
echo CLS>> "Run #2.bat"

:: ================================================== =============== ::

rem *** Create "Photos" Links ***

echo @ECHO OFF>> Photos.bat
echo.>> Photos.bat
echo SET open="C:\Program Files (x86)\Internet Explorer\iexplore.exe">> Photos.bat
echo SET url=http://node2.bbcimg.co.uk/iplayer/images/episode>> Photos.bat
echo.>> Photos.bat
echo %%open%% %%url%%/%PID%_150_84.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_178_100.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_261_147.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_303_170.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_512_288.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_528_297.jpg>> Photos.bat
echo %%open%% %%url%%/%PID%_640_360.jpg>> Photos.bat
echo.>> Photos.bat
echo CLS>> Photos.bat
echo.>> Photos.bat
echo.>> Photos.bat

:: ================================================== =============== ::

rem *** Edit the HOSTS file ***

IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\NOHOSTS REN C:\WINDOWS\SYSTEM32\DRIVERS\ETC\NOHOSTS HOSTS

rem Replace line 1 with this:
rem 127.0.0.1 bbcmedia.fcod.llnwd.net

IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX ECHO.
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX ECHO HOSTS_XX already exists: Aborting!
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX PAUSE
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX GOTO END

C:\WINDOWS\SYSTEM32\ATTRIB.EXE -R -S -H C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
REN C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS HOSTS_XX
:: Next line: Setting prior to 1pm on 12 July '10
:: echo 127.0.0.1 bbcmedia.fcod.llnwd.net> C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
:: Next line: Setting FROM 1pm on 12 July '10 onwards
echo 127.0.0.1 bbcodspdns.fcod.llnwd.net> C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
C:\WINDOWS\SYSTEM32\ATTRIB.EXE +R +H C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS

cls

:: ================================================== =============== ::

rem *** Start RTMPSRV ***

:: Start RTMPSRV.EXE and pipe the URLs it displays to a .BAT file
:: to be used with RTMPDUMP to download the iPlayer file

"C:\Users\dg\Desktop\General\iPlayer\- Recording iPlayer\rtmpsrv.exe" > RTMPdump_run.bat


:END
cls




Run #3 - Run RTMPdump_run.bat


@echo off

rem *** Edit the HOSTS file ***

rem Wait 8 Seconds
echo.
echo Wait 8 Seconds ...
echo.
@CHOICE /T 8 /C yn /D y > NUL

cls

rem Restore the normal line 1:
rem 127.0.0.1 localhost

C:\WINDOWS\SYSTEM32\ATTRIB.EXE -R -S -H C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX DEL C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS
IF EXIST C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX REN C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS_XX HOSTS
C:\WINDOWS\SYSTEM32\ATTRIB.EXE +R +H C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS

:: ================================================== =============== ::

rem *** Run RTMPDUMP ***
CALL RTMPdump_run.bat

rem *** Rename the downloaded file ***
:: REN *.MP4 *.flv

rem *** Save the Download command ***
COPY "Notes.txt"+"RTMPdump_run.bat" "Notes_New.txt"
echo. >> "Notes_New.txt"
DEL "Notes.txt"
REN "Notes_New.txt" "Notes.txt"

rem *** Save the SWFINFO file ***
COPY "Notes.txt"+".swfinfo" "Notes_New.txt"
echo. >> "Notes_New.txt"
echo. >> "Notes_New.txt"
DEL "Notes.txt"
REN "Notes_New.txt" "Notes.txt"

rem *** Open MediaSelector page ***
IF EXIST MediaSelector.bat CALL MediaSelector.bat

rem *** Tidy Up ***
IF EXIST *.swfinfo DEL *.swfinfo
IF EXIST RTMPdump_run.bat DEL RTMPdump_run.bat
IF EXIST MediaSelector.bat DEL MediaSelector.bat
IF EXIST Run#2*.PIF DEL Run#2*.PIF
IF EXIST "Run #2.BAT" DEL "Run #2.BAT"

:: ================================================== =============== ::

:: Delete BBC Cookies
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cook ies\dg@bbc.* .txt
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cook ies\dg@bbc.co .txt
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cook ies\dg@www.bbc.co .txt
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cook ies\dg@cookie.radioplayer.co .txt
DEL C:\Users\dg\AppData\Roaming\Microsoft\Windows\Cook ies\dg@static.radioplayer.co .txt

:: ================================================== =============== ::

cls




Run #4 - Rename FLV file.bat


@echo off

rem *** Rename the downloaded file ***
IF EXIST *.MP4 REN *.MP4 *.flv

setlocal enabledelayedexpansion

for %%j in (RBN2_radio_4_*.flv) do (
set filename=%%~nj
set filename=!filename:RBN2_radio_4_-_=!
set filename=!filename:RBN2_radio_4_extra_-_=!
set filename=!filename:monday=Mon!
set filename=!filename:tuesday=Tue!
set filename=!filename:wednesday=Wed!
set filename=!filename:thursday=Thu!
set filename=!filename:friday=Fri!
set filename=!filename:saturday=Sat!
set filename=!filename:sunday=Sun!
set filename=!filename:_b00= [b00!
set filename=!filename:_b01= [b01!
set filename=!filename:_2011_01_=] 2011-01-!
set filename=!filename:_2011_02_=] 2011-02-!
set filename=!filename:_2011_03_=] 2011-03-!
set filename=!filename:_2011_04_=] 2011-04-!
set filename=!filename:_2011_05_=] 2011-05-!
set filename=!filename:_2011_06_=] 2011-06-!
set filename=!filename:_2011_07_=] 2011-07-!
set filename=!filename:_2011_08_=] 2011-08-!
set filename=!filename:_2011_09_=] 2011-09-!
set filename=!filename:_2011_10_=] 2011-10-!
set filename=!filename:_2011_11_=] 2011-11-!
set filename=!filename:_2011_12_=] 2011-12-!
set filename=!filename:~0,-9%!
set filename=!filename:_= !
if not "!filename!"=="%%~nj" ren "%%j" "!filename!%%~xj"
)

Ed999
02-17-2012, 02:32 PM
This is a method for downloading an iPlayer file using a MediaSelector url (e.g. obtained from http://www.bbc.co.uk/radio/aod/availability/radio4extra.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.


<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>

Ed999
02-18-2012, 09:45 AM
This is a Batch file which performs the same function as the .HTM file in my post of yesterday (above).


@ECHO OFF

:: *** MediaSelector ID ***

:: Final 8 Characters
SET ID=b01by95r

:: Source -
:: http://www.bbc.co.uk/radio/aod/availability/radio4extra.xml


:: *** Create a HTM file ***

ECHO ^<html^> >> %temp%\temp.htm
ECHO ^<head^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^<title^>Parse XML File^</title^> >> %temp%\temp.htm
ECHO.
ECHO ^<!-- Downloading from a BBC iPlayer page --^> >> %temp%\temp.htm
ECHO ^<!-- This parses the elements in a MediaSelector xml page --^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^<SCRIPT^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Target XML file's URL address [MediaSelector URL] >> %temp%\temp.htm
ECHO var url = "http://www.bbc.co.uk/mediaselector/4/mtis/stream/%ID%" ; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO var xmlDoc; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO window.open('','_self'); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO function loadxml() >> %temp%\temp.htm
ECHO { >> %temp%\temp.htm
ECHO xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); >> %temp%\temp.htm
ECHO xmlDoc.async = false; >> %temp%\temp.htm
ECHO xmlDoc.onreadystatechange = readXML; >> %temp%\temp.htm
ECHO xmlDoc.load(url); >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO function readXML() >> %temp%\temp.htm
ECHO { >> %temp%\temp.htm
ECHO if(xmlDoc.readyState == 4) { >> %temp%\temp.htm
ECHO // This function is called on statechange >> %temp%\temp.htm
ECHO // When the state reaches 4 this function reads the xml document >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Create a Text File >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO var fso = new ActiveXObject("Scripting.FileSystemObject"); >> %temp%\temp.htm
ECHO var fh = fso.CreateTextFile("C:\\Users\\dg\\AppData\\Local\\Temp\\MediaSelector .bat", true); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO for(i=0; i^<xmlDoc.getElementsByTagName("media").length; i++) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO bitrate = xmlDoc.getElementsByTagName("media")[i].attributes.getNamedItem("bitrate").nodeValue ; >> %temp%\temp.htm
ECHO encoding = xmlDoc.getElementsByTagName("media")[i].attributes.getNamedItem("encoding").nodeValue ; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO if ( bitrate==128 ^&^& encoding=="aac" ){ >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO fh.WriteLine( '@echo off' ); >> %temp%\temp.htm
ECHO fh.WriteLine( ':: Media tag #' + [i] ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET rtmpdump=C:\\Data\\General\\iPlayer\\- Recording iPlayer\\rtmpdump.exe' ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET server=' + >> %temp%\temp.htm
ECHO xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("server").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET application=' + >> %temp%\temp.htm
ECHO xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("application").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET identifier=' + >> %temp%\temp.htm
ECHO xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("identifier").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm

ECHO var str1=xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("authString").nodeValue ; >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET authString=' + str1.replace(/^&/g,"^&") ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO var str2=xmlDoc.getElementsByTagName("media")[i].firstChild.attributes.getNamedItem("identifier").nodeValue ; >> %temp%\temp.htm
ECHO fh.WriteLine( '"%%rtmpdump%%" --protocol 0 --host "%%server%%" -a "%%application%%?%%authString%%" ' + >> %temp%\temp.htm
ECHO '-y "%%identifier%%" -o ' + str2.slice(28,999) ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO fh.Close(); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^</SCRIPT^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^</head^> >> %temp%\temp.htm
ECHO ^<body onload="loadxml();window.close()"^> ^</body^> >> %temp%\temp.htm
ECHO ^</html^> >> %temp%\temp.htm


:: *** Run HTM file in Internet Explorer ***
"C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE" %temp%\temp.htm

:: *** Run MediaSelector.bat ***
CALL %temp%\MediaSelector.bat

Ed999
03-15-2012, 12:34 PM
This is a method for downloading an iPlayer TV stream using its MediaSelector url.

Just like a radio show, a tv show/stream has its own unique 8-digit ID number, which is contained in the MediaSelector URL for that stream. It is displayed - amongst other places - on the Playlist xml page associated with the particular stream. That 8-digit ID (identifier) can be used in the javascript code set out below.

See my other posts, above, for further details of the MediaSelector ID and how to find it.

The HTML code, below, is the content for the file TV_Download.htm (a file which runs Javascript).

All you need do is change the 8-digit ID number highlighted in red for the actual MediaSelector 8-digit ID of the tv show you want to download.

If you alter the sections highlighted in blue, you can download instead a stream running at a different bitrate. Details of the available bitrates for each tv show are given in that show's MediaSelector page. Each tv show is offered by the BBC in half a dozen different bitrates, from 184 kbps to 1500 kbps.

You can also choose either a LIMELIGHT server or an AKAMAI server for some bitrates. There is not much difference in video or audio quality between the two types, at any given bitrate; but there may be a difference in file size.

If you open the .HTML file in Internet Explorer 8 or 9, and allow the javascript to run, it will create a .bat batch file at C:\MediaSelector.bat containing the download command. You then run that batch file to do the actual download. The tv show will, by default, download into your C:\ root directory.

You must copy the program RTMPDUMP.EXE (http://all-streaming-media.com/record-video-stream/rtmpdump-freeware-console-RTMP-downloading-application.htm) into the folder "C:\Program Files\rtmpdump" in order for this method to succeed.




<html>
<head>
<title>Parse XML file in Internet Explorer</title>

<SCRIPT language="javascript">

// Target XML file's URL address [MediaSelector URL]
var url = "http://www.bbc.co.uk/mediaselector/4/mtis/stream/b01d5nj6";
var xmlDoc;

window.open('','_self'); // This prevents the browser window prompting before closing

function loadxml(){
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.onreadystatechange = readXML;
xmlDoc.load(url);
}

function readXML(){
if ( xmlDoc.readyState==4 ) {

var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("C:\\MediaSelector.bat",true);

var a = xmlDoc.getElementsByTagName("media");
for (i=0;i<a.length;i++) {
element1 = a[i].attributes.getNamedItem("kind").nodeValue; // create array

if ( element1=="video" ) {

// Element "bitrate" only exists WITHIN element "video"
element2 = a[i].attributes.getNamedItem("bitrate").nodeValue; // create array
if ( element2==796 ) {

var b = a[i].childNodes;
for (j=0;j<b.length;j++) {

element3 = b[j].attributes.getNamedItem("supplier").nodeValue;
if ( element3=="limelight" ) {


// Write elements in selected Child tag to file
fh.WriteLine( '@echo off' );
fh.WriteLine( ':: Media tag #' + [i] + ', Child tag #' + [j] );
fh.WriteLine( '' );
fh.WriteLine( 'SET rtmpdump=C:\\Program Files\\rtmpdump\\rtmpdump.exe' );
fh.WriteLine( '' );
fh.WriteLine( 'SET server=' + b[j].attributes.getNamedItem("server").nodeValue );
fh.WriteLine( '' );
fh.WriteLine( 'SET application=' + b[j].attributes.getNamedItem("application").nodeValue );
fh.WriteLine( '' );
fh.WriteLine( 'SET identifier=' + b[j].attributes.getNamedItem("identifier").nodeValue );
fh.WriteLine( '' );
var str1 = b[j].attributes.getNamedItem("authString").nodeValue ;
fh.WriteLine( 'SET authString=' + str1.replace(/&/g,"^&") );
fh.WriteLine( '' );
fh.WriteLine( ':: *** Command Line : TV : 796 kbps ***' );
var str2 = b[j].attributes.getNamedItem("identifier").nodeValue ;
var str3 = str2.split("/");
fh.WriteLine( '"%rtmpdump%" --protocol 0 --host "%server%" -a "%application%?%authString%" ' +
'-y "%identifier%" -o "'+element2+'kbps '+element3+' '+str3[4]+'" --resume --timeout 15' );

}
}
}
}
}
}
}
</SCRIPT>

</head>
<body onload="loadxml();window.close();"> </body>
</html>

chap
03-15-2012, 05:05 PM
This is a method for downloading an iPlayer TV stream using its MediaSelector url.
thanks works fine:cool:

bat999
03-16-2012, 06:54 AM
thanks works fine
Are you guys using this longwinded method for a particular reason? :cool:
RTMPDump v2.1d :confused:

Ed999
03-17-2012, 06:11 AM
I've posted this method, which combines RTMPDUMP with JavaScript, because I was asked - by PM - to suggest an easy method for choosing between the 9 different streams the BBC server provides for each tv show available on iPlayer.

For television, the BBC server offers 5 different bitrates, 4 of which are available from two different suppliers.

My method makes it easy to specify the bitrate you want and the server you want.

Most of the download methods available online don't give the user any choice at all as to bitrate or supplier, but merely capture a default version, determined either by the download program being used or by the iplayer software.

I'm not aware of any other solution which gives the user complete control over which bitrate and supplier to use.

A lower bitrate can be useful if you have a slow broadband connection or only a dial-up connection, and the size of the downloaded file can be different - even for the same bitrate - depending upon which supplier is chosen.


Although this thread has discussed a particular version of RTMPDUMP, using Windows 7 I've not noticed that any version of RTMPDUMP is better or worse than any other. I've mainly used v2.1d as it happens.

Ed999
03-25-2012, 06:53 AM
Here is a similar HTML file, the contents of TV_live.htm, for recording a live tv stream. This needs rtmpdump version 2.4 (at C:\Program Files\RTMPDUMP).

This is valid only for the AKAMAI server (won't work with a LIMELIGHT stream).

It creates a .bat file in C:\ root which must be run to do the actual recording.



<html>
<head>

<title>Parse BBC iPlayer XML File - Javascript Method</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/bbc_one_live_rtmp";

var xmlDoc;

window.open('','_self'); // This prevents the browser window prompting before closing

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("C:\\MediaSelector.bat",true);


// LEVEL 1 TAGS [Primary tags]

// Specify the Level 1 tag to loop through
var a = xmlDoc.getElementsByTagName("media");

// Loop instruction
for (i=0;i<a.length;i++) {

// Specify a target element within the Level 1 tag
// Specified element must exist in ALL the Level 1 tags
element1 = a[i].attributes.getNamedItem("kind").nodeValue; // create array [Line 50]

// Conditional Filter
// Pass only those tags that contain video data
if ( element1=="video" ) {

// Conditional Filter [Bitrate]
// Pass only the tag that contains the desired bitrate
element2 = a[i].attributes.getNamedItem("bitrate").nodeValue; // create array
if ( element2==796 ) {

// NOTE: The element "bitrate" can't be used as the primary filter at line 50,
// because it's an element that does NOT exist in all primary level tags


// LEVEL 2 TAGS [Child tags]

// Loop through each Child tag
var b = a[i].childNodes;

// Loop instruction
for (j=0;j<b.length;j++) {

// Specify a target element within the Child tag
// Specified element must exist in ALL the Child tags
element3 = b[j].attributes.getNamedItem("supplier").nodeValue; // create array

// Conditional Filter [Supplier]
// Pass only the Child tag that contains the desired supplier
if ( element3=="akamai" ) {

// Write elements in selected Child tag to file
fh.WriteLine( '@echo off' );
fh.WriteLine( '' );
fh.WriteLine( 'SET rtmpdump=C:\\Program Files\\RTMPDUMP\\rtmpdump.exe' );
fh.WriteLine( '' );
fh.WriteLine( 'SET protocol=' + b[j].attributes.getNamedItem("protocol").nodeValue );
fh.WriteLine( '' );
fh.WriteLine( 'SET server=' + b[j].attributes.getNamedItem("server").nodeValue );
fh.WriteLine( '' );
fh.WriteLine( 'SET application=' + b[j].attributes.getNamedItem("application").nodeValue );
fh.WriteLine( '' );
fh.WriteLine( 'SET identifier=' + b[j].attributes.getNamedItem("identifier").nodeValue );
fh.WriteLine( '' );

var str1=b[j].attributes.getNamedItem("authString").nodeValue;
fh.WriteLine( 'SET authString=' + str1.replace(/&/g,"^&") );
fh.WriteLine( '' );

fh.WriteLine( ':: *** Command Line : TV : AKAMAI ***' );
fh.WriteLine( '"%rtmpdump%" --live --verbose ' +
'-r "%protocol%://%server%:1935/%application%?%authString%" ' +
'-a "%application%?%authString%" -y "%identifier%?%authString%" ' +
'-W "http://www.bbc.co.uk/emp/releases/iplayer/revisions/617463_618125_4/617463_618125_4_emp.swf" ' +
'-o "bbc_one_live_rtmp '+element2+'kbps '+element3+'.flv" ' );


} } // Close Level 2
} } } // Close Level 1
}
}

</SCRIPT>

</head>
<body onload="loadXML();window.close()"> </body>
</html>

Ed999
03-25-2012, 09:55 AM
Any .flv or .mp4 video stream can be watched while the stream is still downloading, using the command line utility FFPLAY.EXE


The build to use (with Windows XP/Vista/7) is FFPLAY release 16573 -

http://ffmpeg.arrozcru.org/builds/shared/ffmpeg-r16537-gpl-shared-win32.tar.bz2


The ffplay syntax is -

ffplay.exe -bufsize 4096 *.*


The command line is (for example) -

"C:\Program Files\FFPLAY\ffplay.exe" -bufsize 4096 *.flv

If the stream is downloading as .mp4 rather than as .flv then change *.flv to *.mp4 instead

Put that command line in a .bat batch file (e.g. play.bat) and put the .bat file in the directory in which the stream is downloading, then run the batch file.

Ed999
05-11-2012, 02:24 PM
My scripts - above - might cause the following security prompt (in Internet Explorer):

"An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?"


To avoid receiving that prompt, in Windows 7 set the following Registry value:

HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Internet Settings\Zones\0
"1201"=dword:00000000

Ed999
12-26-2012, 06:05 AM
Here is a revised script for downloading the Akamai live tv streams from the BBC.

This is a modified version of the batch file script posted above in this thread, modified to take account of recent changes on the BBC website.

Copy-and-paste the code into a plain text file called (for example) BBCtv_Live_Akamai.bat



@echo off

:: *** Select Channel *** [ MediaSelector ID ]

SET ID=bbc_one_london
:: SET ID=bbc_two_england
:: SET ID=bbc_three
:: SET ID=bbc_four


:: *** Select Bitrate *** [ MediaSelector Bitrate ]

:: SET bitrate=56
:: SET bitrate=176
:: SET bitrate=396
:: SET bitrate=480
SET bitrate=796
:: SET bitrate=1500


:: *** Select Supplier *** [ MediaSelector Supplier ] !! This script ONLY works for an AKAMAI server !!

SET supplier=akamai


:: *** Media Selector pages ***

:: http://www.bbc.co.uk/mediaselector/4/mtis/stream/bbc_one_london
:: http://www.bbc.co.uk/mediaselector/4/mtis/stream/bbc_two_england
:: http://www.bbc.co.uk/mediaselector/4/mtis/stream/bbc_three
:: http://www.bbc.co.uk/mediaselector/4/mtis/stream/bbc_four



:: *** Port ***
SET port=1935

:: *** RTMPDump v2.4 (RTMPDump v2.1d doesn't work) ***
SET rtmpdump=C:\\Program Files (x86)\\rtmpdump\\rtmpdump.exe

:: *** SWF File ***
SET swf=http://www.bbc.co.uk/emp/releases/iplayer/revisions/617463_618125_4/617463_618125_4_emp.swf

:: *** File Name ***
SET currDate=%date:/=-%
SET currTime=%time::=-%

:: *** Safety Tests ***
IF EXIST "%temp%\*.bat" DEL "%temp%\*.bat"
IF EXIST "%temp%\*.htm" DEL "%temp%\*.htm"



:: *** Create a HTML file : AKAMAI ***

ECHO ^<html^> >> %temp%\temp.htm
ECHO ^<head^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^<title^>Parse BBC iPlayer XML File - Javascript Method^</title^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^<!-- Downloading from a BBC iPlayer page --^> >> %temp%\temp.htm
ECHO ^<!-- This parses the elements in a MediaSelector XML page --^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^<SCRIPT^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Target XML file's URL address [MediaSelector URL] >> %temp%\temp.htm
ECHO var url = "http://www.bbc.co.uk/mediaselector/4/mtis/stream/%ID%"; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO var xmlDoc; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO window.open('','_self'); // This prevents the browser window prompting before closing >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO function loadXML() >> %temp%\temp.htm
ECHO { >> %temp%\temp.htm
ECHO xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); >> %temp%\temp.htm
ECHO xmlDoc.async = false; >> %temp%\temp.htm
ECHO xmlDoc.onreadystatechange = readXML; >> %temp%\temp.htm
ECHO xmlDoc.load(url); >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO function readXML() >> %temp%\temp.htm
ECHO { >> %temp%\temp.htm
ECHO if(xmlDoc.readyState == 4) { >> %temp%\temp.htm
ECHO // This function is called on statechange >> %temp%\temp.htm
ECHO // When the state reaches 4 this function reads the xml document >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Create a Text File >> %temp%\temp.htm
ECHO var fso = new ActiveXObject("Scripting.FileSystemObject"); >> %temp%\temp.htm
ECHO var fh = fso.CreateTextFile("C:\\MediaSelector.bat",true); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // LEVEL 1 TAGS [Primary tags] >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Specify the Level 1 tag to loop through >> %temp%\temp.htm
ECHO var a = xmlDoc.getElementsByTagName("media"); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Loop instruction >> %temp%\temp.htm
ECHO for (i=0;i^<a.length;i++) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Specify a target element within the Level 1 tag >> %temp%\temp.htm
ECHO // Specified element must exist in ALL the Level 1 tags >> %temp%\temp.htm
ECHO element1 = a[i].attributes.getNamedItem("kind").nodeValue; // create array [Line 50] >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Conditional Filter >> %temp%\temp.htm
ECHO // Pass only those tags that contain video data >> %temp%\temp.htm
ECHO if ( element1=="video" ) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Test value of chosen element within this IF condition >> %temp%\temp.htm
ECHO // alert( "Video = " + element1 ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm



/Continued below...

Ed999
12-26-2012, 06:08 AM
/Continued...



ECHO // Conditional Filter [Bitrate] >> %temp%\temp.htm
ECHO // Pass only the tag that contains the desired bitrate >> %temp%\temp.htm
ECHO element2 = a[i].attributes.getNamedItem("bitrate").nodeValue; // create array >> %temp%\temp.htm
ECHO if ( element2==%bitrate% ) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // NOTE: The element "bitrate" can't be used as the primary filter at line 50, >> %temp%\temp.htm
ECHO // because it's an element that does NOT exist in all primary level tags >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Test value of chosen element within this IF condition >> %temp%\temp.htm
ECHO // alert( "Bitrate = " + element2 ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // LEVEL 2 TAGS [Child tags] >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Loop through each Child tag >> %temp%\temp.htm
ECHO var b = a[i].childNodes; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Loop instruction >> %temp%\temp.htm
ECHO for (j=0;j^<b.length;j++) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Specify a target element within the Child tag >> %temp%\temp.htm
ECHO // Specified element must exist in ALL the Child tags >> %temp%\temp.htm
ECHO element3 = b[j].attributes.getNamedItem("supplier").nodeValue; // create array >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Conditional Filter [Supplier] >> %temp%\temp.htm
ECHO // Pass only the Child tag that contains the desired supplier >> %temp%\temp.htm
ECHO if ( element3=="%supplier%" ) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Test value of chosen element within this IF condition >> %temp%\temp.htm
ECHO // alert( "Supplier = " + element3 ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Write elements in selected Child tag to file >> %temp%\temp.htm
ECHO fh.WriteLine( '@echo off' ); >> %temp%\temp.htm
ECHO fh.WriteLine( ':: Media tag #' + [i] + ', Child tag #' + [j] ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET rtmpdump=%rtmpdump%' ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET protocol=' + b[j].attributes.getNamedItem("protocol").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET server=' + b[j].attributes.getNamedItem("server").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET application=' + b[j].attributes.getNamedItem("application").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET identifier=' + b[j].attributes.getNamedItem("identifier").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO var str1=b[j].attributes.getNamedItem("authString").nodeValue; >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET authString=' + str1.replace(/^&/g,"^&") ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm

:: NOTES: 1. The symbol & must be carat-escaped using REPLACE (character to replace, replacement character).
:: 2. A carat (symbol ^) must preceed & in the first argument; g [global] means replace ALL instances.
:: 3. In second argument no escaping is needed: use of double quotes forces the symbols to be read literally

ECHO fh.WriteLine( ':: *** Command Line : TV : AKAMAI : %bitrate% kbps ***' ); >> %temp%\temp.htm
ECHO fh.WriteLine( '"%%rtmpdump%%" --live --verbose ' + >> %temp%\temp.htm
ECHO '-r "%%protocol%%://%%server%%:%port%/%%application%%?%%authString%%" ' + >> %temp%\temp.htm
ECHO '-a "%%application%%?%%authString%%" -y "%%identifier%%?%%authString%%" ' + >> %temp%\temp.htm
ECHO '-f "WIN 11,1,102,63" -W "%swf%" ' + >> %temp%\temp.htm
ECHO '-o "Live %ID% ['+element2+'kbps] ['+element3+'] %currDate% %currTime%.flv" '); >> %temp%\temp.htm

:: NOTES: 1. The symbol % must be doubled in a Batch file (in contrast to a Command Line).

ECHO. >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO } } // Close Level 2 >> %temp%\temp.htm
ECHO } } } // Close Level 1 >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^</SCRIPT^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^</head^> >> %temp%\temp.htm
ECHO ^<body onload="loadXML();window.close()"^> ^</body^> >> %temp%\temp.htm
ECHO ^</html^> >> %temp%\temp.htm


:: *** Run HTM file in Internet Explorer ***
"C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE" %temp%\temp.htm

:: *** Run MediaSelector.bat ***
CALL "C:\MediaSelector.bat"

pause

Ed999
12-26-2012, 06:22 AM
The following code is the contents of a .bat batch file for downloading a BBC tv live stream from a LIMELIGHT server.

Copy-and-paste the code into a file called (for example) BBCtv_Live_Limelight.bat


@echo off

:: *** MediaSelector ID ***
SET ID=bbc_one_london
:: SET ID=bbc_two_england
:: SET ID=bbc_three
:: SET ID=bbc_four

:: *** Stream Bitrate ***
:: SET bitrate=56
:: SET bitrate=176
:: SET bitrate=396
:: SET bitrate=480
SET bitrate=796
:: SET bitrate=1500

:: *** Supplier ***
SET supplier=limelight


:: *** Port ***
SET port=1935

:: *** RTMPDump v2.4 (RTMPDump v2.1d doesn't work) ***
SET rtmpdump=C:\\Program Files (x86)\\rtmpdump\\rtmpdump.exe

:: *** SWF File ***
SET swf=http://www.bbc.co.uk/emp/releases/iplayer/revisions/617463_618125_4/617463_618125_4_emp.swf

:: *** File Name ***
SET currDate=%date:/=-%
SET currTime=%time::=-%

:: *** Safety Tests ***
IF EXIST "%temp%\*.bat" DEL "%temp%\*.bat"
IF EXIST "%temp%\*.htm" DEL "%temp%\*.htm"


:: *** Create a HTML file : LIMELIGHT stream ***

ECHO ^<html^> >> %temp%\temp.htm
ECHO ^<head^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^<title^>Parse BBC iPlayer XML File - Javascript Method^</title^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^<!-- Downloading from a BBC iPlayer page --^> >> %temp%\temp.htm
ECHO ^<!-- This parses the elements in a MediaSelector xml page --^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^<SCRIPT^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Target XML file's URL address [MediaSelector URL] >> %temp%\temp.htm
ECHO var url = "http://www.bbc.co.uk/mediaselector/4/mtis/stream/%ID%"; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO var xmlDoc; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO window.open('','_self'); // This prevents the browser window prompting before closing >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO function loadXML() >> %temp%\temp.htm
ECHO { >> %temp%\temp.htm
ECHO xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); >> %temp%\temp.htm
ECHO xmlDoc.async = false; >> %temp%\temp.htm
ECHO xmlDoc.onreadystatechange = readXML; >> %temp%\temp.htm
ECHO xmlDoc.load(url); >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO function readXML() >> %temp%\temp.htm
ECHO { >> %temp%\temp.htm
ECHO if ( xmlDoc.readyState==4 ) { >> %temp%\temp.htm
ECHO // This function is called on statechange >> %temp%\temp.htm
ECHO // When the state reaches 4, this function reads the xml document >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Create a Text File >> %temp%\temp.htm
ECHO var fso = new ActiveXObject("Scripting.FileSystemObject"); >> %temp%\temp.htm
ECHO var fh = fso.CreateTextFile("C:\\MediaSelector.bat",true); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // LEVEL 1 TAGS [Primary tags] >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Specify the Level 1 tag to loop through >> %temp%\temp.htm
ECHO var a = xmlDoc.getElementsByTagName("media"); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Loop instruction >> %temp%\temp.htm
ECHO for (i=0;i^<a.length;i++) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Specify a target element within the Level 1 tag >> %temp%\temp.htm
ECHO // Specified element must exist in ALL the Level 1 tags >> %temp%\temp.htm
ECHO element1 = a[i].attributes.getNamedItem("kind").nodeValue; // create array [Line 50] >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Conditional Filter >> %temp%\temp.htm
ECHO // Pass only those tags that contain video data >> %temp%\temp.htm
ECHO if ( element1=="video" ) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Test value of chosen element >> %temp%\temp.htm
ECHO // alert( "Kind = " + element1 ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Conditional Filter >> %temp%\temp.htm
ECHO // Pass only the tag that contains the desired bitrate >> %temp%\temp.htm
ECHO element2 = a[i].attributes.getNamedItem("bitrate").nodeValue; // create array >> %temp%\temp.htm
ECHO if ( element2==%bitrate% ) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // NOTE: The element "bitrate" can't be used as the primary filter at line 50, >> %temp%\temp.htm
ECHO // because it's an element that does NOT exist in all primary level tags >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Test value of chosen element >> %temp%\temp.htm
ECHO // alert( "Bitrate = " + element2 ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm



/Continued below...

Ed999
12-26-2012, 06:24 AM
/ Continued...




ECHO // LEVEL 2 TAGS [Child tags] >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Loop through each Child tag >> %temp%\temp.htm
ECHO var b = a[i].childNodes; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Loop instruction >> %temp%\temp.htm
ECHO for (j=0;j^<b.length;j++) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Specify a target element within the Child tag >> %temp%\temp.htm
ECHO // Specified element must exist in ALL the Child tags >> %temp%\temp.htm
ECHO element3 = b[j].attributes.getNamedItem("supplier").nodeValue; >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Conditional Filter >> %temp%\temp.htm
ECHO // Pass only the Child tag that contains the desired supplier >> %temp%\temp.htm
ECHO if ( element3=="%supplier%" ) { >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Test value of element >> %temp%\temp.htm
ECHO // alert( "Supplier = " + element3 ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO // Write elements in selected Child tag to file >> %temp%\temp.htm
ECHO fh.WriteLine( '@echo off' ); >> %temp%\temp.htm
ECHO fh.WriteLine( ':: Media tag #' + [i] + ', Child tag #' + [j] ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET rtmpdump=%rtmpdump%' ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET protocol=' + b[j].attributes.getNamedItem("protocol").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET server=' + b[j].attributes.getNamedItem("server").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET application=' + b[j].attributes.getNamedItem("application").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET identifier=' + b[j].attributes.getNamedItem("identifier").nodeValue ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO var str1 = b[j].attributes.getNamedItem("authString").nodeValue; >> %temp%\temp.htm
ECHO fh.WriteLine( 'SET authString=' + str1.replace(/^&/g,"^&") ); >> %temp%\temp.htm
ECHO fh.WriteLine( '' ); >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm

:: NOTES: 1. The symbol & must be carat-escaped using REPLACE (character to replace, replacement character).
:: 2. A carat (symbol ^) must preceed & in the first argument; g [global] means replace ALL instances.
:: 3. In second argument no escaping is needed: use of double quotes forces the symbols to be read literally

ECHO fh.WriteLine( ':: *** Command Line : TV : LIMELIGHT : %bitrate% kbps ***' ); >> %temp%\temp.htm
ECHO fh.WriteLine( '"%%rtmpdump%%" --live --protocol "%%protocol%%" --host "%%server%%" ' + >> %temp%\temp.htm
ECHO '--port %port% -a "%%application%%?%%authString%%&%%identifier%%" ' + >> %temp%\temp.htm
ECHO '-y "%%identifier%%" ' + >> %temp%\temp.htm
ECHO '-o "Live %ID% ['+element2+'kbps] ['+element3+'] %currDate% %currTime%.flv" '); >> %temp%\temp.htm

:: NOTES: 1. The symbol % must be doubled in a Batch file (in contrast to a Command Line),
:: to prevent it being expanded immediately as if it was an environment variable.

ECHO. >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO } } // Close Child function >> %temp%\temp.htm
ECHO } } } // Close Primary function >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO } >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^</SCRIPT^> >> %temp%\temp.htm
ECHO. >> %temp%\temp.htm
ECHO ^</head^> >> %temp%\temp.htm
ECHO ^<body onload="loadXML();window.close()"^> ^</body^> >> %temp%\temp.htm
ECHO ^</html^> >> %temp%\temp.htm


:: *** Run HTM file in Internet Explorer ***
"C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE" %temp%\temp.htm

:: *** Run MediaSelector.bat ***
CALL "C:\MediaSelector.bat"

svnpenn
12-26-2012, 03:57 PM
Here is a revised script for downloading the Akamai live tv streams from the BBC. This is a modified version of the batch file script posted above in this thread, modified to take account of recent changes on the BBC website.
Copy-and-paste the code into a plain text file called (for example) BBCtv_Live_Akamai.bat

Appreciate the effort, but most people are not going to want to copy all that crap. Just put it in a link like this.

github.com/svnpenn/a/blob/ca92/scripts/BBCtv_Live_Limelight.bat
github.com/svnpenn/a/blob/ca92/scripts/BBCtv_Live_Akamai.bat

Ed999
12-27-2012, 06:01 AM
Thank you, but if I had wanted to do that I could have done it myself. :)

My purpose in posting commented code is to explain - to people who might want to use the code - how it works, so that they can adapt it to other situations.

I anticipate that few users, if any, will want to download BBC live streams. Their on-demand streams are much more user-friendly, for example.

This code is just an illustration of how easy it can be to use a batch script to interrogate an xml file and build a download link from it. Accordingly, this code is for posting, and explaining; not necessarily for using.

chap
12-27-2012, 07:49 AM
possible to use such a file on CBS,Hulu...?

chanc
01-31-2013, 05:48 AM
This is a method for downloading an iPlayer TV stream using its MediaSelector url.

How amazing !!

I am outside the UK, and I got the iplayer code with a vpn.
After the Mediaselector has been established, I just shut down the vpn and found the download still works !

Now I am enjoying a much better download speed, thanks to the code above!!

chemi
02-14-2013, 11:40 AM
Really? Does it work from outside UK?
I am trying it from Spain and it doesn't work...

I get the Media Selector because I am using tunlr.net trick (without it, it fails at the beginning), but then rtmp:// fails. Here is the log. Any help or comment?

RTMPDump v2.4
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
DEBUG: Parsing...
DEBUG: Parsed protocol: 0
DEBUG: Parsed host : cp96472.live.edgefcs.net
DEBUG: Parsed app : live?auth=daEbBbpbCaQdadpdoaMdndBaGdEa0dva4dW-brhr._-bWG
-IoqEInyqFEsHrwK&aifp=v001&slist=bbc1_inlet_480@s24324;bbc1_inlet_800@s24324; bbc
1_inlet_176@s24324;bbc1_inlet_56@s24324;bbc1_inlet _1500@s24324;bbc1_inlet_396@s2
4324
DEBUG: Protocol : RTMP
DEBUG: Hostname : cp96472.live.edgefcs.net
DEBUG: Port : 1935
DEBUG: Playpath : bbc1_inlet_800@s24324?auth=daEbBbpbCaQdadpdoaMdndB aGdEa0dva4dW
-brhr._-bWG-IoqEInyqFEsHrwK&aifp=v001&slist=bbc1_inlet_480@s24324;bbc1_inlet_800
@s24324;bbc1_inlet_176@s24324;bbc1_inlet_56@s24324 ;bbc1_inlet_1500@s24324;bbc1_i
nlet_396@s24324
DEBUG: tcUrl : rtmp://cp96472.live.edgefcs.net:1935/live?auth=daEbBbpbCaQdadp
doaMdndBaGdEa0dva4dW-brhr._-bWG-IoqEInyqFEsHrwK&aifp=v001&slist=bbc1_inlet_480@s
24324;bbc1_inlet_800@s24324;bbc1_inlet_176@s24324; bbc1_inlet_56@s24324;bbc1_inle
t_1500@s24324;bbc1_inlet_396@s24324
DEBUG: swfUrl : http://www.bbc.co.uk/emp/releases/iplayer/revisions/617463_618
125_4/617463_618125_4_emp.swf
DEBUG: app : live?auth=daEbBbpbCaQdadpdoaMdndBaGdEa0dva4dW-brhr._-bWG-IoqEI
nyqFEsHrwK&aifp=v001&slist=bbc1_inlet_480@s24324;bbc1_inlet_800@s24324; bbc1_inle
t_176@s24324;bbc1_inlet_56@s24324;bbc1_inlet_1500@ s24324;bbc1_inlet_396@s24324
DEBUG: flashVer : WIN 11,1,102,63
DEBUG: live : yes
DEBUG: timeout : 30 sec
DEBUG: SWFSHA256:
DEBUG: b6 74 7f 89 f9 ec 6a 60 c1 a4 b5 8b b1 18 b0 fa
DEBUG: 65 18 86 24 c2 8a 1a a3 2f 72 0f 0b 80 59 dd 7f
DEBUG: SWFSize : 595316
DEBUG: Setting buffer time to: 36000000ms
Connecting ...
DEBUG: RTMP_Connect1, ... connected, handshaking
DEBUG: HandShake: Client type: 03
DEBUG: HandShake: Client digest offset: 53
DEBUG: HandShake: Initial client digest:
DEBUG: fc 05 f6 56 84 91 0b 14 1d 8a 1c 21 db a3 1d c1
DEBUG: a5 8d ec a6 9d bb d9 e1 d3 f4 f6 bc ab da 95 f4
DEBUG: HandShake: Type Answer : 03
DEBUG: HandShake: Server Uptime : 407558033
DEBUG: HandShake: FMS Version : 4.5.2.1
DEBUG: HandShake: Calculated digest key from secure key and server digest:
DEBUG: 04 96 57 47 80 65 3a e9 02 5f 6e 2e c0 2c 60 b9
DEBUG: 86 58 60 22 9e c0 5d d6 24 54 7b d7 84 62 95 97
DEBUG: HandShake: Client signature calculated:
DEBUG: 63 e0 9c cb 05 0b c4 a9 ee 10 e7 a4 32 8f ee 1f
DEBUG: bf fe 1e 59 9a ee b2 28 f5 c2 01 cc 38 1b c1 f0
DEBUG: HandShake: Server sent signature:
DEBUG: 99 93 7a b9 3d 5a 9b 30 09 d8 fa 77 0b 89 2e 0f
DEBUG: 1c 78 c7 97 ce a1 69 ef c8 46 32 32 55 80 d2 8a
DEBUG: HandShake: Digest key:
DEBUG: 4b e6 40 f4 27 2a 4f 80 d3 b2 e3 aa 48 11 d5 fc
DEBUG: 8b ab 81 22 3a b3 41 1c 63 9b d9 35 85 06 7b d0
DEBUG: HandShake: Signature calculated:
DEBUG: 99 93 7a b9 3d 5a 9b 30 09 d8 fa 77 0b 89 2e 0f
DEBUG: 1c 78 c7 97 ce a1 69 ef c8 46 32 32 55 80 d2 8a
DEBUG: HandShake: Genuine Adobe Flash Media Server
DEBUG: HandShake: Handshaking finished....
DEBUG: RTMP_Connect1, handshaked
DEBUG: Invoking connect
INFO: Connected...
DEBUG: RTMP_ClientPacket, received: invoke 134 bytes
DEBUG: (object begin)
DEBUG: Property: NULL
DEBUG: (object begin)
DEBUG: Property: <Name: level, STRING: error>
DEBUG: Property: <Name: code, STRING: NetConnection.Connect.Rejected>
DEBUG: Property: <Name: description, STRING: [ AccessManager.Reject ]
: Access denied!>
DEBUG: (object end)
DEBUG: (object end)
DEBUG: HandleInvoke, server invoking <_error>
ERROR: rtmp server sent error
DEBUG: RTMP_ClientPacket, received: invoke 18 bytes
DEBUG: (object begin)
DEBUG: Property: NULL
DEBUG: (object end)
DEBUG: HandleInvoke, server invoking <close>
ERROR: rtmp server requested close
DEBUG: Closing connection.

Press any key to continue . . .

Thanks in advance,

Chemi.

Ed999
03-06-2013, 06:46 AM
Sorry, I live in England, so I have no means of testing solutions for using this code from outside the UK.

This code should produce the same command line for downloading the target tv show, whether it is run from inside the UK or elsewhere.

The problem will be the rtmp connection, not the command line. The BBC tests the connection, to learn whether it is being originated from an ip address in the UK. They reject a connection if it is from an ip address outside the UK.

There are various ways for you to overcome this. I can only speak in general terms, because I can't test these solutions.

Geo-spoofing is a trick which allows you, situated in a foreign country, to appear to be originating a connection from within the UK. Look up geo-spoofing or ip-spoofing on Google for details.

There is a software program called Tor which allows you to connect your computer to a node inside the UK, which acts as a relay, so that your computer appears to be co-located with the node (i.e. if the node is in the UK, then you too appear to be in the UK).

https://www.torproject.org/download/download.html.en

Also look at http://sourceforge.net/projects/tork/files/latest/download?source=files

Also search 'Anonymous web proxy'. This will lead you to e.g. http://hidemyass.com/ or http://apcyberax.co.uk/iwfchecker/ or http://server14.kproxy.com/

There are in fact many software solutions, but the problem they solve is that your connection request is originating from outside the UK. There is nothing wrong with the command line built by my code - it will work, provided you can mask the fact that you are running it from a computer that is outside the UK.

drbmn
08-25-2013, 04:37 PM
This is a method for downloading an iPlayer TV stream using its MediaSelector url.

If you alter the sections highlighted in blue, you can download instead a stream running at a different bitrate. Details of the available bitrates for each tv show are given in that show's MediaSelector page. Each tv show is offered by the BBC in half a dozen different bitrates, from 184 kbps to 1500 kbps.


Hi,
There are no parts higlighted in blue, only the mediaslector in red.
What are the parts that should have been highlited in blue???