View Single Post
  #12  
Old 12-26-2012, 06:08 AM
Ed999 Ed999 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 115
Ed999 is on a distinguished road
Default

Download from BBC iPlayer - TV Show - Javascript method -- Continued


/Continued...

Code:
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
Reply With Quote