// ==SiteScript==
// @siteName Magnovideo.com
// @siteUrl http://www.magnovideo.com/
// @author mayan
// @authorUrl
// @scriptUrl
// @description
// @date 2013/12/02
// @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, "/" )
.replace( /(\d+);/g, function(a,b){return String.fromCharCode(parseInt(b,10));} )
.replace( /([0-9a-f]+);/ig, function(a,b){return String.fromCharCode(parseInt(b,16));} );
}
}
var _Magno = {};
_Magno.showMsg = true;
function isSiteUrl( url ) {
if ( typeof _Magno != "object" ) _Magno = {};
if ( url.match( /http:\/\/(?:www\.)?magnovideo\.com\/?(\?.+)/ )
&& RegExp.$1.match( /[?&]v=[^]+/ ) ) return true;
if ( url.match( /http:\/\/(?:www\.)?magnovideo\.com\/[0-9A-Za-z]{8}(?:$|[?])/ ) ) return true;
return false;
}
function getVideoDetail( url ) {
if ( url.match( /http:\/\/(?:www\.)?magnovideo\.com\/?(\?.+)/ )
&& RegExp.$1.match( /[?&]v=([^]+)/ ) ) {
var vid = RegExp.$1;
} else
if ( url.match( /http:\/\/(?:www\.)?magnovideo\.com\/([0-9A-Za-z]{8})(?:$|[?])/ ) ) {
vid = RegExp.$1;
} else {
return null;
}
if ( !vid ) return null;
var craving = new CravingSiteScript();
var pageurl = "http://www.magnovideo.com/?v=" + vid;
try {
var text = craving.getResponseText( pageurl );
} catch( e ) {
text = "";
}
if ( text && text.match( /
]*)?>\s*(.*?)\s*<\/title\s*>/i ) ) {
var page_title = craving.decodeHtml( RegExp.$1 );
}
var configurl = "http://www.magnovideo.com/player_config.php?mdid=" + vid;
try {
text = craving.getResponseText( configurl );
} catch( e ) {
text = "";
}
if ( !text ) return null;
var video_title = text.match( /]*)?>(?:\s*\s*)?<\/video_title\s*>/im )? craving.decodeHtml( RegExp.$1 ): "";
var mdid_ex = text.match( /]*)?>(?:\s*\s*)?<\/mdid_ex\s*>/im )? craving.decodeHtml( RegExp.$1 ): "";
var video_name = text.match( /]*)?>(?:\s*\s*)?<\/video_name\s*>/im )? craving.decodeHtml( RegExp.$1 ): "1.mp4";
var storage_path = text.match( /]*)?>(?:\s*\s*)?<\/storage_path\s*>/im )? craving.decodeHtml( RegExp.$1 ): "";
var original_storage_path = text.match( /]*)?>(?:\s*\s*)?<\/original_storage_path\s*>/im )? craving.decodeHtml( RegExp.$1 ): "http://o1.magnovideo.com:8080/";
var movie_burst = text.match( /]*)?>(?:\s*\s*)?<\/movie_burst\s*>/im )? craving.decodeHtml( RegExp.$1 ): "";
var burst_speed = text.match( /]*)?>(?:\s*\s*)?<\/burst_speed\s*>/im )? craving.decodeHtml( RegExp.$1 ): "";
var mdid = text.match( /]*)?>(?:\s*\s*)?<\/mdid\s*>/im )? craving.decodeHtml( RegExp.$1 ): "0";
var mdid_hash = text.match( /]*)?>(?:\s*\s*)?<\/mdid_hash\s*>/im )? craving.decodeHtml( RegExp.$1 ): mdid;
var ste = text.match( /]*)?>(?:\s*\s*)?<\/ste\s*>/im )? craving.decodeHtml( RegExp.$1 ): "";
var sto = text.match( /]*)?>(?:\s*\s*)?<\/sto\s*>/im )? craving.decodeHtml( RegExp.$1 ): "";
var opart = text.match( /]*)?>(?:\s*\s*)?<\/opart\s*>/im )? craving.decodeHtml( RegExp.$1 ): "";
opart = ( opart == "-" )? "": ( "part" + opart + "/" );
var cpart = text.match( /]*)?>(?:\s*\s*)?<\/cpart\s*>/im )? craving.decodeHtml( RegExp.$1 ): "";
cpart = ( cpart == "-" )? "": ( "part" + cpart + "/" );
var title = video_title || page_title;
if ( !title ) title = "magnovideo_" + vid;
title = title.replace(/[\\\/:*?"<>|]/g, "_");
try {
var hash = parseInt( mdid_hash, 10 );
} catch( e ) {
hash = 0;
}
if ( isNaN( hash ) ) hash = 0;
if ( hash <= 0 ) {
if ( mdid_ex && _Magno.showMsg ) {
var objBx = new clsMsgBox();
if ( objBx.isOK ) {
objBx.MsgBox( "埋め込みの動画かもしれません。\n" + mdid_ex
, "from magnovideo.site.js", 0 );
}
}
return null;
}
var arr = [];
for ( var i = 0; i < 4; i++ ) {
arr.push( hash % 200 );
hash = Math.floor( hash / 200 );
}
arr.reverse();
var hash_path = arr.join( "/" );
if ( storage_path && ste ) {
var realUrl = storage_path + "storage/files/"
+ cpart + hash_path + "/" + video_name
+ "?burst=" + movie_burst + "k"
+ "&u=" + burst_speed + "k"
+ "&" + ste;
} else {
realUrl = original_storage_path + "storage/files/"
+ opart + hash_path + "/" + video_name
+ "?burst=" + movie_burst + "k"
+ "&u=" + burst_speed + "k"
+ "&" + sto;
}
return { videoTitle0: title, videoUrl0: realUrl };
}
/* msgbox */
function clsMsgBox(){
//WScript.Shell Popup
this.isOK = false;
this._objShell = null;
this._initialize = function (){
try{
this._objShell = new ActiveXObject( "WScript.Shell" );
this.isOK = true;
} catch( e ) {
this.isOK = false;
}
}
this._initialize();
this.MsgBox = function ( msg, title, btn ){
if ( btn == undefined ) btn = 1;
//btn=1の時ret: OK:1, キャンセル:2
if ( this.isOK )
return this._objShell.Popup( msg, 0, title, btn+64 );
}
}
/* msgbox */