feat: 获取视频动态的简介以参与转发抽奖

This commit is contained in:
shanmite 2026-06-05 11:12:28 +08:00
parent 9bb9268b96
commit 51ec0a191f
4 changed files with 39 additions and 39 deletions

View File

@ -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;
}

View File

@ -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 || '未获取到';

View File

@ -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(

View File

@ -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!');