// 所有截图link
var snapshots = []
$('a.sample-box').each(function (i, e) {
let $e = $(e);
snapshots.push($e.attr("href"))
})
getSnapshots(link, snapshots);
getSnapshots 方法:
function getSnapshots(link, snapshots) {
// https://pics.dmm.co.jp/digital/video/118abp00454/118abp00454jp-1.jpg
for (var i = 0; i < snapshots.length; i++){
getSnapshot(link, snapshots[i])
}
}
getSnapshot 方法:
function getSnapshot(link, snahpshotLink) {
let fanhao = link.split('/').pop();
let itemOutput = output + "/" + fanhao
mkdirp.sync(itemOutput);
let snapshotName = snahpshotLink.split('/').pop();
let fileFullPath = path.join(itemOutput, snapshotName)
fs.access(fileFullPath, fs.F_OK, function (err) {
if (err) {
var snapshotFileStream = fs.createWriteStream(fileFullPath + '.part');
var finished = false;
request.get(snahpshotLink)
.on('end', function () {
if (!finished) {
fs.renameSync(fileFullPath + '.part', fileFullPath);
finished = true;
// console.error(('[' + fanhao + ']').green.bold.inverse + '[截图]'.yellow.inverse, fileFullPath);
}
})
.on('error', function (err) {
if (!finished) {
finished = true;
// console.error(('[' + fanhao + ']').red.bold.inverse + '[截图]'.yellow.inverse, err.message.red);
errorCount++;
}
})
.pipe(snapshotFileStream);
} else {
// console.log(('[' + fanhao + ']').green.bold.inverse + '[截图]'.yellow.inverse, 'file already exists, skip!'.yellow);
}
})
}
小封面下载的方法已经除掉,方法可见#23,在
getItemPage
的getItemMagnet(link, meta, callback);
后面添加了下载当前番号的视频截图的功能:getSnapshots 方法:
getSnapshot 方法:
由于本人对nodejs不熟,所以添加的方法是在作者原来的方法上改的。