fix: 获取动态详情出现undefined (#271)

Fixes #271
This commit is contained in:
shanmite 2023-03-22 17:26:44 +08:00
parent 00174b0fdc
commit d370fef899
2 changed files with 13 additions and 3 deletions

View File

@ -110,8 +110,12 @@ function parseDynamicCard(dynamic_detail_card) {
obj.hasOfficialLottery = extension && extension.lott && true;
/* 转发者的描述 纯文字内容 图片动态描述 后两个分别是视频动态的描述和视频本身的描述*/
obj.description =
(item && (item.content || '' + item.description || ''))
|| (cardToJson.dynamic || '' + cardToJson.desc || '')
(item && ((item.content || '') + (item.description || '')))
|| (
(cardToJson.dynamic || '')
+ (cardToJson.desc || '')
+ (cardToJson.vest && cardToJson.vest.content || '')
)
|| '';
/* 转发 */
if (obj.type === 1) {

View File

@ -4,7 +4,7 @@ const searcher = require("../lib/core/searcher");
const util = require('./util');
(async () => {
await util.par_run([0, 1, 2, 3, 4, 5], [
await util.par_run([0, 1, 2, 3, 4, 5, 6], [
// 0
async () => {
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
@ -44,6 +44,12 @@ const util = require('./util');
chats = await bili_client.getChat(card.rid_str, card.chat_type)
assert.equal(chats.filter(it => it[0] === '六的月').length, 0)
},
// 6
async () => {
const dy = await bili_client.getOneDynamicByDyid("774973685666676768");
const card = searcher.parseDynamicCard(dy)
assert.notEqual(card.description + "", undefined + "");
},
])
console.log("dynamic_card.test ... ok!");