Skip to content

Commit

Permalink
fix: 预约抽奖包月抽奖识别异常 (#288)
Browse files Browse the repository at this point in the history
Fixed #288
  • Loading branch information
shanmiteko committed Aug 23, 2023
1 parent da8d460 commit 2f2eaab
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
nodev: 18
- platform: win
nodev: 18
- platform: win
nodev: 12
# - platform: win
# nodev: 12
steps:
- name: "Checkout codes"
uses: actions/checkout@v3
Expand Down
23 changes: 20 additions & 3 deletions lib/core/searcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,15 @@ function parseDynamicCard(dynamic_detail_card) {
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
}
/* 是否有官方抽奖 */
Expand All @@ -119,9 +127,10 @@ function parseDynamicCard(dynamic_detail_card) {
|| '';
/* 转发 */
if (obj.type === 1) {
const { origin_extension, origin } = cardToJson
const { origin_extension, origin, origin_extend_json } = cardToJson
, originToJson = strToJson(origin)
, { add_on_card_info = [] } = display.origin || {}
, originExtendjsonToJson = strToJson(origin_extend_json)
, { user, item } = originToJson;
/* 源动态的ts10 */
obj.origin_create_time = desc.origin.timestamp;
Expand Down Expand Up @@ -150,7 +159,15 @@ function parseDynamicCard(dynamic_detail_card) {
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
}
/* 是否有官方抽奖 */
Expand Down
2 changes: 1 addition & 1 deletion lib/net/bili.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ const bili_client = {
},
/**
* 预约抽奖
* @param {number} reserve_id
* @param {string} reserve_id
* @returns
*/
async reserve_lottery(reserve_id) {
Expand Down
18 changes: 15 additions & 3 deletions test/dynamic_card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ const searcher = require("../lib/core/searcher");
const util = require('./util');

(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
async () => {
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
assert(searcher.parseDynamicCard(info).is_charge_lottery);
},
// 1
async () => {
// let info = await bili_client.getOneDynamicByDyid("728455586333589522");
// assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
let info = await bili_client.getOneDynamicByDyid("768874900850999300");
assert(searcher.parseDynamicCard(info).origin_is_charge_lottery);
},
// 2
async () => {
Expand Down Expand Up @@ -50,6 +50,18 @@ const util = require('./util');
const card = searcher.parseDynamicCard(dy)
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!");
Expand Down

0 comments on commit 2f2eaab

Please sign in to comment.