mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
parent
b6c56c5061
commit
ad6af9705f
@ -427,11 +427,14 @@ class Searcher {
|
||||
const
|
||||
content = await bili.getOneArticleByCv(id),
|
||||
dyids = content.match(/(?<=t.bilibili.com\/)[0-9]+/g) || [],
|
||||
dyids_set = [...new Set(dyids)],
|
||||
short_ids = content.match(/(?<=b23.tv\/)[a-zA-Z0-9]{7}/g) || [],
|
||||
short_id_set = [...new Set(short_ids)],
|
||||
short_ids_to_dyids = await Promise.all(short_id_set.map(bili.shortDynamicIdToDyid)),
|
||||
dyid_set = [...new Set([...dyids, ...short_ids_to_dyids])],
|
||||
/**判断此专栏是否查看过的权重 */
|
||||
weight = dyids_set.length / 2;
|
||||
weight = dyid_set.length / 2;
|
||||
|
||||
let { length } = dyids_set,
|
||||
let { length } = dyid_set,
|
||||
/**初始权重 */
|
||||
_weight = 0,
|
||||
/**单个专栏中的dyid */
|
||||
@ -439,8 +442,9 @@ class Searcher {
|
||||
log.info('获取动态', `提取专栏(${id})中提及的dyid(${length})`)
|
||||
|
||||
/**遍历某专栏中的dyids */
|
||||
for (const dyid of dyids_set) {
|
||||
if (dyid.length === utils.dyid_length) {
|
||||
for (const dyid of dyid_set) {
|
||||
if (typeof dyid === "string"
|
||||
&& dyid.length === utils.dyid_length) {
|
||||
|
||||
log.info('获取动态', `查看专栏中所提及动态(${dyid}) (${length--})`)
|
||||
const card = await bili.getOneDynamicByDyid(dyid)
|
||||
|
||||
@ -32,6 +32,7 @@ module.exports = Object.freeze({
|
||||
SESSION_SVR_GET_SESSIONS: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions',
|
||||
SESSION_SVR_SINGLE_UNREAD: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread',
|
||||
SESSION_SVR_UPDATE_ACK: 'https://api.vc.bilibili.com/session_svr/v1/session_svr/update_ack',
|
||||
SHORTLINK: 'https://b23.tv/{{short_id}}',
|
||||
SPACE_MYINFO: 'https://api.bilibili.com/x/space/myinfo',
|
||||
TAG_INFO: 'https://api.bilibili.com/x/tag/info',
|
||||
TOP_FEED_RCMD: "https://api.bilibili.com/x/web-interface/index/top/feed/rcmd",
|
||||
|
||||
@ -378,6 +378,22 @@ const bili_client = {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {string} short_id
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async shortDynamicIdToDyid(short_id) {
|
||||
return get({
|
||||
url: API.SHORTLINK.replace('{{short_id}}', short_id),
|
||||
config: {
|
||||
redirect: false,
|
||||
}
|
||||
}).then(a => {
|
||||
const dyid = (a.match(/[0-9]{18}/) || [])[0];
|
||||
log.info("短连接转换", `${short_id} -> ${dyid}`)
|
||||
return dyid
|
||||
})
|
||||
},
|
||||
_getOneDynamicByDyid: new Line('获取一个动态的细节', [
|
||||
(dynamic_id) => get({
|
||||
url: API.DYNAMIC_SVR_GET_DYNAMIC_DETAIL_V2,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
const assert = require('assert');
|
||||
const bili_client = require("../lib/net/bili");
|
||||
const searcher = require("../lib/core/searcher");
|
||||
const util = require('./util');
|
||||
|
||||
(async () => {
|
||||
@ -8,9 +7,9 @@ const util = require('./util');
|
||||
// 0
|
||||
async () => {
|
||||
let info = await bili_client.getOneArticleByCv(22112353);
|
||||
console.log(info);
|
||||
let short_ids = [...new Set(info.match(/(?<=b23.tv\/)[a-zA-Z0-9]{7}/g) || [])];
|
||||
assert.equal((await Promise.all(short_ids.map(bili_client.shortDynamicIdToDyid)))[0], "767357823884460033");
|
||||
},
|
||||
])
|
||||
|
||||
console.log("article.test ... ok!");
|
||||
})()
|
||||
Loading…
Reference in New Issue
Block a user