From 57c5d2b453925c5f4335e6fea34067e27c716fc9 Mon Sep 17 00:00:00 2001 From: zhiyu <542716863@qq.com> Date: Tue, 13 Feb 2024 22:09:33 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20V1.3.5=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dbili=E8=A7=A3=E6=9E=90AV=E8=A7=86=E9=A2=91=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20&=20=E9=80=82=E9=85=8D=E7=BD=91=E9=A1=B5?= =?UTF-8?q?=E7=AB=AF=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修复了bili解析AV视频问题(eg. 【av565798707?p=1&unique_k=114514),感谢Mix在群里提供issue 2. 适配网页端的bili动态 3. 修复bili动态无法使用的问题,感谢Mix在群里提供issue --- apps/tools.js | 17 ++++++++++------- config/version.yaml | 2 +- constants/tools.js | 2 +- utils/bilibili.js | 5 +++-- 4 files changed, 15 insertions(+), 11 deletions(-) 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)