feat: V1.6.7 适配 YouTube Music

This commit is contained in:
zhiyu1998 2024-04-22 20:37:27 +08:00
parent 49f765e082
commit c2c75fccc0
2 changed files with 11 additions and 5 deletions

View File

@ -75,6 +75,8 @@ chmod a+rx ~/.local/bin/yt-dlp
# debian 国内
curl -L https://ghproxy.net/https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o ~/.local/bin/yt-dlp
chmod a+rx ~/.local/bin/yt-dlp
# archlinux
sudo pacman -Syu yt-dlp
```
4. 【可选】小程序解析适配了:
@ -151,8 +153,7 @@ git clone -b 1.5.1 https://gitee.com/kyrzy0416/rconsole-plugin.git
`proxyPort: '7890' # 魔法端口`
> 海外服务器示例:
`proxyAddr: '127.0.0.1' # 魔法地址`
`proxyPort: '80' # 魔法端口`
直接发送`#设置海外解析`
## 📦 业务

View File

@ -136,7 +136,7 @@ export class tools extends plugin {
fnc: "general",
},
{
reg: "(youtube.com|youtu.be)",
reg: "(youtube.com|youtu.be|music.youtube.com)",
fnc: "sy2b"
},
{
@ -1173,10 +1173,15 @@ export class tools extends plugin {
return false;
}
try {
const urlRex = /(?:https?:\/\/)?(www\.)?youtube\.com\/[A-Za-z\d._?%&+\-=\/#]*/g;
const urlRex = /(?:https?:\/\/)?(www\.|music\.)?youtube\.com\/[A-Za-z\d._?%&+\-=\/#]*/g;
const url2Rex = /(?:https?:\/\/)?youtu\.be\/[A-Za-z\d._?%&+\-=\/#]*/g;
let url = urlRex.exec(e.msg)?.[0] || url2Rex.exec(e.msg)?.[0];
const path = this.getCurDownloadPath(e)
// 适配 YouTube Music
if (url.includes("music")) {
// https://music.youtube.com/watch?v=F4sRtMoIgUs&si=7ZYrHjlI3fHAha0F
url = url.replace("music", "www");
}
const path = this.getCurDownloadPath(e);
await checkAndRemoveFile(path + "/temp.mp4")
const title = execSync(`yt-dlp --get-title ${ url } ${ isOversea ? "" : `--proxy ${ this.myProxy }` }`)
e.reply(`识别:油管,视频下载中请耐心等待 \n${ title }`);