feat: V1.5.0 新增最右解析

1. 新增最右解析
2. 增加适配器,更改ks、xigua、最右为通用解析,为下一步扩展解析业务做准备
3. 修改了一些bug
This commit is contained in:
zhiyu1998 2024-03-02 11:11:10 +08:00
parent ce2729d5c6
commit 0a6a668dcc
6 changed files with 122 additions and 92 deletions

View File

@ -45,17 +45,18 @@ import { getWbi } from "../utils/biliWbi.js";
import { import {
BILI_SUMMARY, BILI_SUMMARY,
DY_INFO, DY_INFO,
MIYOUSHE_ARTICLE, MIYOUSHE_ARTICLE, NETEASE_SONG_DETAIL, NETEASE_SONG_DOWNLOAD,
TIKTOK_INFO, TIKTOK_INFO,
TWITTER_TWEET_INFO, TWITTER_TWEET_INFO,
XHS_REQ_LINK, XHS_REQ_LINK,
XHS_VIDEO, XHS_VIDEO,
XIGUA_REQ_LINK GENERAL_REQ_LINK
} from "../constants/tools.js"; } from "../constants/tools.js";
import child_process from 'node:child_process' import child_process from 'node:child_process'
import { getAudio, getVideo } from "../utils/y2b.js"; import { getAudio, getVideo } from "../utils/y2b.js";
import { processTikTokUrl } from "../utils/tiktok.js"; import { processTikTokUrl } from "../utils/tiktok.js";
import { getDS } from "../utils/mihoyo.js"; import { getDS } from "../utils/mihoyo.js";
import GeneralLinkAdapter from "../utils/general-link-adapter.js";
export class tools extends plugin { export class tools extends plugin {
/** /**
@ -129,17 +130,13 @@ export class tools extends plugin {
fnc: "bodianMusic", fnc: "bodianMusic",
}, },
{ {
reg: "(kuaishou.com)", reg: "(kuaishou.com|ixigua.com|share.xiaochuankeji.cn)",
fnc: "kuaishou", fnc: "general",
}, },
{ {
reg: "(youtube.com)", reg: "(youtube.com)",
fnc: "y2b" fnc: "y2b"
}, },
{
reg: "(ixigua.com)",
fnc: "xigua"
},
{ {
reg: "(miyoushe.com)", reg: "(miyoushe.com)",
fnc: "miyoushe" fnc: "miyoushe"
@ -147,7 +144,7 @@ export class tools extends plugin {
{ {
reg: "(music.163.com|163cn.tv)", reg: "(music.163.com|163cn.tv)",
fnc: "netease", fnc: "netease",
} },
], ],
}); });
// 配置文件 // 配置文件
@ -579,7 +576,7 @@ export class tools extends plugin {
const reg = /https?:\/\/x.com\/[0-9-a-zA-Z_]{1,20}\/status\/([0-9]*)/; const reg = /https?:\/\/x.com\/[0-9-a-zA-Z_]{1,20}\/status\/([0-9]*)/;
const twitterUrl = reg.exec(e.msg)[0]; const twitterUrl = reg.exec(e.msg)[0];
// 提取视频 // 提取视频
const videoUrl = XIGUA_REQ_LINK.replace("{}", twitterUrl); const videoUrl = GENERAL_REQ_LINK.replace("{}", twitterUrl);
e.reply("识别:小蓝鸟"); e.reply("识别:小蓝鸟");
axios.get(videoUrl, { axios.get(videoUrl, {
headers: { headers: {
@ -903,18 +900,24 @@ export class tools extends plugin {
JSON.parse(message); JSON.parse(message);
return true; return true;
} catch (err) { } catch (err) {
axios.get(`https://www.oranges1.top/neteaseapi.do/song/url?id=${id}`, { axios.get(NETEASE_SONG_DOWNLOAD.replace("{}", id), {
headers: { headers: {
"User-Agent": "User-Agent":
"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36", "Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Mobile Safari/537.36",
}, },
}).then(async resp => { }).then(async resp => {
const url = await resp.data.data?.[0].url; const url = await resp.data.data?.[0].url;
const title = await axios.get(`https://www.oranges1.top/neteaseapi.do/song/detail?ids=${id}`).then(res => { // 获取歌曲信息
const title = await axios.get(NETEASE_SONG_DETAIL.replace("{}", id)).then(res => {
const song = res.data.songs[0]; const song = res.data.songs[0];
return `${song?.name}-${song?.ar?.[0].name}`.replace(/[\/\?<>\\:\*\|".… ]/g, ""); return `${song?.name}-${song?.ar?.[0].name}`.replace(/[\/\?<>\\:\*\|".… ]/g, "");
}); });
e.reply(`识别:网易云音乐,${title}`); e.reply(`识别:网易云音乐,${title}`);
// const mvUrlJson = await getKugouMv(title, 1, 1, 0);
// const mvUrl = mvUrlJson.map(item => item.mv_url)?.[0];
// this.downloadVideo(mvUrl).then(path => {
// e.reply(segment.video(path + "/temp.mp4"));
// });
downloadMp3(url, 'follow').then(path => { downloadMp3(url, 'follow').then(path => {
Bot.acquireGfs(e.group_id).upload(fs.readFileSync(path), '/', `${title.replace(/[\/\?<>\\:\*\|".… ]/g, '')}.mp3`) Bot.acquireGfs(e.group_id).upload(fs.readFileSync(path), '/', `${title.replace(/[\/\?<>\\:\*\|".… ]/g, '')}.mp3`)
}) })
@ -927,41 +930,17 @@ export class tools extends plugin {
} }
/** /**
* 快手解析 * 通用解析
* @param e * @param e
* @return {Promise<void>} * @return {Promise<void>}
*/ */
async kuaishou(e) { async general(e) {
// 例子https://www.kuaishou.com/short-video/3xkfs8p4pnd67p4?authorId=3xkznsztpwetngu&streamSource=find&area=homexxbrilliant const linkAdapter = new GeneralLinkAdapter(e.msg);
// https://v.m.chenzhongtech.com/fw/photo/3xburnkmj3auazc const adapter = await linkAdapter.build();
// https://v.kuaishou.com/1ff8QP logger.info(adapter.link)
let msg = /(?:https?:\/\/)?(www|v)\.kuaishou\.com\/[A-Za-z\d._?%&+\-=\/#]*/g.exec(e.msg)[0]; e.reply(`识别:${adapter.name}`);
// 跳转短号
if (msg.includes("v.kuaishou")) {
await fetch(msg, {
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
}
}).then(resp => {
msg = resp.url;
})
}
logger.info(msg)
let video_id;
if (msg.includes('/fw/photo/')) {
video_id = msg.match(/\/fw\/photo\/([^/?]+)/)[1];
} else if (msg.includes("short-video")) {
video_id = msg.match(/short-video\/([^/?]+)/)[1];
} else {
e.reply("无法提取快手的信息,请重试或者换一个视频!")
return
}
// 提取视频
const videoUrl = XIGUA_REQ_LINK.replace("{}", `https://www.kuaishou.com/short-video/${ video_id }`);
e.reply("识别:快手");
// 发送GET请求 // 发送GET请求
axios.get(videoUrl, { axios.get(adapter.link, {
headers: { headers: {
'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.7', '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.7',
'Accept-Language': 'zh-CN,zh;q=0.9', 'Accept-Language': 'zh-CN,zh;q=0.9',
@ -1098,52 +1077,6 @@ export class tools extends plugin {
} }
} }
async xigua(e) {
// 1. https://v.ixigua.com/ienrQ5bR/
// 2. https://www.ixigua.com/7270448082586698281
// 3. https://m.ixigua.com/video/7270448082586698281
let msg = /(?:https?:\/\/)?(www|v|m)\.ixigua\.com\/[A-Za-z\d._?%&+\-=\/#]*/g.exec(e.msg)[0];
// 跳转短号
if (msg.includes("v.ixigua")) {
await fetch(msg, {
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
}
}).then(resp => {
msg = resp.url;
})
}
e.reply("识别:🍉视频");
const id = /ixigua\.com\/(\d+)/.exec(msg)[1] || /\/video\/(\d+)/.exec(msg)[1];
const videoReq = `https://www.ixigua.com/${ id }`;
const xiguaHeader = {
'authority': 'ib.365yg.com',
'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.7',
'accept-language': 'zh-CN,zh;q=0.9',
'cache-control': 'no-cache',
'pragma': 'no-cache',
'sec-ch-ua': '"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'none',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'
}
axios.get(XIGUA_REQ_LINK.replace("{}", videoReq), {
headers: xiguaHeader
}).then(resp => {
const url = resp.data.data.url;
this.downloadVideo(url).then(path => {
e.reply(segment.video(path + "/temp.mp4"));
});
})
return true
}
// 米游社 // 米游社
async miyoushe(e) { async miyoushe(e) {
let msg = /(?:https?:\/\/)?(m|www)\.miyoushe\.com\/[A-Za-z\d._?%&+\-=\/#]*/.exec(e.msg)[0]; let msg = /(?:https?:\/\/)?(m|www)\.miyoushe\.com\/[A-Za-z\d._?%&+\-=\/#]*/.exec(e.msg)[0];

View File

@ -62,6 +62,9 @@
- icon: miyoushe - icon: miyoushe
title: "米游社" title: "米游社"
desc: 米游社文章分享实时下载 desc: 米游社文章分享实时下载
- icon: zuiyou
title: "最右(测试阶段)"
desc: 最右分享实时下载
- icon: literature - icon: literature
title: "论文" title: "论文"
desc: SCI论文实时解析 desc: SCI论文实时解析
@ -78,4 +81,4 @@
desc: "进行更新R插件" desc: "进行更新R插件"
- icon: computer - icon: computer
title: "【实验指令】#ocr" title: "【实验指令】#ocr"
desc: "基于gpt的识图总结" desc: "基于gpt的识图总结"

View File

@ -1,5 +1,5 @@
- { - {
version: 1.4.5, version: 1.5.0,
data: data:
[ [
新增<span class="cmd">米游社解析</span>功能, 新增<span class="cmd">米游社解析</span>功能,

View File

@ -81,4 +81,16 @@ export const XHS_REQ_LINK = "https://www.xiaohongshu.com/explore/"
* 🍉 的请求链接 * 🍉 的请求链接
* @type {string} * @type {string}
*/ */
export const XIGUA_REQ_LINK = "http://47.99.158.118/video-crack/v2/parse?content={}" export const GENERAL_REQ_LINK = "http://47.99.158.118/video-crack/v2/parse?content={}"
/**
* 获取网易云歌曲下载链接
* @type {string}
*/
export const NETEASE_SONG_DOWNLOAD = "https://www.oranges1.top/neteaseapi.do/song/url?id={}"
/**
* 获取网易云歌曲详情
* @type {string}
*/
export const NETEASE_SONG_DETAIL = "https://www.oranges1.top/neteaseapi.do/song/detail?ids={}"

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,82 @@
import { GENERAL_REQ_LINK } from "../constants/tools.js";
/**
* 第三方接口适配器用户大面积覆盖解析视频的内容
*/
class GeneralLinkAdapter {
#url;
constructor(link) {
console.log("============",link)
if (/share.xiaochuankeji.cn/.test(link)) {
this.#url = this.zuiyou(link);
} else if (/kuaishou.com/.test(link)) {
this.#url = this.ks(link);
} else if (/ixigua.com/.test(link)) {
this.#url = this.xigua(link);
}
}
async ks(link) {
// 例子https://www.kuaishou.com/short-video/3xkfs8p4pnd67p4?authorId=3xkznsztpwetngu&streamSource=find&area=homexxbrilliant
// https://v.m.chenzhongtech.com/fw/photo/3xburnkmj3auazc
// https://v.kuaishou.com/1ff8QP
let msg = /(?:https?:\/\/)?(www|v)\.kuaishou\.com\/[A-Za-z\d._?%&+\-=\/#]*/g.exec(link)[0];
// 跳转短号
if (msg.includes("v.kuaishou")) {
await fetch(msg, {
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
}
}).then(resp => {
msg = resp.url;
})
}
let video_id;
if (msg.includes('/fw/photo/')) {
video_id = msg.match(/\/fw\/photo\/([^/?]+)/)[1];
} else if (msg.includes("short-video")) {
video_id = msg.match(/short-video\/([^/?]+)/)[1];
} else {
throw "无法提取快手的信息,请重试或者换一个视频!";
}
// 提取视频
return {
name: "快手",
link: GENERAL_REQ_LINK.replace("{}", `https://www.kuaishou.com/short-video/${ video_id }`)
};
}
async zuiyou(link) {
// #最右#分享一条有趣的内容给你,不好看算我输。请戳链接>>https://share.xiaochuankeji.cn/hybrid/share/post?pid=365367131&zy_to=applink&share_count=1&m=dc114ccc8e55492642f6a702b510c1f6&d=9e18ca2dace030af656baea96321e0ea353fe5c46097a7f3962b93f995641e962796dd5faa231feea5531ac65547045f&app=zuiyou&recommend=r0&name=n0&title_type=t0
const msg = /(?:https?:\/\/)?(share|share.xiaochuankeji)\.cn\/[A-Za-z\d._?%&+\-=\/#]*/.exec(link)[0];
return {name: "最右", link: GENERAL_REQ_LINK.replace("{}", msg)};
}
async xigua(link) {
// 1. https://v.ixigua.com/ienrQ5bR/
// 2. https://www.ixigua.com/7270448082586698281
// 3. https://m.ixigua.com/video/7270448082586698281
let msg = /(?:https?:\/\/)?(www|v|m)\.ixigua\.com\/[A-Za-z\d._?%&+\-=\/#]*/g.exec(link)[0];
// 跳转短号
if (msg.includes("v.ixigua")) {
await fetch(msg, {
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
}
}).then(resp => {
msg = resp.url;
})
}
const id = /ixigua\.com\/(\d+)/.exec(msg)[1] || /\/video\/(\d+)/.exec(msg)[1];
const videoReq = `https://www.ixigua.com/${ id }`;
return {name: "西瓜", link: GENERAL_REQ_LINK.replace("{}", videoReq)};
}
async build() {
return this.#url;
}
}
export default GeneralLinkAdapter