mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
commit
b89ef59739
@ -1432,7 +1432,12 @@ export class tools extends plugin {
|
|||||||
try {
|
try {
|
||||||
const urlRex = /(?:https?:\/\/)?(www\.|music\.)?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;
|
const url2Rex = /(?:https?:\/\/)?youtu\.be\/[A-Za-z\d._?%&+\-=\/#]*/g;
|
||||||
let url = urlRex.exec(e.msg)?.[0]?.replace(/&/g, '^&') || url2Rex.exec(e.msg)?.[0]?.replace(/&/g, '^&');
|
// 检测操作系统平台
|
||||||
|
const isWindows = process.platform === 'win32';
|
||||||
|
|
||||||
|
// 匹配并转义 URL 中的 & 符号(仅对 Windows 进行转义)
|
||||||
|
let url = urlRex.exec(e.msg)?.[0]?.replace(/&/g, isWindows ? '^&' : '&') ||
|
||||||
|
url2Rex.exec(e.msg)?.[0]?.replace(/&/g, isWindows ? '^&' : '&');
|
||||||
// 适配 YouTube Music
|
// 适配 YouTube Music
|
||||||
if (url.includes("music")) {
|
if (url.includes("music")) {
|
||||||
// https://music.youtube.com/watch?v=F4sRtMoIgUs&si=7ZYrHjlI3fHAha0F
|
// https://music.youtube.com/watch?v=F4sRtMoIgUs&si=7ZYrHjlI3fHAha0F
|
||||||
|
@ -18,7 +18,7 @@ function constructProxyParam(isOversea, proxy) {
|
|||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
export function ytDlpGetTilt(url, isOversea, proxy) {
|
export function ytDlpGetTilt(url, isOversea, proxy) {
|
||||||
return execSync(`yt-dlp --get-title ${constructProxyParam(isOversea, proxy)} ${url}`);
|
return execSync(`yt-dlp --get-title ${constructProxyParam(isOversea, proxy)} ${url} --encoding utf8`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +34,7 @@ export async function ytDlpHelper(path, url, isOversea, proxy, merge = false) {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const mergeOption = merge ? '--merge-output-format "mp4"' : '';
|
const mergeOption = merge ? '--merge-output-format "mp4"' : '';
|
||||||
|
|
||||||
const command = `yt-dlp ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.%(ext)s" ${mergeOption} ${url}`;
|
const command = `yt-dlp -f "bv[height<=720][ext=mp4]+ba[ext=m4a]" ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.%(ext)s" ${url}`;
|
||||||
|
|
||||||
exec(command, (error, stdout) => {
|
exec(command, (error, stdout) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user