mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
🐞 fix: V1.5.3 修复miyoushe解析问题 & weibo解析问题
1. 修复weibo解析中部分视频无法解析的问题(🌸感谢Mix群友在群里提供测试样例和问题) 2. 修复miyoushe中无法解析部分视频的问题(🌸感谢群友湘潭在群里提供测试样例和问题)
This commit is contained in:
parent
c123d68537
commit
fb57635f4c
@ -965,7 +965,7 @@ export class tools extends plugin {
|
||||
if (pics) {
|
||||
// 图片
|
||||
const images = pics.map(item => ({
|
||||
message: segment.image(item.url),
|
||||
message: segment.image(item?.large.url || item.url),
|
||||
nickname: e.sender.card || e.user_id,
|
||||
user_id: e.user_id,
|
||||
}));
|
||||
@ -975,7 +975,12 @@ export class tools extends plugin {
|
||||
// 视频
|
||||
const videoUrl = page_info.urls?.mp4_720p_mp4 || page_info.urls?.mp4_hd_mp4;
|
||||
try {
|
||||
this.downloadVideo(videoUrl).then(path => {
|
||||
this.downloadVideo(videoUrl, false, {
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36",
|
||||
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
||||
"referer": "https://weibo.com/",
|
||||
}).then(path => {
|
||||
e.reply(segment.video(path + "/temp.mp4"));
|
||||
});
|
||||
} catch (err) {
|
||||
@ -1153,9 +1158,18 @@ export class tools extends plugin {
|
||||
}
|
||||
}).then(async resp => {
|
||||
const respJson = await resp.json();
|
||||
// debug专用
|
||||
// fs.writeFile('data.json', JSON.stringify(respJson), (err) => {
|
||||
// if (err) {
|
||||
// console.error('Error writing file:', err);
|
||||
// } else {
|
||||
// console.log('JSON saved to file successfully.');
|
||||
// }
|
||||
// });
|
||||
// return;
|
||||
const data = respJson.data.post.post;
|
||||
// 分别获取:封面、主题、内容、图片
|
||||
const { cover, subject, content, images, structured_content } = data;
|
||||
const { cover, subject, content, images } = data;
|
||||
let realContent = "";
|
||||
// safe JSON.parse
|
||||
try {
|
||||
@ -1178,15 +1192,14 @@ export class tools extends plugin {
|
||||
e.reply(Bot.makeForwardMsg(replyImages));
|
||||
}
|
||||
// 视频
|
||||
const sc = JSON.parse(structured_content);
|
||||
logger.info(sc.length)
|
||||
if (sc?.[0]?.insert.vod.resolutions) {
|
||||
let vod_list = respJson.data.post?.vod_list;
|
||||
if (vod_list.length > 0) {
|
||||
const resolutions = vod_list?.[0]?.resolutions;
|
||||
// 逐个遍历是否包含url
|
||||
for (let i = 0; i < sc.length; i++) {
|
||||
const resolutions = sc?.[i]?.insert.vod.resolutions;
|
||||
for (let i = 0; i < resolutions.length; i++) {
|
||||
if (resolutions) {
|
||||
// 暂时选取分辨率较低的video进行解析
|
||||
const videoUrl = resolutions[0].url;
|
||||
const videoUrl = resolutions[i].url;
|
||||
this.downloadVideo(videoUrl).then(path => {
|
||||
e.reply(segment.video(path + "/temp.mp4"));
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
- {
|
||||
version: 1.5.2,
|
||||
version: 1.5.3,
|
||||
data:
|
||||
[
|
||||
新增<span class="cmd">微博解析</span>功能,
|
||||
|
Loading…
x
Reference in New Issue
Block a user