mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
修复哔哩哔哩解析多p时长解析拦截错误 增强对多p标题识别 修复皮皮虾解析错误 修复QQ音乐解析
This commit is contained in:
parent
1e63bf96f2
commit
7642b04ee7
@ -783,11 +783,11 @@ export class tools extends plugin {
|
|||||||
segment.image(user_cover),
|
segment.image(user_cover),
|
||||||
segment.image(keyframe),
|
segment.image(keyframe),
|
||||||
[`${ this.identifyPrefix }识别:哔哩哔哩直播,${ title }`,
|
[`${ this.identifyPrefix }识别:哔哩哔哩直播,${ title }`,
|
||||||
`${ description ? `📝 简述:${ description.replace(`<p>`, '').replace(`</p>`, '') }` : '' }`,
|
`${ description ? `📝 简述:${ description.replace(`<p>`, '').replace(`</p>`, '') }` : '' }`,
|
||||||
`${ tags ? `🔖 标签:${ tags }` : '' }`,
|
`${ tags ? `🔖 标签:${ tags }` : '' }`,
|
||||||
`📍 分区:${ parent_area_name ? `${ parent_area_name }` : '' }${ area_name ? `-${ area_name }` : '' }`,
|
`📍 分区:${ parent_area_name ? `${ parent_area_name }` : '' }${ area_name ? `-${ area_name }` : '' }`,
|
||||||
`${ live_time ? `⏰ 直播时间:${ live_time }` : '' }`,
|
`${ live_time ? `⏰ 直播时间:${ live_time }` : '' }`,
|
||||||
`📺 独立播放器: https://www.bilibili.com/blackboard/live/live-activity-player.html?enterTheRoom=0&cid=${ streamId }`
|
`📺 独立播放器: https://www.bilibili.com/blackboard/live/live-activity-player.html?enterTheRoom=0&cid=${ streamId }`
|
||||||
].filter(item => item.trim() !== "").join("\n")
|
].filter(item => item.trim() !== "").join("\n")
|
||||||
]);
|
]);
|
||||||
const streamData = await this.getBiliStream(streamId);
|
const streamData = await this.getBiliStream(streamId);
|
||||||
@ -825,14 +825,40 @@ export class tools extends plugin {
|
|||||||
// 视频信息获取例子:http://api.bilibili.com/x/web-interface/view?bvid=BV1hY411m7cB
|
// 视频信息获取例子:http://api.bilibili.com/x/web-interface/view?bvid=BV1hY411m7cB
|
||||||
// 请求视频信息
|
// 请求视频信息
|
||||||
const videoInfo = await getVideoInfo(url);
|
const videoInfo = await getVideoInfo(url);
|
||||||
|
// 打印获取到的视频信息,用于调试时长问题
|
||||||
|
logger.debug(`[R插件][Bili Debug] Video Info for ${url}: duration=${videoInfo.duration}, pages=${JSON.stringify(videoInfo.pages)}`);
|
||||||
const { duration, bvid, cid, owner, pages } = videoInfo;
|
const { duration, bvid, cid, owner, pages } = videoInfo;
|
||||||
// 限制时长 & 考虑分页视频情况
|
|
||||||
const query = querystring.parse(url);
|
let durationForCheck;
|
||||||
const curPage = query?.p || 0;
|
let displayTitle = videoInfo.title; // 默认使用总标题
|
||||||
const curDuration = pages?.[curPage]?.duration || duration;
|
let targetPageInfo = null; // 用于后续下载决策
|
||||||
const isLimitDuration = curDuration > this.biliDuration;
|
|
||||||
|
const urlParts = url.split('?');
|
||||||
|
const queryParams = urlParts.length > 1 ? querystring.parse(urlParts[1]) : {};
|
||||||
|
const pParam = queryParams.p ? parseInt(queryParams.p, 10) : null;
|
||||||
|
|
||||||
|
if (pParam && pages && pages.length >= pParam && pParam > 0) {
|
||||||
|
// 如果URL指定了有效的p参数 (p从1开始计数)
|
||||||
|
targetPageInfo = pages[pParam - 1];
|
||||||
|
durationForCheck = targetPageInfo.duration;
|
||||||
|
displayTitle = targetPageInfo.part;
|
||||||
|
logger.info(`[R插件][Bili Duration] 分析到合集 P${pParam} (标题: ${displayTitle}), 时长: ${durationForCheck}s`);
|
||||||
|
} else if (pages && pages.length > 0) {
|
||||||
|
// 否则,如果存在分P,默认检查第一个分P
|
||||||
|
targetPageInfo = pages[0];
|
||||||
|
durationForCheck = targetPageInfo.duration;
|
||||||
|
displayTitle = targetPageInfo.part;
|
||||||
|
logger.info(`[R插件][Bili Duration] 分析到合集 P1 (标题: ${displayTitle}), 时长: ${durationForCheck}s`);
|
||||||
|
} else {
|
||||||
|
// 如果没有分P信息(或pages为空),使用总时长
|
||||||
|
durationForCheck = duration;
|
||||||
|
// displayTitle 保持为 videoInfo.title
|
||||||
|
logger.info(`[R插件][Bili Duration] Using total duration (Title: ${displayTitle}): ${durationForCheck}s`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const isLimitDuration = durationForCheck > this.biliDuration;
|
||||||
// 动态构造哔哩哔哩信息
|
// 动态构造哔哩哔哩信息
|
||||||
let biliInfo = await this.constructBiliInfo(videoInfo);
|
let biliInfo = await this.constructBiliInfo(videoInfo, displayTitle);
|
||||||
// 总结
|
// 总结
|
||||||
if (this.biliDisplaySummary) {
|
if (this.biliDisplaySummary) {
|
||||||
const summary = await this.getBiliSummary(bvid, cid, owner.mid);
|
const summary = await this.getBiliSummary(bvid, cid, owner.mid);
|
||||||
@ -841,7 +867,7 @@ export class tools extends plugin {
|
|||||||
}
|
}
|
||||||
// 限制视频解析
|
// 限制视频解析
|
||||||
if (isLimitDuration) {
|
if (isLimitDuration) {
|
||||||
const durationInMinutes = (curDuration / 60).toFixed(0);
|
const durationInMinutes = (durationForCheck / 60).toFixed(0); // 使用 durationForCheck
|
||||||
biliInfo.push(`${ DIVIDING_LINE.replace('{}', '限制说明') }\n当前视频时长约:${ durationInMinutes }分钟,\n大于管理员设置的最大时长 ${ (this.biliDuration / 60).toFixed(2).replace(/\.00$/, '') } 分钟!`);
|
biliInfo.push(`${ DIVIDING_LINE.replace('{}', '限制说明') }\n当前视频时长约:${ durationInMinutes }分钟,\n大于管理员设置的最大时长 ${ (this.biliDuration / 60).toFixed(2).replace(/\.00$/, '') } 分钟!`);
|
||||||
e.reply(biliInfo);
|
e.reply(biliInfo);
|
||||||
return true;
|
return true;
|
||||||
@ -893,8 +919,8 @@ export class tools extends plugin {
|
|||||||
* @param videoInfo
|
* @param videoInfo
|
||||||
* @returns {Promise<(string|string)[]>}
|
* @returns {Promise<(string|string)[]>}
|
||||||
*/
|
*/
|
||||||
async constructBiliInfo(videoInfo) {
|
async constructBiliInfo(videoInfo, displayTitle) { // displayTitle 参数
|
||||||
const { title, desc, bvid, cid, pic } = videoInfo;
|
const { desc, bvid, cid, pic } = videoInfo; // 移除了 title
|
||||||
// 视频信息
|
// 视频信息
|
||||||
const { view, danmaku, reply, favorite, coin, share, like } = videoInfo.stat;
|
const { view, danmaku, reply, favorite, coin, share, like } = videoInfo.stat;
|
||||||
// 格式化数据
|
// 格式化数据
|
||||||
@ -925,7 +951,7 @@ export class tools extends plugin {
|
|||||||
const onlineTotal = await this.biliOnlineTotal(bvid, cid);
|
const onlineTotal = await this.biliOnlineTotal(bvid, cid);
|
||||||
combineContent += `\n🏄♂️️ 当前视频有 ${ onlineTotal.total } 人在观看,其中 ${ onlineTotal.count } 人在网页端观看`;
|
combineContent += `\n🏄♂️️ 当前视频有 ${ onlineTotal.total } 人在观看,其中 ${ onlineTotal.count } 人在网页端观看`;
|
||||||
}
|
}
|
||||||
let biliInfo = [`${ this.identifyPrefix }识别:哔哩哔哩,${ title }`, combineContent];
|
let biliInfo = [`${ this.identifyPrefix }识别:哔哩哔哩,${ displayTitle }`, combineContent]; // 使用 displayTitle
|
||||||
// 是否显示封面
|
// 是否显示封面
|
||||||
if (this.biliDisplayCover) {
|
if (this.biliDisplayCover) {
|
||||||
// 加入图片
|
// 加入图片
|
||||||
@ -1119,13 +1145,14 @@ export class tools extends plugin {
|
|||||||
logger.info(summaryUrl);
|
logger.info(summaryUrl);
|
||||||
// 构造结果:https://api.bilibili.com/x/web-interface/view/conclusion/get?bvid=BV1L94y1H7CV&cid=1335073288&up_mid=297242063&wts=1701546363&w_rid=1073871926b3ccd99bd790f0162af634
|
// 构造结果:https://api.bilibili.com/x/web-interface/view/conclusion/get?bvid=BV1L94y1H7CV&cid=1335073288&up_mid=297242063&wts=1701546363&w_rid=1073871926b3ccd99bd790f0162af634
|
||||||
return axios.get(summaryUrl, {
|
return axios.get(summaryUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
Cookie: `SESSDATA=${ this.biliSessData }`
|
Cookie: `SESSDATA=${ this.biliSessData }`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
const data = resp.data.data?.model_result;
|
logger.debug(resp)
|
||||||
// logger.info(data)
|
const data = resp.data.data?.model_result;
|
||||||
|
logger.debug(data)
|
||||||
const summary = data?.summary;
|
const summary = data?.summary;
|
||||||
const outline = data?.outline;
|
const outline = data?.outline;
|
||||||
let resReply = "";
|
let resReply = "";
|
||||||
@ -2056,9 +2083,21 @@ export class tools extends plugin {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const adapter = await GeneralLinkAdapter.create(e.msg);
|
const adapter = await GeneralLinkAdapter.create(e.msg);
|
||||||
|
logger.debug(`[R插件][General Adapter Debug] Adapter object: ${JSON.stringify(adapter, null, 2)}`);
|
||||||
e.reply(`${ this.identifyPrefix }识别:${ adapter.name }${ adapter.desc ? `, ${ adapter.desc }` : '' }`);
|
e.reply(`${ this.identifyPrefix }识别:${ adapter.name }${ adapter.desc ? `, ${ adapter.desc }` : '' }`);
|
||||||
logger.mark(adapter);
|
logger.debug(adapter);
|
||||||
if (adapter.images && adapter.images.length > 0) {
|
logger.debug(`[R插件][General Adapter Debug] adapter.images: ${JSON.stringify(adapter.images)}`);
|
||||||
|
logger.debug(`[R插件][General Adapter Debug] adapter.video: ${adapter.video}`);
|
||||||
|
if (adapter.video && adapter.video !== '') {
|
||||||
|
logger.debug(`[R插件][General Adapter Debug] Entering video sending logic for ${adapter.name}. Video URL: ${adapter.video}`);
|
||||||
|
// 视频:https://www.kuaishou.com/short-video/3xhjgcmir24m4nm
|
||||||
|
const url = adapter.video;
|
||||||
|
this.downloadVideo(url).then(path => {
|
||||||
|
logger.debug(`[R插件][General Adapter Debug] Video downloaded to path: ${path}`);
|
||||||
|
this.sendVideoToUpload(e, `${ path }/temp.mp4`);
|
||||||
|
});
|
||||||
|
} else if (adapter.images && adapter.images.length > 0) {
|
||||||
|
logger.debug(`[R插件][General Adapter Debug] Entering image sending logic for ${adapter.name}`);
|
||||||
const images = adapter.images.map(item => {
|
const images = adapter.images.map(item => {
|
||||||
return {
|
return {
|
||||||
message: segment.image(item),
|
message: segment.image(item),
|
||||||
@ -2067,14 +2106,8 @@ export class tools extends plugin {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
e.reply(Bot.makeForwardMsg(images));
|
e.reply(Bot.makeForwardMsg(images));
|
||||||
} else if (adapter.video && adapter.video !== '') {
|
|
||||||
// 视频:https://www.kuaishou.com/short-video/3xhjgcmir24m4nm
|
|
||||||
const url = adapter.video;
|
|
||||||
this.downloadVideo(url).then(path => {
|
|
||||||
logger.info(path);
|
|
||||||
this.sendVideoToUpload(e, `${ path }/temp.mp4`);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
|
logger.debug(`[R插件][General Adapter Debug] No images or video found for ${adapter.name}. Replying with failure message.`);
|
||||||
e.reply("解析失败:无法获取到资源");
|
e.reply("解析失败:无法获取到资源");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -2536,7 +2569,6 @@ export class tools extends plugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
logger.info(`[R插件][qqMusic] 识别音乐为:${ musicInfo }`);
|
logger.info(`[R插件][qqMusic] 识别音乐为:${ musicInfo }`);
|
||||||
|
|
||||||
// 使用临时接口下载
|
// 使用临时接口下载
|
||||||
const url = await this.musicTempApi(e, musicInfo, "QQ音乐");
|
const url = await this.musicTempApi(e, musicInfo, "QQ音乐");
|
||||||
// 下载音乐
|
// 下载音乐
|
||||||
|
Loading…
x
Reference in New Issue
Block a user