将章节数据单独存放

This commit is contained in:
zhl 2019-04-03 16:43:54 +08:00
parent 53e6efaec9
commit 580654b7aa

View File

@ -167,9 +167,6 @@ const parseOneBook = async (book) => {
if (!siteId) {
return ;
}
book.data.chapter_list = chapterList;
book.status = 2;
book.markModified('data');
await book.save();
let bar = multi.newBar(' '+book.data.name+' [:bar] :percent :etas', {
complete: '=',
@ -181,14 +178,25 @@ const parseOneBook = async (book) => {
let obj = await bookChapterInfo(chapter.chapter_id, chapter.crawl_book_id, chapter.lists_id, siteId);
bar.tick(1);
chapter.content = obj.data.content;
chapter.book_id = bookId;
chapter.site = siteId;
let chapterRecord = new SpiderData({
data: chapter,
type: 'book_chapter'
});
await chapterRecord.save();
}
book.status = 3;
book.data.chapter_list = chapterList;
book.status = 2;
book.markModified('data');
await book.save();
}
const parseAllBookList = async (start) => {
let bookList = await SpiderData.find({status: 0, type: 'book'}).sort({'data.book_id': 1}).limit(15);
const parseAllBookList = async (sex, ltype) => {
let bookList = await SpiderData.find({
'data.sex': sex,
'data.ltype_id': ltype,
status: 0,
type: 'book'
}).sort({'data.book_id': 1});
for(let book of bookList) {
generalQueue.addQueue({
run: async function () {
@ -209,6 +217,6 @@ export default {
// 获取所有分类下的数据列表
// await parseAllCategory(2, 0);
// 获取所有数据的详情
await parseAllBookList();
await parseAllBookList(1, 0);
}
}