From 28b106fa93bee6f4f45cbe205125e2b7f5579f7a Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Fri, 24 Mar 2023 09:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=93=94=E5=93=A9=E5=93=94=E5=93=A9=E6=80=BB=E7=BB=93=E7=9A=84?= =?UTF-8?q?=E9=83=A8=E5=88=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 2 +- utils/biliSummary.js | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 3272ed5..1a65aab 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -355,7 +355,7 @@ export class tools extends plugin { if (this.biliSessData && this.openaiApiKey) { let prompt; try { - prompt = await getBiliGptInputText(title, aid, cid); + prompt = await getBiliGptInputText(title, aid, cid, this.biliSessData); } catch (err) { logger.error("总结失败,可能是没有弹幕或者网络问题!"); return true; diff --git a/utils/biliSummary.js b/utils/biliSummary.js index 5710a1b..2e1385e 100644 --- a/utils/biliSummary.js +++ b/utils/biliSummary.js @@ -1,27 +1,27 @@ -const headers = { - Accept: "application/json", - "Content-Type": "application/json", - "User-Agent": - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36", - Host: "api.bilibili.com", - Cookie: `SESSDATA=92ce67f8%2C1695139091%2C5151e%2A31`, -}; -const commonConfig = { - method: "GET", - cache: "no-cache", - headers, - referrerPolicy: "no-referrer", -}; - /** * 获取gpt提取视频信息的文字 * @param title 视频标题 * @param aid * @param cid + * @param biliSessData * @param shouldShowTimestamp 是否在每段字幕前面加入时间标识 * @returns {Promise} */ -export async function getBiliGptInputText(title, aid, cid, shouldShowTimestamp = false) { +export async function getBiliGptInputText(title, aid, cid, biliSessData, shouldShowTimestamp = false) { + const headers = { + Accept: "application/json", + "Content-Type": "application/json", + "User-Agent": + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36", + Host: "api.bilibili.com", + Cookie: `SESSDATA=${biliSessData}`, + }; + const commonConfig = { + method: "GET", + cache: "no-cache", + headers, + referrerPolicy: "no-referrer", + }; // https://api.bilibili.com/x/player/v2?aid=438937138&cid=1066979272 const resp = await fetch( `https://api.bilibili.com/x/player/v2?aid=${aid}&cid=${cid}`,