🐞 fix: V1.6.7 修复y2b解析pr后细节问题

This commit is contained in:
zhiyu1998 2024-04-21 21:37:18 +08:00
parent 72121208ae
commit 301d4c657d

View File

@ -1147,22 +1147,22 @@ export class tools extends plugin {
* @param e * @param e
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async dy2b(path,url) { async dy2b(path, url, isOversea) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const command = `yt-dlp ${isOversea ? "" : `--proxy ${this.myProxy}`} -P ${path} -o "temp.%(ext)s" -f 'best[height<=720][ext=mp4]' --merge-output-format "mp4" ${url}`; const command = `yt-dlp ${ isOversea ? "" : `--proxy ${ this.myProxy }` } -P ${ path } -o "temp.%(ext)s" -f 'best[height<=720][ext=mp4]' --merge-output-format "mp4" ${ url }`;
exec(command, (error, stdout) => { exec(command, (error, stdout) => {
if (error) { if (error) {
console.error(`Error executing command: ${error}`); console.error(`Error executing command: ${ error }`);
reject(error); reject(error);
} else { } else {
console.log(`Command output: ${stdout}`); console.log(`Command output: ${ stdout }`);
resolve(stdout); resolve(stdout);
} }
}); });
}); });
} }
async sy2b(e){ async sy2b(e) {
let videoSizeLimit = 30 let videoSizeLimit = 30
const isOversea = await this.isOverseasServer(); const isOversea = await this.isOverseasServer();
if (!isOversea && !(await testProxy(this.proxyAddr, this.proxyPort))) { if (!isOversea && !(await testProxy(this.proxyAddr, this.proxyPort))) {
@ -1170,16 +1170,16 @@ export class tools extends plugin {
return false; return false;
} }
try { try {
const urlRex = /(?:https?:\/\/)?(www\.)?youtube\.com\/[A-Za-z\d._?%&+\-=\/#]*/g; const urlRex = /(?:https?:\/\/)?(www\.)?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] || url2Rex.exec(e.msg)?.[0]; let url = urlRex.exec(e.msg)?.[0] || url2Rex.exec(e.msg)?.[0];
const path = this.getCurDownloadPath(e) const path = this.getCurDownloadPath(e)
await checkAndRemoveFile(path + "/temp.mp4") await checkAndRemoveFile(path + "/temp.mp4")
const title = execSync(`yt-dlp --get-title ${url} ${isOversea ? "" : `--proxy ${this.myProxy}`}`) const title = execSync(`yt-dlp --get-title ${ url } ${ isOversea ? "" : `--proxy ${ this.myProxy }` }`)
e.reply(`识别:油管,视频下载中请耐心等待 \n${title}`); e.reply(`识别:油管,视频下载中请耐心等待 \n${ title }`);
await this.dy2b(path,url) await this.dy2b(path, url, isOversea);
this.sendVideoToUpload(e, `${path}/temp.mp4`,videoSizeLimit) this.sendVideoToUpload(e, `${ path }/temp.mp4`, videoSizeLimit)
}catch (error) { } catch (error) {
console.error(error); console.error(error);
throw error; // Rethrow the error so it can be handled by the caller throw error; // Rethrow the error so it can be handled by the caller
} }