// ==SiteScript==
// @siteName 日テレいつでもどこでもキャンペーン
// @siteUrl http://cu.ntv.co.jp/
// @author mayan
// @authorUrl
// @scriptUrl
// @description RTMP,HLSのデータを取得
// @date 2014/01/17
// @version 0.1
// ==/SiteScript==
function CravingSiteScript() {
this._initialize();
}
CravingSiteScript.prototype = {
_xhr: null,
_initialize: function() {},
_getXmlHttpRequest: function() {
if ( this._xhr != null ) {
return this._xhr;
}
var xhr = null;
var these = [
function() { return new XMLHttpRequest(); }
, function() { return new ActiveXObject( "Msxml2.XMLHTTP" ); }
, function() { return new ActiveXObject( "Microsoft.XMLHTTP" ); }
, function() { return new ActiveXObject( "Msxml2.XMLHTTP.4.0" ); }
];
for ( var i = 0, length = these.length; i < length; i++ ) {
var func = these[ i ];
try {
xhr = func();
break;
}
catch( e ) {}
}
this._xhr = xhr;
return this._xhr;
},
_load: function( url, data, method ) {
var req = this._getXmlHttpRequest();
var mtd = ( method == null ) ? "GET" : "POST";
req.open( mtd, url, false );
if ( mtd == "POST" ) {
req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
}
req.send( data );
return req.responseText;
},
getResponseText: function( url, data, method ) {
return this._load( url, data, method );
},
getResponseJSON: function( url, data, method ) {
var text = this._load( url, data, method );
return eval( "("+text+")" );
},
/// Math
random: function( limit ) {
return Math.floor( Math.random() * limit );
},
/// String
decodeHtml: function( str ) {
return str.replace( /&(quot|#0*34);/ig, "\"" )
.replace( /&(amp|#0*38);/ig, "&" )
.replace( /&(apos|#0*39);/ig, "'" )
.replace( /&(lt|#0*60);/ig, "<" )
.replace( /&(gt|#0*62);/ig, ">" )
.replace( /&(nbsp|#0*160);/ig, " " )
.replace( /&(frasl|#8260);/ig, "/" );
}
}
var _NTV = {};
_NTV.Err = [];
function isSiteUrl( url ) {
if ( url.match( /http:\/\/cu\.ntv\.co\.jp\/[^\/?]+/ ) ) return true;
return false;
}
function getVideoDetail( url ) {
if ( url.match( /http:\/\/cu\.ntv\.co\.jp\/([^\/?]+)/ ) ) {
var article = RegExp.$1;
} else {
//return null;
}
var craving = new CravingSiteScript();
try {
var text = craving.getResponseText( url );
} catch( e ) {
_NTV.Err.push( e.description );
text = "";
}
if ( !text ) {
_NTV.Err.push( "ページの取得に失敗。\nurl=" + url );
return null;
}
if ( text.match( /]*?name\s*=\s*("|')?@videoPlayer\2[^>]*)>/im )
&& RegExp.$1.match( /\s+value\s*=\s*("|')?(\d+)\1/i ) ) {
var contentId = RegExp.$2;
}
if ( !contentId ) {
_NTV.Err.push( "contentIdの取得に失敗" );
return null;
}
if ( text.match( /]*?name\s*=\s*("|')?playerID\2[^>]*)>/im )
&& RegExp.$1.match( /\s+value\s*=\s*("|')?(\d+)\1/i ) ) {
var experienceId = RegExp.$2;
}
if ( !experienceId ) experienceId = "685172045002";
if ( text.match( /]*?name\s*=\s*("|')?playerKey\2[^>]*)>/im )
&& RegExp.$1.match( /\s+value\s*=\s*("|')?(\d+)\1/i ) ) {
var playerKey = RegExp.$2;
}
if ( !playerKey ) playerKey = "AQ~~,AAAAnk93epo~,EIwFxo9ffYxveMRMRZ4XDfJ7ig_WTjBb";
var title = "";
if ( text.match( /]*?property\s*=\s*("|')?og:title\2[^>]*)>/im )
&& RegExp.$1.match( /\s+content\s*=\s*("|')(.*?)\1/i ) ) {
var title = craving.decodeHtml( RegExp.$2 ).replace( /\s*\|[^|]*$/, "" );
}
if ( !title &&
text.match( /
]*)?>\s*(.*?)\s*<\/title\s*>/im ) ) {
title = craving.decodeHtml( RegExp.$2 ).replace( /\s*\|[^|]*$/, "" );
}
//title = title.replace(/[\\\/:*?"<>|]/g, "_");
var description = "";
if ( ( text.match( /]*?name\s*=\s*("|')?description\2[^>]*)>/im ) ||
text.match( /]*?property\s*=\s*("|')?og:description\2[^>]*)>/im ) )
&& RegExp.$1.match( /\s+content\s*=\s*("|')(.*?)\1/i ) ) {
description = craving.decodeHtml( RegExp.$2 );
}
var objBinary = new clsGetBinary();
if ( !objBinary.isOK ) {
_NTV.Err.push( "objBinaryの作成に失敗" );
return null;
}
getSendData( objBinary, url, experienceId, playerKey, contentId );
var amfurl = "http://c.brightcove.co.jp/services/messagebroker/amf?playerKey=" + playerKey;
try {
var objHttp = craving._getXmlHttpRequest();
objHttp.Open( "POST", amfurl, false );
objHttp.setRequestHeader( "Content-Type", "application/x-amf" );
objHttp.Send( objBinary.senddata );
var objByte = new clsGetByteCode( objHttp.responseBody );
} catch( e ) {
_NTV.Err.push( e.description );
}
if ( !objByte || !objByte.isOK ) {
_NTV.Err.push( "objByteの作成に失敗" );
return null;
}
var objAMF = new clsAMF();
try {
var objBody = objAMF.decodeAMF( objByte.toByteArray() ).messages[ 0 ].body;
} catch( e ) {
objBody = null;
}
if ( !objBody || typeof( objBody ) != "object" ) {
_NTV.Err.push( "AMFデータ解析に失敗" );
return null;
}
if ( !objBody.programmedContent || typeof objBody.programmedContent != "object" ||
!objBody.programmedContent.videoPlayer || typeof objBody.programmedContent.videoPlayer != "object" ||
!objBody.programmedContent.videoPlayer.mediaDTO || typeof objBody.programmedContent.videoPlayer.mediaDTO != "object" ) {
_NTV.Err.push( "AMFデータ構造が想定外" );
return null;
}
var objDto = objBody.programmedContent.videoPlayer.mediaDTO;
//for CE
//略
//for WSH
var objRtn = {};
objRtn.url = url;
objRtn.article = article;
objRtn.title = title;
objRtn.description = description;
objRtn.contentId = contentId;
objRtn.experienceId = experienceId;
objRtn.objDto = objDto;
objRtn.publisherId = objBody.publisherId;
return objRtn;
}
function getSendData( objBny, strUrl, strExperienceId, strPlayerKey, strContentId ){
var arrHeader = [
0x00, 0x03, 0x00, 0x00, 0x00, 0x01
];
var arrBodyHe = [
0x00, 0x46,
0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x72, 0x69, 0x67,
0x68, 0x74, 0x63, 0x6f, 0x76, 0x65, 0x2e, 0x65,
0x78, 0x70, 0x65, 0x72, 0x69, 0x65, 0x6e, 0x63,
0x65, 0x2e, 0x45, 0x78, 0x70, 0x65, 0x72, 0x69,
0x65, 0x6e, 0x63, 0x65, 0x52, 0x75, 0x6e, 0x74,
0x69, 0x6d, 0x65, 0x46, 0x61, 0x63, 0x61, 0x64,
0x65, 0x2e, 0x67, 0x65, 0x74, 0x44, 0x61, 0x74,
0x61, 0x46, 0x6f, 0x72, 0x45, 0x78, 0x70, 0x65,
0x72, 0x69, 0x65, 0x6e, 0x63, 0x65,
0x00, 0x02,
0x2f, 0x31
];
//+ content length
var arrBodyCo1 = [
0x0a, 0x00, 0x00, 0x00, 0x02,
0x02, 0x00, 0x28,
0x64, 0x65, 0x36, 0x37, 0x63, 0x64, 0x35, 0x33,
0x64, 0x33, 0x36, 0x64, 0x38, 0x33, 0x38, 0x35,
0x35, 0x30, 0x33, 0x36, 0x62, 0x62, 0x36, 0x38,
0x64, 0x35, 0x34, 0x66, 0x38, 0x62, 0x65, 0x65,
0x32, 0x34, 0x64, 0x32, 0x39, 0x38, 0x30, 0x32,
0x11,
0x0a, 0x63, 0x63, 0x63, 0x6f, 0x6d, 0x2e, 0x62,
0x72, 0x69, 0x67, 0x68, 0x74, 0x63, 0x6f, 0x76,
0x65, 0x2e, 0x65, 0x78, 0x70, 0x65, 0x72, 0x69,
0x65, 0x6e, 0x63, 0x65, 0x2e, 0x56, 0x69, 0x65,
0x77, 0x65, 0x72, 0x45, 0x78, 0x70, 0x65, 0x72,
0x69, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74,
0x21,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4f,
0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x73,
0x11,
0x54, 0x54, 0x4c, 0x54, 0x6f, 0x6b, 0x65, 0x6e,
0x19,
0x64, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79,
0x54, 0x79, 0x70, 0x65,
0x13,
0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4b, 0x65,
0x79,
0x07,
0x55, 0x52, 0x4c,
0x19,
0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x65, 0x6e,
0x63, 0x65, 0x49, 0x64,
0x09, 0x03, 0x01,
0x0a, 0x81, 0x03,
0x53, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x72, 0x69,
0x67, 0x68, 0x74, 0x63, 0x6f, 0x76, 0x65, 0x2e,
0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x65, 0x6e,
0x63, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69,
0x64, 0x65,
0x15,
0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x64,
0x49, 0x64,
0x13,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49,
0x64,
0x0d,
0x74, 0x61, 0x72, 0x67, 0x65, 0x74,
0x1b,
0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x64,
0x52, 0x65, 0x66, 0x49, 0x64,
0x15,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x49,
0x64, 0x73,
0x19,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52,
0x65, 0x66, 0x49, 0x64,
0x17,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54,
0x79, 0x70, 0x65,
0x1b,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52,
0x65, 0x66, 0x49, 0x64, 0x73,
0x05,
0x7f, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00 //featuredId,Number,NaN
];
//+ contentId,Number
var arrBodyCo2 = [
0x06, 0x17, //target,String,videoPlayer
0x76, 0x69, 0x64, 0x65, 0x6f, 0x50, 0x6c, 0x61,
0x79, 0x65, 0x72,
0x01, //featuredRefId,Null
0x01, //contentIds,Null
0x01, //contentRefId,Null
0x04, 0x00, //contentType,Integer,0
0x01, //contentRefIds,Null
0x06, 0x01, //TTLToken,String,""
0x05, //deliveryType,Number,NaN
0x7f, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00
];
//+ playerKey,String
//+ URL,String
//+ experienceId,Number
var arrUrl = makeStringArr( strUrl );
var arrPlayerKey = makeStringArr( strPlayerKey );
var contentLength = 364 + arrUrl.length + arrPlayerKey.length;
var objStream = new ActiveXObject( "ADODB.Stream" );
objStream.type = 1;
objStream.Open();
objStream.Position = 0;
for ( var i = 0; i < arrHeader.length; i++ )
objStream.Write( objBny.fromByteCode( arrHeader[i] ) );
for ( var i = 0; i < arrBodyHe.length; i++ )
objStream.Write( objBny.fromByteCode( arrBodyHe[i] ) );
var arrTmp = LenToByteCode( contentLength, 4 );
for ( var i = 0; i < arrTmp.length; i++ )
objStream.Write( objBny.fromByteCode( arrTmp[i] ) );
for ( var i = 0; i < arrBodyCo1.length; i++ )
objStream.Write( objBny.fromByteCode( arrBodyCo1[i] ) );
arrTmp = toDoubleByte( strContentId );
objStream.Write( objBny.fromByteCode( 0x05 ) );
for ( var i = 0; i < arrTmp.length; i++ )
objStream.Write( objBny.fromByteCode( arrTmp[i] ) );
for ( var i = 0; i < arrBodyCo2.length; i++ )
objStream.Write( objBny.fromByteCode( arrBodyCo2[i] ) );
for ( var i = 0; i < arrPlayerKey.length; i++ )
objStream.Write( objBny.fromByteCode( arrPlayerKey[i] ) );
for ( var i = 0; i < arrUrl.length; i++ )
objStream.Write( objBny.fromByteCode( arrUrl[i] ) );
arrTmp = toDoubleByte( strExperienceId );
objStream.Write( objBny.fromByteCode( 0x05 ) );
for ( var i = 0; i < arrTmp.length; i++ )
objStream.Write( objBny.fromByteCode( arrTmp[i] ) );
objStream.Position = 0;
objBny.senddata = objStream.Read();
objStream.Close();
}
function LenToByteCode( intLen, intByteLen ){
var arr = new Array();
var tmp = intLen;
for ( var i = 0; i < intByteLen; i++ ){
arr.push( tmp & 255 );
tmp = tmp >> 8 ;
}
return arr.reverse();
}
function LenToByteCode( intLen, intByteLen ){
var arr = new Array();
var tmp = intLen;
for ( var i = 0; i < intByteLen; i++ ){
arr.push( tmp & 255 );
tmp = tmp >> 8 ;
}
return arr.reverse();
}
function makeStringArr( str ){
//unsupport, str.len>2^13
var arr = new Array();
var len = str.length;
if ( len < 0 || 8192 < len ) return arr;
arr.push( 0x06 );
if ( len < 64 ){
arr.push( len * 2 + 1 );
} else {
arr.push( ( len >>> 6 ) + 128 );
arr.push( ( ( len & 63 ) << 1 ) + 1 );
}
for ( var i = 0; i < len; i++ ){
arr.push( str.charCodeAt( i ) );
}
return arr;
}
function toDoubleByte( strNum ){
//integer only
var intNum = parseInt( strNum );
if ( intNum == 0 ){
var strBi = padozero( "", 64 );
} else {
var sig = ( intNum > 0 ) ? "0" : "1";
intNum = Math.abs( intNum );
var man = intNum.toString(2);
var exp = zeropad( ( man.length - 1 + 1023 ).toString(2), 11 );
man = padzero( man.substring(1), 52 );
strBi = sig + exp + man;
}
var arr = new Array(7);
for ( var i = 0; i < 8; i++ ){
arr[i] = parseInt( strBi.substr( i * 8, 8 ), 2 );
}
return arr;
}
function padzero( strNum, keta ){
for ( var i = strNum.length; i < keta; i++ ) strNum += "0";
return strNum;
}
function zeropad( strNum, keta ){
for ( var i = strNum.length; i < keta; i++ ) strNum = "0" + strNum;
return strNum;
}
function clsGetBinary(){
this.isOK = false;
this._objStream = null;
this._binaryNone;
this._initialize = function (){
try {
this._objStream = new ActiveXObject( "ADODB.Stream" );
this.isOK = true;
} catch(e) {
this.isOk = false;
return false;
}
this._objStream.Open();
this._objStream.type = 1;
this._binaryNone = this._objStream.Read( 0 );
this._objStream.Close();
return true;
}
this._initialize();
this.fromByteCode = function ( intByteCode ){
if ( !this.isOK ) return this._binaryNone;
if ( intByteCode < 0 || 255 < intByteCode ) return this._binaryNone;
this._objStream.Open();
this._objStream.type = 2;
this._objStream.Charset = "Unicode";
this._objStream.WriteText( String.fromCharCode( intByteCode ) );
this._objStream.Position = 0;
this._objStream.type = 1;
this._objStream.Position = 2;
var binary = this._objStream.Read( 1 );
this._objStream.Close();
return binary;
}
}
function clsGetByteCode( binarydata ){
this._binary = binarydata;
this.isOK = false;
this.size = 0;
this._objSC = null;
this._initialize= function (){
try {
this._objSC = new ActiveXObject( "ScriptControl" );
this.isOK = true;
} catch(e) {
this.isOK = falae;
this.size = 0;
return false;
}
this._objSC.Language = "VBScript";
this._objSC.AddCode( "Function VB_getSize( bin ) : VB_getSize = LenB( bin ) : End Function" );
this._objSC.AddCode( "Function VB_getByte( bin, pos ) : VB_getByte = AscB( MidB( bin, pos, 1 ) ) : End Function" );
this.size = this._objSC.Run( "VB_getSize", this._binary );
return true;
};
this._initialize();
this.byteCodeAt = function ( index ){
//arg:index0-, ret: Number
if ( !this.isOK ) return 0;
if ( index < 0 || this.size <= index ) return 0;
return this._objSC.Run( "VB_getByte", this._binary, index + 1 );
};
this.toByteArray = function (){
var arr = [];
for ( var i = 0; i < this.size; i++ ) arr.push( this.byteCodeAt(i) );
return arr;
};
}
function clsAMF() {
var window = {};
this.decodeAMF = decodeAMF;
function utf8to16( arrByt ) {
var arrU8 = arrByt;
var arrU16 = [];
var len = arrU8.length;
var i = 0;
while ( i < len ) {
var c0 = arrU8[i++];
var s = (c0 < 128)? 0:
(c0 < 192)? -1:
(c0 < 224)? 1:
(c0 < 240)? 2:
(c0 < 248)? 3:
(c0 < 252)? 4:
(c0 < 254)? 5:-1;
if ( s < 0 ) {//invalid.
continue; //skip
}
if ( s == 0 ) {
arrU16.push( c0 );
continue;
}
if ( s > len - i ) {//invalid(unfinished)
break; //cutoff
}
var u16 = c0 & ( 31 >>> (s-1) );
for ( var j = 0; j < s; j++ ) {
u16 = ( u16 << 6 ) | ( arrU8[i++] & 63 );
}
if ( u16 <= 0xFFFF ) {
arrU16.push( u16 );
} else if ( u16 <= 0x10FFFF ) {//surrogate
arrU16.push( (u16 >>> 10) - 64 + 55296 );
arrU16.push( (u16 & 1023) + 56320 );
} else {
//invalid, skip
}
}
var arr = [];
for ( var i = 0; i < arrU16.length; i++ ) {
arr.push( String.fromCharCode( arrU16[ i ] ) );
}
return arr.join( "" );
}
//以下、James Ward氏の amf.js (Git,June09,2012)を使っています。
//readStringの関数を書き換えてあります(utf8to16関数を使っています)。
//Google Closure Compilerを用いて最適化してあります。
/*
amf.js - A Pure JavaScript AMF Implementation
http://www.jamesward.com/2010/07/07/amf-js-a-pure-javascript-amf-implementation/
Google Closure Compiler
https://developers.google.com/closure/compiler/
*/
/* amf.jsここから */
/*
amf.js - An AMF library in JavaScript
Copyright (c) 2010, James Ward - www.jamesward.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY JAMES WARD ''AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JAMES WARD OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of James Ward.
*/
function decodeAMF(a){a=new a3d.ByteArray(a,a3d.Endian.BIG);var b=a.readUnsignedShort();a.objectEncoding=a3d.ObjectEncoding.AMF0;for(var c=new a3d.AMFPacket,d=a.readUnsignedShort(),e=0;e=e&&32>7)-127,d=(d&127)<<16|e<<8|b;return 0==d&&-127==a?0:(1-(c>>7<<1))*(1+this.TWOeN23*d)*this.pow(2,a)},readFloat64BE:function(){var a=this.readByte(),b=this.readByte(),c=this.readByte(),d=this.readByte(),e=this.readByte(),h=this.readByte(),f=this.readByte(),g=this.readByte(),k=1-(a>>7<<1),a=(a<<4&2047|b>>4)-1023,b=((b&15)<<16|c<<8|d).toString(2)+(e>>7?"1":"0")+((e&127)<<
24|h<<16|f<<8|g).toString(2),b=parseInt(b,2);return 0==b&&-1023==a?0:k*(1+this.TWOeN52*b)*this.pow(2,a)},readUInt29:function(){var a,b=this.readByte()&255;if(128>b)return b;a=(b&127)<<7;b=this.readByte()&255;if(128>b)return a|b;a=(a|b&127)<<7;b=this.readByte()&255;if(128>b)return a|b;a=(a|b&127)<<8;b=this.readByte()&255;return a|b},readUInt30LE:function(){var a=readByte(),b=readByte(),c=readByte(),d=readByte();return 64<=d?void 0:a|b<<8|c<<16|d<<24},readUInt32LE:function(){var a=this.data,b=this.pos+=
4;return(a[--b]&255)<<24|(a[--b]&255)<<16|(a[--b]&255)<<8|a[--b]&255},readInt32LE:function(){var a=this.data,b=this.pos+=4,a=(a[--b]&255)<<24|(a[--b]&255)<<16|(a[--b]&255)<<8|a[--b]&255;return 2147483648<=a?a-4294967296:a},readUInt16LE:function(){var a=this.data,b=this.pos+=2;return(a[--b]&255)<<8|a[--b]&255},readInt16LE:function(){var a=this.data,b=this.pos+=2,a=(a[--b]&255)<<8|a[--b]&255;return 32768<=a?a-65536:a},readFloat32LE:function(){var a=this.data,b=this.pos+=4,c=a[--b]&255,d=a[--b]&255,
e=a[--b]&255,b=a[--b]&255,a=(c<<1&255|d>>7)-127,d=(d&127)<<16|e<<8|b;return 0==d&&-127==a?0:(1-(c>>7<<1))*(1+this.TWOeN23*d)*this.pow(2,a)},readFloat64LE:function(){var a=this.data,b=this.pos+=8,c=a[--b]&255,d=a[--b]&255,e=a[--b]&255,h=a[--b]&255,f=a[--b]&255,g=a[--b]&255,k=a[--b]&255,b=a[--b]&255,a=1-(c>>7<<1),c=(c<<4&2047|d>>4)-1023,d=((d&15)<<16|e<<8|h).toString(2)+(f>>7?"1":"0")+((f&127)<<24|g<<16|k<<8|b).toString(2),d=parseInt(d,2);return 0==d&&-1023==c?0:a*(1+this.TWOeN52*d)*this.pow(2,c)},
readDate:function(){var a=this.readDouble(),b=this.readUInt16();return new Date(a+6E4*b)},readString:function(a){for(var b=[];0>1];a>>=1;if(0==a)return"";a=this.readString(a);this.stringTable.push(a);return a},readTraits:function(a){var b={properties:[]};if(1==(a&3))return this.traitTable[a>>2];b.externalizable=4==(a&4);b.dynamic=8==(a&8);b.count=a>>4;b.className=this.readStringAMF3();this.traitTable.push(b);for(a=0;a>1];var a=this.readDouble(),c=new Date(a);this.objectTable.push(c);
return c}if(a==a3d.Amf3Types.kArrayType){a=this.readUInt29();if(0==(a&1))return this.objectTable[a>>1];a>>=1;b=this.readStringAMF3();if(""==b){for(var d=[],b=0;b>1];var e=this.readTraits(a),a=e.className;if(e.externalizable)d=
this.readExternalizable(a);else{a=e.properties.length;for(b=0;b>1]);a>>=1;if(0==a)return null;a=this.readString(a);a=this.stringToXML(a);this.objectTable.push(a);return a}if(a==a3d.Amf3Types.kByteArrayType){a=this.readUInt29();
if(0==(a&1))return this.objectTable[a>>1];a>>=1;d=new a3d.ByteArray;this.objectTable.push(d);for(b=0;b 0)? ("\nErrMsg:\n" + _NTV.Err.join("\n")): "" )
);
} else {
var arrHLS = [];
var arrTmp = objRet.objDto.IOSRenditions;
if ( arrTmp && arrTmp instanceof Array && arrTmp.length ) {
for ( var i = 0; i < arrTmp.length; i++ ) {
if ( !arrTmp[i] || typeof arrTmp[i] != "object" ) continue;
arrHLS.push( "[" + (i+1) + "]"
+ " " + (arrTmp[i].frameWidth? arrTmp[i].frameWidth:" ") + "×" + (arrTmp[i].frameHeight? arrTmp[i].frameHeight:" ")
+ " size=" + (arrTmp[i].size? ((typeof arrTmp[i].size=="number")?Math.floor(arrTmp[i].size):arrTmp[i].size):" ")
+ " bitrate=" + (arrTmp[i].encodingRate? arrTmp[i].encodingRate:" ")
+ " codec=" + (arrTmp[i].videoCodec? arrTmp[i].videoCodec:" ")
+ "\n" + arrTmp[i].defaultURL
);
}
}
var arrRTMP = [];
var selectRTMPUrl = "";
arrTmp = objRet.objDto.renditions;
if ( arrTmp && arrTmp instanceof Array && arrTmp.length ) {
for ( var i = 0; i < arrTmp.length; i++ ) {
if ( !arrTmp[i] || typeof arrTmp[i] != "object" ) continue;
arrRTMP.push( "[" + (i+1) + "]"
+ " " + (arrTmp[i].frameWidth? arrTmp[i].frameWidth:" ") + "×" + (arrTmp[i].frameHeight? arrTmp[i].frameHeight:" ")
+ " size=" + (arrTmp[i].size? ((typeof arrTmp[i].size=="number")?Math.floor(arrTmp[i].size):arrTmp[i].size):" ")
+ " bitrate=" + (arrTmp[i].encodingRate? arrTmp[i].encodingRate:" ")
+ " codec=" + (arrTmp[i].videoCodec? arrTmp[i].videoCodec:" ")
+ "\n" + arrTmp[i].defaultURL
);
}
var arrSct = [];
for ( var i = 0; i < arrTmp.length; i++ ) {
if ( !arrTmp[i] || typeof arrTmp[i] != "object" ) continue;
if ( !arrTmp[i].defaultURL ) continue;
var obj = {};
obj.url = arrTmp[i].defaultURL;
obj.size = (typeof arrTmp[i].size == "number")? arrTmp[i].size: 0;
arrSct.push( obj );
}
if ( arrSct.length > 0 ) {
arrSct.sort( function(a,b){return b.size-a.size;} );
selectRTMPUrl = arrSct[0].url;
}
}
var publisherId = objRet.publisherId || objRet.objDto.publisherId;
var defUrl = objRet.objDto.FLVFullLengthURL? objRet.objDto.FLVFullLengthURL:"";
if ( defUrl ) var defCmdLine = mkRtmpCmdLine ( defUrl, objRet.url, objRet.contentId, publisherId, objRet.experienceId );
if ( selectRTMPUrl && ( defUrl != selectRTMPUrl ) ) var sctCmdLine = mkRtmpCmdLine ( selectRTMPUrl, objRet.url, objRet.contentId, publisherId, objRet.experienceId );
WScript.Echo( "title: " + objRet.title
+ ( objRet.article?("\narticle: " + objRet.article): "" )
+ ( objRet.description?("\ndescription: " + objRet.description):"" )
+ "\n\nHLS:\n" + arrHLS.join( "\n\n" )
+ "\n\nRTMP:\n" + arrRTMP.join( "\n\n" )
+ ( defCmdLine? ("\n\nRTMPCmdLine(default):\n"+defCmdLine):"" )
+ ( sctCmdLine? ("\n\nRTMPCmdLine(高画質):\n"+sctCmdLine):"" )
+ ( (_NTV.Err.length > 0)? ("\n\nErrMsg:\n" + _NTV.Err.join("\n")):"" )
);
}
/* WSH 動作用コード、ここまで */