Skip to content

Commit

Permalink
fix(route): 增加锁章检测 (#16760)
Browse files Browse the repository at this point in the history
  • Loading branch information
jichangee committed Sep 15, 2024
1 parent 2783eed commit 0ae1f0c
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions lib/routes/jjwxc/book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ async function handler(ctx) {
const chapterUpdatedTime = item.find('td').last().text().trim();

const isVip = item.find('span[itemprop="headline"] font').last().text() === '[VIP]';
const isLock = item.find('td').eq(1).last().text().trim() === '[锁]';

return {
title: `${chapterName} ${chapterIntro}`,
Expand All @@ -82,32 +83,35 @@ async function handler(ctx) {
guid: `jjwxc-${id}#${chapterId}`,
pubDate: timezone(parseDate(chapterUpdatedTime), +8),
isVip,
isLock,
};
});

items.reverse();

items = await Promise.all(
items.slice(0, limit).map((item) =>
cache.tryGet(item.link, async () => {
if (!item.isVip) {
const { data: detailResponse } = await got(item.link, {
responseType: 'buffer',
});
item.isLock
? Promise.resolve(item)
: cache.tryGet(item.link, async () => {
if (!item.isVip) {
const { data: detailResponse } = await got(item.link, {
responseType: 'buffer',
});

const content = load(iconv.decode(detailResponse, 'gbk'));
const content = load(iconv.decode(detailResponse, 'gbk'));

content('span.favorite_novel').parent().remove();
content('span.favorite_novel').parent().remove();

item.description += art(path.join(__dirname, 'templates/book.art'), {
description: content('div.novelbody').html(),
});
}
item.description += art(path.join(__dirname, 'templates/book.art'), {
description: content('div.novelbody').html(),
});
}

delete item.isVip;
delete item.isVip;

return item;
})
return item;
})
)
);

Expand Down

0 comments on commit 0ae1f0c

Please sign in to comment.