fix: 预约抽奖包月抽奖识别异常 (#288)

Fixed #288
This commit is contained in:
shanmite 2023-08-23 16:20:45 +08:00
parent da8d460dc6
commit 2f2eaabc57
4 changed files with 38 additions and 9 deletions

View File

@ -26,8 +26,8 @@ jobs:
nodev: 18 nodev: 18
- platform: win - platform: win
nodev: 18 nodev: 18
- platform: win # - platform: win
nodev: 12 # nodev: 12
steps: steps:
- name: "Checkout codes" - name: "Checkout codes"
uses: actions/checkout@v3 uses: actions/checkout@v3

View File

@ -103,7 +103,15 @@ function parseDynamicCard(dynamic_detail_card) {
obj.reserve_lottery_text = text; obj.reserve_lottery_text = text;
} }
} }
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) { if (extendjsonToJson[""]) {
let r = extendjsonToJson[""].reserve || {};
let { reserve_id, reserve_lottery } = r;
if (reserve_lottery === 1) {
obj.reserve_id = reserve_id + "";
obj.reserve_lottery_text = "信息丢失";
}
}
if (extend_json.match(/"":\{"lottery/)) {
obj.is_charge_lottery = true obj.is_charge_lottery = true
} }
/* 是否有官方抽奖 */ /* 是否有官方抽奖 */
@ -119,9 +127,10 @@ function parseDynamicCard(dynamic_detail_card) {
|| ''; || '';
/* 转发 */ /* 转发 */
if (obj.type === 1) { if (obj.type === 1) {
const { origin_extension, origin } = cardToJson const { origin_extension, origin, origin_extend_json } = cardToJson
, originToJson = strToJson(origin) , originToJson = strToJson(origin)
, { add_on_card_info = [] } = display.origin || {} , { add_on_card_info = [] } = display.origin || {}
, originExtendjsonToJson = strToJson(origin_extend_json)
, { user, item } = originToJson; , { user, item } = originToJson;
/* 源动态的ts10 */ /* 源动态的ts10 */
obj.origin_create_time = desc.origin.timestamp; obj.origin_create_time = desc.origin.timestamp;
@ -150,7 +159,15 @@ function parseDynamicCard(dynamic_detail_card) {
obj.origin_reserve_lottery_text = text; obj.origin_reserve_lottery_text = text;
} }
} }
if (JSON.stringify(add_on_card_info).match(/充电专属抽奖/)) { if (originExtendjsonToJson[""]) {
let r = originExtendjsonToJson[""].reserve || {};
let { reserve_id, reserve_lottery } = r;
if (reserve_lottery === 1) {
obj.origin_reserve_id = reserve_id + "";
obj.origin_reserve_lottery_text = "信息丢失";
}
}
if (origin_extend_json.match(/"":\{"lottery/)) {
obj.origin_is_charge_lottery = true obj.origin_is_charge_lottery = true
} }
/* 是否有官方抽奖 */ /* 是否有官方抽奖 */

View File

@ -911,7 +911,7 @@ const bili_client = {
}, },
/** /**
* 预约抽奖 * 预约抽奖
* @param {number} reserve_id * @param {string} reserve_id
* @returns * @returns
*/ */
async reserve_lottery(reserve_id) { async reserve_lottery(reserve_id) {

View File

@ -4,7 +4,7 @@ const searcher = require("../lib/core/searcher");
const util = require('./util'); const util = require('./util');
(async () => { (async () => {
await util.par_run([0, 1, 2, 3, 4, 5, 6], [ await util.par_run([0, 1, 2, 3, 4, 5, 6, 7, 8], [
// 0 // 0
async () => { async () => {
let info = await bili_client.getOneDynamicByDyid("728424890210713624"); let info = await bili_client.getOneDynamicByDyid("728424890210713624");
@ -12,8 +12,8 @@ const util = require('./util');
}, },
// 1 // 1
async () => { async () => {
// let info = await bili_client.getOneDynamicByDyid("728455586333589522"); let info = await bili_client.getOneDynamicByDyid("768874900850999300");
// assert(searcher.parseDynamicCard(info).origin_is_charge_lottery); assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
}, },
// 2 // 2
async () => { async () => {
@ -50,6 +50,18 @@ const util = require('./util');
const card = searcher.parseDynamicCard(dy) const card = searcher.parseDynamicCard(dy)
assert.notEqual(card.description + "", undefined + ""); assert.notEqual(card.description + "", undefined + "");
}, },
// 7
async () => {
const dy = await bili_client.getOneDynamicByDyid("832208853440397352");
const card = searcher.parseDynamicCard(dy)
assert.equal(card.reserve_id, "3106984");
},
// 8
async () => {
const dy = await bili_client.getOneDynamicByDyid("832966468497834066");
const card = searcher.parseDynamicCard(dy)
assert.equal(card.origin_reserve_id, "3106984");
},
]) ])
console.log("dynamic_card.test ... ok!"); console.log("dynamic_card.test ... ok!");