mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
Merge pull request #66 from CSSZYF/master
修复哔哩哔哩多p时长拦截错误 增加多p标题识别 更换QQ音乐解析api
This commit is contained in:
commit
a18f1b1df2
@ -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) {
|
||||||
// 加入图片
|
// 加入图片
|
||||||
@ -1124,8 +1150,9 @@ export class tools extends plugin {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
|
logger.debug(resp)
|
||||||
const data = resp.data.data?.model_result;
|
const data = resp.data.data?.model_result;
|
||||||
// logger.info(data)
|
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音乐");
|
||||||
// 下载音乐
|
// 下载音乐
|
||||||
|
@ -210,7 +210,7 @@ export const NETEASE_TEMP_API = "https://www.hhlqilongzhu.cn/api/dg_wyymusic.php
|
|||||||
* 备用:https://www.hhlqilongzhu.cn/api/dg_qqmusic.php?gm={}&n=1&type=json
|
* 备用:https://www.hhlqilongzhu.cn/api/dg_qqmusic.php?gm={}&n=1&type=json
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
export const QQ_MUSIC_TEMP_API = "https://www.hhlqilongzhu.cn/api/dg_shenmiMusic_SQ.php?msg={}&n=1&type=json";
|
export const QQ_MUSIC_TEMP_API = "https://www.hhlqilongzhu.cn/api/dg_QQmusicflac.php?msg={}&n=1&type=json";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载VIP的临时接口3
|
* 下载VIP的临时接口3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user