Created
September 9, 2009 07:09
-
-
Save modeverv/183533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Vs = { | |
Sites:['youtube','saymove','niconico','veoh'/*,'MEGAVIDEO'*/], | |
youtube :{ | |
base: "http://www.youtube.com", | |
get qurl(){ | |
return CmdUtils.renderTemplate( this.base+"/results?search_query=${word}", {word: encodeURI(Vs.D.word)} ); | |
}, | |
yank: function yank(p, doc, count) { | |
var self = this; | |
doc.find(".list-view").each(function(){ | |
var t = $(this); | |
t.find(".yt-uix-hovercard-content,.hid,.video-facets,.video-short-title,.video-translation-links,.video-username,.video-translation-links,.hid quicklist-inlist").empty(); | |
t.find('a[href]').each(function(){ Vs.fullpath(self, $(this));}); | |
t.find(".video-cell").each(function(){ | |
$(this).attr({style:"width:95%;"}); | |
var uuu = [];urll = $(this).find("a[href]").each(function(){return uuu.push($(this).attr("href"));})[0]; | |
p.push([ $(this).html() , urll ]); | |
}); | |
}); | |
return [p,0,"limit"]; | |
} | |
}, | |
/* | |
MEGAVIDEO :{ | |
base: "http://www.megavideo.com/", | |
get qurl(){ | |
return CmdUtils.renderTemplate( this.base+"?c=search&s=${word}", {word: encodeURI(Vs.D.word)} ); | |
}, | |
yank: function yank(p, doc, count) { | |
var self = this; | |
var urll = "うんこ"; | |
var sele = "a:content(" + Vs.D.word.slice(0,2) + ")"; | |
var pk = 4;//magicnumber!!!!! | |
$(doc.find("#mainpage").find("table").get(2)).find("table").find(sele).each(function(){ | |
pk++; | |
if(pk % 10 == 0 || pk == 11){ //magicnumber!!!!! | |
count++; | |
urll = self.base + $(this).attr("href"); | |
var tagg = ['<a href="',urll,'" >', $(this).html(),'</a>'].join(""); | |
p.push([pk + tagg,urll]); | |
} | |
}); | |
return [p,count,"nolimit"]; | |
} | |
}, | |
*/ | |
saymove :{ | |
base: "http://say-move.org", | |
get qurl(){ | |
return CmdUtils.renderTemplate( this.base + "/comesearch.php?q=${word}&sort=view&genre=&sitei=&mode=&p=1", {word: encodeURI(Vs.D.word)} ); | |
}, | |
yank: function yank(p, doc, count) { | |
var self = this; | |
doc.find("p b a").each(function(){ | |
var tagg = ['<a href="',(urll = $(this).attr("href")) ,'" >', $(this).html(),'</a>'].join(""); | |
p.push([tagg,urll]); | |
}); | |
return [p,0,"nolimit"]; | |
} | |
}, | |
veoh :{ | |
base: "http://www.veoh.com", | |
get qurl() { | |
return CmdUtils.renderTemplate( this.base+"/search/videos/q/${word}", {word: encodeURI(Vs.D.word)} ); | |
}, | |
yank: function yank(p, doc, count) { | |
var self = this; | |
doc.find("li").find(".thumbWrapper").each(function(){ | |
$(this).find('a[href]').each(function(){ | |
Vs.fullpath(self, $(this)); | |
}); | |
var uuu = []; | |
$(this).find(".thumbLink,.thumbCat,.sp_info").empty(); | |
p.push([$(this).html(),$(this).find('a[href]').each(function(){ | |
return uuu.push($(this).attr("href")); | |
})[0]]); | |
}); | |
return [p,0,"nolimit"]; | |
} | |
}, | |
niconico :{ | |
base: "http://nicovideo.jp/", | |
get qurl(){ | |
return CmdUtils.renderTemplate( this.base+"search/${word}", {word: encodeURI(Vs.D.word)} ); | |
}, | |
yank: function yank(p, doc, count) { | |
var self = this; | |
var urll = ""; | |
doc.find(".thumb_frm").each(function(){ | |
var titleAndTime = []; | |
$(this).find("span").each(function(){ | |
titleAndTime.push($(this).html()); | |
}); | |
titleAndTime = titleAndTime.slice(0,3); | |
var uuu = []; | |
urll = $(this).find('a').each(function(){ | |
return uuu.push(Vs.fullpath(self, $(this))); | |
})[0]; | |
$(this).find(".TXT10,.vinfo_last_res,.font10,.vinfo_length,.font12").empty(); | |
p.push([$(this).html() + titleAndTime.join(""),urll]); | |
count++; | |
}); | |
return [p,count,"limit"]; | |
} | |
}, | |
D:{word:"",srvc:"",qurl:""}, | |
setArgs:function(args){ | |
var Args = args.object.text; | |
var Idx = Args.lastIndexOf(" from "); | |
this.D.word = Args.substr(0,Idx); | |
this.D.srvc = Args.substr(Idx).replace(" from ",""); | |
}, | |
fullpath:function (tg, $_){ | |
$_.attr({ href: [tg.base, $_.attr("href")].join('')}); | |
return $_.attr("href"); | |
} | |
}; | |
CmdUtils.CreateCommand({ | |
names: ["vsearch"], | |
icon: "http://nicovideo.jp/favicon.ico", | |
author: {name: "pawchin=>modeverv(fork)", email: "modeverv@gmail.com"}, | |
license: "GPL", | |
description: "video search", | |
help:(""+<>Supported Services:<ul style="list-style-image:none"> | |
<li><a href="http://www.youtube.com/">youtube</a></li> | |
<li><a href="http://www.nicovideo.jp/">niconico</a></li> | |
<li><a href="http://www.veoh.com/">veoh</a></li> | |
</ul></>), | |
arguments: [{ | |
role: 'object', | |
nountype:{ | |
label: "querystring", | |
suggest: function( text, html ){ | |
var suggestions = []; | |
for(var i = 0;i < Vs.Sites.length;i++){ | |
suggestions.push(CmdUtils.makeSugg( html + " from " + Vs.Sites[i] ) ); | |
} | |
return suggestions; | |
} | |
} | |
},], | |
preview: function preview(pblock, args) { | |
Vs.setArgs(args); | |
if(Vs.D.word.length == 0) return; | |
Vs.D.qurl = Vs[Vs.D.srvc].qurl; | |
var p = []; | |
var count = 0; | |
pblock.innerHTML = <><h1>Now Searching from {Vs.D.srvc} ....</h1> | |
<h1>querystrings: {Vs.D.word}</h1></>; | |
var genPreview = function (data){ | |
[p, count,lim] = Vs[Vs.D.srvc].yank(p,jQuery(data),count); | |
var strHtml = "<ol>"; | |
var limitia = 3 >= p.length ? p.length : lim == "nolimit" ? p.length : 3; | |
for(var i = 0; limitia > i; i++){ | |
strHtml += ['<li style="font-size:10px;line-height:12px;margin:0;padding:0;"><a accesskey="' , (i + 1) ,'" href="' , p[i][1] , '" >' , '</a>', | |
,p[i][0].replace("<br/>",""), | |
'<hr/>'].join("") ; | |
} | |
strHtml += "</ol>"; | |
jQuery(pblock) | |
.empty() | |
.append(strHtml); | |
}; | |
CmdUtils.previewGet(pblock, Vs.D.qurl, null, genPreview, "html"); | |
}, | |
execute:function(args){ | |
Utils.openUrlInBrowser( Vs.D.qurl ); | |
} | |
}); | |
/* | |
履歴 | |
2010/01/05 | |
google++の食感が忘れられなくてアクセスキーを仕込みました。 | |
1画面に収まるような表示件数に制限しました。ちゃんと調べたいならそのサイトにいくべさ! | |
2010/01/06 | |
saymoveに対応した。 | |
magevideoは調整中 | |
めんどくさくてパースをしきれていないveohとmegavideoとsaymoveはページを出したいのでlimit処理を追加した。 | |
とりあえず動きますが、いろいろ見直したい。 | |
youtubeリンクおかしいですよね。。 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment