diff --git a/apps/tools.js b/apps/tools.js index e6a0d92..8453bdb 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -321,16 +321,19 @@ export class tools extends plugin { // av处理 const matched = url.match(/\/(AV|av)(\w+)/); if (matched) { - url = url.replace(matched[0], av2BV(Number(matched[2]))); + url = url.replace(matched[0].replace("\/", ""), av2BV(Number(matched[2]))); } // 只提取音乐处理 if (e.msg !== undefined && e.msg.includes("bili音乐")) { - await this.biliMusic(e, url); - return true; + return await this.biliMusic(e, url); } // 动态处理 - if (url.includes("t.bilibili.com")) { - url = this.biliDynamic(url, e); + if (url.includes("t.bilibili.com") || url.includes("bilibili.com\/opus")) { + if (_.isEmpty(this.biliSessData)) { + e.reply("检测到没有填写biliSessData,无法解析动态"); + return true; + } + url = this.biliDynamic(e, url, this.biliSessData); return true; } // 视频信息获取例子:http://api.bilibili.com/x/web-interface/view?bvid=BV1hY411m7cB @@ -407,13 +410,13 @@ export class tools extends plugin { } // 发送哔哩哔哩动态的算法 - biliDynamic(url, e) { + biliDynamic(e, url, session) { // 去除多余参数 if (url.includes("?")) { url = url.substring(0, url.indexOf("?")); } const dynamicId = /[^/]+(?!.*\/)/.exec(url)[0]; - getDynamic(dynamicId).then(async resp => { + getDynamic(dynamicId, session).then(async resp => { if (resp.dynamicSrc.length > 0) { e.reply(`识别:哔哩哔哩动态, ${ resp.dynamicDesc }`); let dynamicSrcMsg = []; diff --git a/config/version.yaml b/config/version.yaml index 984a807..ca7c2ed 100644 --- a/config/version.yaml +++ b/config/version.yaml @@ -1,5 +1,5 @@ - { - version: 1.3.4, + version: 1.3.5, data: [ 新增🍉解析功能, diff --git a/constants/tools.js b/constants/tools.js index 543188c..a8858ef 100644 --- a/constants/tools.js +++ b/constants/tools.js @@ -14,7 +14,7 @@ export const BILI_PLAY_STREAM = "https://api.bilibili.com/x/player/playurl?cid={ /** * 动态信息 - * https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/dynamic/content.md + * https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/dynamic/get_dynamic_detail.md * @type {string} */ export const BILI_DYNAMIC = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail?dynamic_id={}" diff --git a/utils/bilibili.js b/utils/bilibili.js index 2951c10..4099c75 100644 --- a/utils/bilibili.js +++ b/utils/bilibili.js @@ -227,14 +227,15 @@ export async function getVideoInfo(url) { * @param dynamicId * @returns {Promise} */ -export async function getDynamic(dynamicId) { +export async function getDynamic(dynamicId, SESSDATA) { const dynamicApi = BILI_DYNAMIC.replace("{}", dynamicId); return axios.get(dynamicApi, { headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36', 'referer': 'https://www.bilibili.com', - } + Cookie: `SESSDATA=${ SESSDATA }` + }, }).then(resp => { const dynamicData = resp.data.data.card const card = JSON.parse(dynamicData.card)