mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
🐞 fix: 修复部分用户使用 TikTok 解析问题
This commit is contained in:
parent
de424d6a13
commit
9a545f66a9
@ -342,7 +342,7 @@ export class tools extends plugin {
|
||||
return false;
|
||||
}
|
||||
// 处理链接
|
||||
let url = await processTikTokUrl(e.msg.trim(), isOversea);
|
||||
let url = await processTikTokUrl(e.msg.trim(), isOversea, this.myProxy);
|
||||
// 去除多余参数
|
||||
const parsedUrl = new URL(url);
|
||||
parsedUrl.search = '';
|
||||
|
@ -4,9 +4,10 @@ import HttpProxyAgent from "https-proxy-agent";
|
||||
* Tiktok专属解析链接的Fetch
|
||||
* @param url 地址
|
||||
* @param isOversea 是否是海外
|
||||
* @param proxy 梯子
|
||||
*/
|
||||
const fetchTiktokUrl = async (url, isOversea) => {
|
||||
const proxyAgent = isOversea ? '' : new HttpProxyAgent(this.myProxy);
|
||||
const fetchTiktokUrl = async (url, isOversea, proxy) => {
|
||||
const proxyAgent = isOversea ? '' : new HttpProxyAgent(proxy);
|
||||
// 处理特殊情况 & 非特殊情况的header
|
||||
const headers = url.includes("vm.tiktok") || url.includes("tiktok.com/t")
|
||||
? { "User-Agent": "facebookexternalhit/1.1" }
|
||||
@ -25,8 +26,9 @@ const fetchTiktokUrl = async (url, isOversea) => {
|
||||
* 处理Tiktok链接
|
||||
* @param url 用户发送的链接,可能存在一些问题,需要正则匹配处理
|
||||
* @param isOversea 是否是海外
|
||||
* @param proxy 梯子
|
||||
*/
|
||||
export const processTikTokUrl = async (url, isOversea) => {
|
||||
export const processTikTokUrl = async (url, isOversea, proxy) => {
|
||||
// 合并正则表达式
|
||||
// const urlShortRex = /(http:|https:)\/\/vt.tiktok.com\/[A-Za-z\d._?%&+\-=\/#]*/g;
|
||||
// const urlShortRex2 = /(http:|https:)\/\/vm.tiktok.com\/[A-Za-z\d._?%&+\-=\/#]*/g;
|
||||
@ -35,7 +37,7 @@ export const processTikTokUrl = async (url, isOversea) => {
|
||||
const match = tikTokRegex.exec(url);
|
||||
|
||||
if (match) {// 如果URL匹配任何TikTok相关的模式,则进行处理
|
||||
url = await fetchTiktokUrl(match[0], isOversea);
|
||||
url = await fetchTiktokUrl(match[0], isOversea, proxy);
|
||||
}
|
||||
|
||||
// 这里可以处理其他逻辑,例如更新URL、记录日志等
|
||||
|
Loading…
x
Reference in New Issue
Block a user