Skip to content

Commit

Permalink
fix: 充电专属动态 (shanmiteko#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
shanmiteko committed Feb 13, 2023
1 parent bf4e894 commit 82d285e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
24 changes: 15 additions & 9 deletions lib/net/bili.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,22 @@ const bili_client = {
}),
{ code, data } = strToJson(responseText),
{ card } = data || {};
if (code !== 0) {
log.error('获取一个动态的细节', `获取动态(${dynamic_id})数据出错:\n${responseText}`);
return;
}
if (!card) {
log.warn('获取一个动态的细节', `动态(${dynamic_id})不存在`);
return;
switch (code) {
case 0:
if (card) {
log.info('获取一个动态的细节', `动态id(${dynamic_id})`);
return card;
} else {
log.warn('获取一个动态的细节', `动态id(${dynamic_id})不存在`);
return;
}
case 500207:
log.warn('获取一个动态的细节', `动态id(${dynamic_id})该动态为包月充电专属可以给UP主充电后观看`);
return;
default:
log.error('获取一个动态的细节', `获取动态(${dynamic_id})数据出错:\n${responseText}`);
return;
}
log.info('获取一个动态的细节', `动态id(${dynamic_id})`);
return card;
},
/**
* 获取一组动态的信息
Expand Down
11 changes: 7 additions & 4 deletions test/dynamic_card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const searcher = require("../lib/core/searcher");
const util = require('./util');

(async () => {
await util.par_run([0, 1, 2, 3], [
await util.par_run([0, 1, 2, 3, 4], [
// 0
async () => {
let info = await bili_client.getOneDynamicByDyid("728424890210713624");
Expand All @@ -29,10 +29,13 @@ const util = require('./util');
assert(card.chat_type == 17)
assert(card.origin_chat_type == 11)
},
// 4
async () => {
assert.equal(await bili_client.getOneDynamicByDyid("111111111111111111"), undefined);
assert.notEqual(await bili_client.getOneDynamicByDyid("746824225190314008"), undefined);
assert.equal(await bili_client.getOneDynamicByDyid("761475750233636886"), undefined);
},
])




console.log("dynamic_card.test ... ok!");
})()
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const global_var = require("../lib/data/global_var");
const { log } = require('../lib/utils');
const fs = require('fs');

log._level = 1
log._level = 2
env.init()
global_var.init(process.env["COOKIE"], 1)

Expand Down

0 comments on commit 82d285e

Please sign in to comment.