From 0ae1f0c5d430fe8c8614fac5d562938514c93330 Mon Sep 17 00:00:00 2001 From: moxuy Date: Sun, 15 Sep 2024 13:05:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E5=A2=9E=E5=8A=A0=E9=94=81?= =?UTF-8?q?=E7=AB=A0=E6=A3=80=E6=B5=8B=20(#16760)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/jjwxc/book.ts | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/routes/jjwxc/book.ts b/lib/routes/jjwxc/book.ts index 7f5f76ae0cb744..c111a1cfa3d710 100644 --- a/lib/routes/jjwxc/book.ts +++ b/lib/routes/jjwxc/book.ts @@ -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}`, @@ -82,6 +83,7 @@ async function handler(ctx) { guid: `jjwxc-${id}#${chapterId}`, pubDate: timezone(parseDate(chapterUpdatedTime), +8), isVip, + isLock, }; }); @@ -89,25 +91,27 @@ async function handler(ctx) { 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; + }) ) );