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
10c4c58bb8
commit
9e813a2711
23
README.md
23
README.md
@ -79,6 +79,29 @@ chmod a+rx ~/.local/bin/yt-dlp
|
|||||||
sudo pacman -Syu yt-dlp
|
sudo pacman -Syu yt-dlp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`Tiktok解析`需要将`yt-dlp`升级到`最新版本`,如果不会可以按照下面的教程(Linux),Windows换个文件应该就可以:
|
||||||
|
```shell
|
||||||
|
# 1. 去官方下载最新版本:https://github.com/yt-dlp/yt-dlp/releases
|
||||||
|
# 2. 把yt-dlp放在Linux某个位置,比如/home/YtDlpHome/yt-dlp
|
||||||
|
# 3. 删除之前的yt-dlp,删除之前可以看看是不是最新版本
|
||||||
|
|
||||||
|
# 查看最新版本
|
||||||
|
yt-dlp --version
|
||||||
|
# 如果你是 apt 安装需要卸载
|
||||||
|
apt remove yt-dlp
|
||||||
|
|
||||||
|
# 4. 将/home/YtDlpHome/yt-dlp添加到环境变量(下面二选一)
|
||||||
|
vim ~/.bashrc # 如果你使用 bash
|
||||||
|
vim ~/.zshrc # 如果你使用 zsh
|
||||||
|
|
||||||
|
# 5. 添加到最后一行
|
||||||
|
export PATH="/home/YtDlpHome:$PATH"
|
||||||
|
|
||||||
|
# 6. 刷新环境变量即可
|
||||||
|
source ~/.bashrc # 如果你使用 bash
|
||||||
|
source ~/.zshrc # 如果你使用 zsh
|
||||||
|
```
|
||||||
|
|
||||||
`AM解析`需要使用两个依赖`freyr`、`atomicparsley`,现在只以Debian系统为例:
|
`AM解析`需要使用两个依赖`freyr`、`atomicparsley`,现在只以Debian系统为例:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -343,54 +343,42 @@ export class tools extends plugin {
|
|||||||
}
|
}
|
||||||
// 处理链接
|
// 处理链接
|
||||||
let url = await processTikTokUrl(e.msg.trim(), isOversea);
|
let url = await processTikTokUrl(e.msg.trim(), isOversea);
|
||||||
// 处理ID
|
// 去除多余参数
|
||||||
let tiktokVideoId = await getIdVideo(url);
|
const parsedUrl = new URL(url);
|
||||||
tiktokVideoId = tiktokVideoId.replace(/\//g, "");
|
parsedUrl.search = '';
|
||||||
|
const cleanedTiktokUrl = parsedUrl.toString();
|
||||||
const config = {
|
// 下载逻辑
|
||||||
headers: {
|
const path = this.getCurDownloadPath(e);
|
||||||
"User-Agent":
|
const title = execSync(`yt-dlp --get-title ${ cleanedTiktokUrl } ${ isOversea ? "" : `--proxy ${ this.myProxy }` }`)
|
||||||
"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Mobile Safari/537.36",
|
e.reply(`识别:TikTok,视频下载中请耐心等待 \n${ title }`);
|
||||||
},
|
await this.tiktokHelper(path, cleanedTiktokUrl, isOversea);
|
||||||
// redirect: "follow",
|
await this.sendVideoToUpload(e, `${ path }/temp.mp4`);
|
||||||
follow: 10,
|
|
||||||
timeout: 10000,
|
|
||||||
}
|
|
||||||
// 如果不是海外,则使用代理
|
|
||||||
if (!isOversea) {
|
|
||||||
config.httpsAgent = tunnel.httpsOverHttp({
|
|
||||||
proxy: new HttpProxyAgent(this.myProxy),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const params = new URLSearchParams({
|
|
||||||
"iid": "7318518857994389254",
|
|
||||||
"device_id": "7318517321748022790",
|
|
||||||
"channel": "googleplay",
|
|
||||||
"app_name": "musical_ly",
|
|
||||||
"version_code": "300904",
|
|
||||||
"device_platform": "android",
|
|
||||||
"device_type": "ASUS_Z01QD",
|
|
||||||
"os_version": "9",
|
|
||||||
"aweme_id": tiktokVideoId
|
|
||||||
})
|
|
||||||
// console.log(`${TIKTOK_INFO}?${params.toString()}`)
|
|
||||||
await fetch(`${ TIKTOK_INFO }?${ params.toString() }`, config)
|
|
||||||
.then(async resp => {
|
|
||||||
const respJson = await resp.json();
|
|
||||||
const data = respJson.aweme_list[0];
|
|
||||||
e.reply(`识别:tiktok, ${ data.desc }`);
|
|
||||||
this.downloadVideo(data.video.play_addr.url_list[0], !isOversea).then(video => {
|
|
||||||
e.reply(
|
|
||||||
segment.video(
|
|
||||||
`${ this.getCurDownloadPath(e) }/temp.mp4`,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* yt-dlp for tiktok 工具
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
* @param path 下载路径
|
||||||
|
* @param url 下载链接
|
||||||
|
* @param isOversea 是否是海外用户
|
||||||
|
*/
|
||||||
|
async tiktokHelper(path, url, isOversea) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const command = `yt-dlp ${ isOversea ? "" : `--proxy ${ this.myProxy }` } -P ${ path } -o "temp.%(ext)s" ${ url }`;
|
||||||
|
exec(command, (error, stdout) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(`Error executing command: ${ error }`);
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
console.log(`Command output: ${ stdout }`);
|
||||||
|
resolve(stdout);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async biliScan(e) {
|
async biliScan(e) {
|
||||||
e.reply('R插件开源免责声明:\n您将通过扫码完成获取哔哩哔哩refresh_token以及ck。\n本Bot将不会保存您的登录状态。\n我方仅提供视频解析及相关B站内容服务,若您的账号封禁、被盗等处罚与我方无关。\n害怕风险请勿扫码 ~', { recallMsg: 180 });
|
e.reply('R插件开源免责声明:\n您将通过扫码完成获取哔哩哔哩refresh_token以及ck。\n本Bot将不会保存您的登录状态。\n我方仅提供视频解析及相关B站内容服务,若您的账号封禁、被盗等处罚与我方无关。\n害怕风险请勿扫码 ~', { recallMsg: 180 });
|
||||||
// 图片发送钩子
|
// 图片发送钩子
|
||||||
|
Loading…
x
Reference in New Issue
Block a user