diff --git a/lib/core/monitor.js b/lib/core/monitor.js index 7fb338d..bb35fa0 100644 --- a/lib/core/monitor.js +++ b/lib/core/monitor.js @@ -365,7 +365,7 @@ class Monitor extends Searcher { log.debug('正在筛选的动态信息', lottery_info); if (des === '') { - log.info('筛选动态', `获取动态内容为空(https://t.bilibili.com/${dyid})风控或是视频动态`); + log.info('筛选动态', `获取动态内容为空(https://t.bilibili.com/${dyid})风控`); return false; } diff --git a/lib/core/searcher.js b/lib/core/searcher.js index 0c50f27..b24dd74 100644 --- a/lib/core/searcher.js +++ b/lib/core/searcher.js @@ -103,43 +103,27 @@ function parseDynamicCard(data) { /* 是否有官方抽奖 */ obj.hasOfficialLottery = false; /* 转发描述 */ - obj.description = ''; + obj.description = ditem?.modules?.module_dynamic?.major?.archive?.desc || ''; let _total_len = 0; - if (Array.isArray(ditem?.modules?.module_dynamic?.desc?.rich_text_nodes)) { - ditem?.modules?.module_dynamic?.desc?.rich_text_nodes.forEach(node => { - if (node.type === 'RICH_TEXT_NODE_TYPE_AT') { - obj.ctrl.push({ - data: node.rid, - location: _total_len, - length: node.text.length, - type: 1 - }); - } - /* 是否有官方抽奖 */ - if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') { - obj.hasOfficialLottery = true; - } - obj.description += node.orig_text; - _total_len += node.text.length; - }); - } else { - ditem?.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes.forEach(node => { - if (node.type === 'RICH_TEXT_NODE_TYPE_AT') { - obj.ctrl.push({ - data: node.rid, - location: _total_len, - length: node.text.length, - type: 1 - }); - } - /* 是否有官方抽奖 */ - if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') { - obj.hasOfficialLottery = true; - } - obj.description += node.orig_text; - _total_len += node.text.length; - }); - } + let rich_text_nodes = ditem?.modules?.module_dynamic?.desc?.rich_text_nodes + || ditem?.modules?.module_dynamic?.major?.opus?.summary?.rich_text_nodes + || []; + rich_text_nodes.forEach(node => { + if (node.type === 'RICH_TEXT_NODE_TYPE_AT') { + obj.ctrl.push({ + data: node.rid, + location: _total_len, + length: node.text.length, + type: 1 + }); + } + /* 是否有官方抽奖 */ + if (node.type === 'RICH_TEXT_NODE_TYPE_LOTTERY') { + obj.hasOfficialLottery = true; + } + obj.description += node.orig_text; + _total_len += node.text.length; + }); /* 预约抽奖信息 */ obj.reserve_id = ditem?.modules?.module_dynamic?.additional?.reserve?.rid || 0; obj.reserve_lottery_text = ditem?.modules?.module_dynamic?.additional?.reserve?.title || '未获取到'; diff --git a/test/ai.test.js b/test/ai.test.js index f3acae8..2bc7877 100644 --- a/test/ai.test.js +++ b/test/ai.test.js @@ -3,7 +3,7 @@ const utils = require('../lib/utils.js'); const config = require('../lib/data/config'); (async () => { - await util.par_run([0], [ + await util.par_run([], [ // 0 async () => { let msg = await utils.getAiContent( diff --git a/test/dynamic_card.test.js b/test/dynamic_card.test.js index f790e4b..0a4ee94 100644 --- a/test/dynamic_card.test.js +++ b/test/dynamic_card.test.js @@ -4,13 +4,29 @@ const searcher = require('../lib/core/searcher'); const util = require('./util'); (async () => { - await util.par_run([], [ + await util.par_run([0, 1, 2, 3], [ // 0 + async () => { + let info = await bili_client.getOneDynamicByDyid('1206954551173709840'); + let card = searcher.parseDynamicCard(info); + console.log(JSON.stringify(card, null, 4)); + }, async () => { let info = await bili_client.getOneDynamicByDyid('1207028214165143570'); let card = searcher.parseDynamicCard(info); console.log(JSON.stringify(card, null, 4)); }, + async () => { + let info = await bili_client.getOneDynamicByDyid('1209643548566093825'); + let card = searcher.parseDynamicCard(info); + console.log(JSON.stringify(card, null, 4)); + }, + async () => { + let info = await bili_client.getOneDynamicByDyid('1210278611064455168'); + let card = searcher.parseDynamicCard(info); + console.log(JSON.stringify(card, null, 4)); + }, + ]); console.log('dynamic_card.test ... ok!');