Irvineを使って//imgur.comの静止画を落とすためのスクリプト。アルバムの画像全てをアイテム追加するため https://github.com/rentan/Irvine/blob/master/Dorothy2/common/additem.dms が使える必要があります。
//Dorothy2
//caption=imgur
//version=0.1
//hint=例)http://imgur.com/a/0hcgF をアイテム追加
//match=http://imgur.com/[^g]
//ResponseMatch=
//author=nanasi
//path=program
//priority=500
//end
function(){
var userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0';
common_load('download','test_download');
var url=new URL(urlinfo.url);
var http=download(url.url,false,{'Cookie':'', 'User-Agent':userAgent});
if(http.responseHeader.code!=200){
return retry('error--->'+http.responseHeader.code);
}
var cookie=http.responseHeader.cookie.data;
common_load ('additem');
var ini = {
Mode: 'Auto',
// Queue: '/Default',
Listname: '',
Workaround: false
};
var additem = new AddItem (ini);
var result = http.data.match('{"hash":"[^"]*?","title":"[^"]*?","description":"[^"]*?","width":[^"]*?,"height":[^"]*?,"size":[^"]*?,"ext":"[^"]*?","animated":[^"]*?,"prefer_video":[^"]*?,"looping":[^"]*?,"datetime":"[^"]*?"}', 'g');
var num = 1;
for(value in result) {
result[value].match('"hash":"(.+?)".+"ext":"(.+?)"');
var filename = RegExp.$1 + RegExp.$2;
var imgSrc = "http://i.imgur.com/" + filename;
var list = [
{ Url: imgSrc, Filename: num + '_' + filename }
];
additem.send (list);
++num;
}
exit ();
}