fix: deepscan errors

This commit is contained in:
DIYgod
2023-03-18 21:00:38 +00:00
parent cb75624e27
commit c767e6c7b8
10 changed files with 18 additions and 18 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
});
const items = response.data
.replace(/\t\n|\t\n\n/g, '\n\n')
.replace(/\t\n\n|\t\n/g, '\n\n')
.split('\n\n')
.map((item) => {
item = item.indexOf('\n') === 0 ? item.substr(2, item.length - 2) : item;
+1 -1
View File
@@ -41,7 +41,7 @@ module.exports = async (ctx) => {
}
ctx.state.data = {
title: mediaData.mediaInfo.title,
title: mediaData?.mediaInfo.title,
link: `https://www.bilibili.com/bangumi/media/md${mediaData.mediaInfo.media_id}/`,
image: mediaData.mediaInfo.cover,
description: mediaData.mediaInfo.evaluate,
+1 -1
View File
@@ -150,7 +150,7 @@ module.exports = async (ctx) => {
let link = '';
if (data.dynamic_id) {
link = `https://t.bilibili.com/${data.dynamic_id}`;
} else if (item.desc && item.desc.dynamic_id) {
} else if (item.desc?.dynamic_id) {
link = `https://t.bilibili.com/${item.desc.dynamic_id}`;
}
+2 -2
View File
@@ -97,7 +97,7 @@ module.exports = async (ctx) => {
let link = '';
if (data.dynamic_id) {
link = `https://t.bilibili.com/${data.dynamic_id}`;
} else if (item.desc && item.desc.dynamic_id) {
} else if (item.desc?.dynamic_id) {
link = `https://t.bilibili.com/${item.desc.dynamic_id}`;
}
@@ -114,7 +114,7 @@ module.exports = async (ctx) => {
}
// 作者信息
let author = '哔哩哔哩番剧';
if (item.desc.user_profile) {
if (item.desc?.user_profile) {
author = item.desc.user_profile.info.uname;
}
+2 -2
View File
@@ -35,14 +35,14 @@ module.exports = async (ctx) => {
// link
let link = '';
if (item.desc && item.desc.dynamic_id_str) {
if (item.desc?.dynamic_id_str) {
link = `https://t.bilibili.com/${item.desc.dynamic_id_str}`;
}
return {
title: cardData.title || cardData.description || cardData.content || (cardData.vest && cardData.vest.content),
description: `${cardData.desc || cardData.description || cardData.content || cardData.summary || (cardData.vest && cardData.vest.content) + (cardData.sketch && cardData.sketch.title)}${imgHTML} `,
pubDate: new Date(item.desc.timestamp * 1000).toUTCString(),
pubDate: new Date(item.desc?.timestamp * 1000).toUTCString(),
link,
};
}),
+1 -1
View File
@@ -1,5 +1,5 @@
module.exports = function (router) {
router.get('/work/tags/:tag', require('./index'));
router.get('/tag/:tag', require('./index'));
router.get(/([\w|\d|/|-]+)?/, require('./index'));
router.get(/([\w\d/-]+)?/, require('./index'));
};
+1 -1
View File
@@ -1,6 +1,6 @@
module.exports = function (router) {
router.get('/liuyan/:id/:state?', require('./liuyan'));
router.get('/xjpjh/:keyword?/:year?', require('./xjpjh'));
router.get(/([\w|\d]+)\/([\w|\d|/]+)?/, require('./index'));
router.get(/([\w\d]+)\/([\w\d/]+)?/, require('./index'));
router.get('/:0?', require('./index'));
};
+3 -3
View File
@@ -68,9 +68,9 @@ module.exports = async (ctx) => {
for (const news of data.newsArray) {
item.description +=
`<li><a href="${news.url || news.mobileUrl}">${news.title}</a>` + news.siteName
? `&nbsp;&nbsp;<small><b>${news.siteName}</b></small>`
: '' + `${news.publishDate ? `&nbsp;&nbsp;<small>${news.publishDate.split('T')[0]}</small>` : ''}</li>`;
`<li><a href="${news.url || news.mobileUrl}">${news.title}</a>` +
(news.siteName ? `&nbsp;&nbsp;<small><b>${news.siteName}</b></small>` : '') +
`${news.publishDate ? `&nbsp;&nbsp;<small>${news.publishDate.split('T')[0]}</small>` : ''}</li>`;
}
item.description += '</ul>';
+1 -1
View File
@@ -523,7 +523,7 @@ module.exports = async (ctx) => {
let mediaTag = '';
if (showMediaTagInTitle) {
msgTypes.forEach((type) => {
if (type !== REPLY || type !== FORWARDED || type !== VIA_BOT || (type === REPLY && showReplyTo) || (type === FORWARDED && showFwdFrom) || (type === VIA_BOT && showViaBot)) {
if (type !== REPLY || type !== VIA_BOT || (type === REPLY && showReplyTo) || (type === FORWARDED && showFwdFrom) || (type === VIA_BOT && showViaBot)) {
mediaTag += showMediaTagAsEmoji ? mediaTagDict[type][1] : mediaTagDict[type][0];
}
});
+5 -5
View File
@@ -25,12 +25,12 @@ module.exports = async (ctx) => {
if (searchQuery) {
// 删除关键字高亮 <mark class="highlight">
const highlightMarks = item.find('mark.highlight').get();
highlightMarks.forEach((mark) => {
mark = $(mark);
const markInnerHtml = mark.html();
mark.replaceWith(markInnerHtml);
});
if (highlightMarks) {
highlightMarks.forEach((mark) => {
mark = $(mark);
const markInnerHtml = mark.html();
mark.replaceWith(markInnerHtml);
});
item = $(item.html()); // 删除关键字高亮后,相邻的裸文本节点不会被自动合并,重新生成 cheerio 对象以确保后续流程正常运行
}
}