mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
21 lines
731 B
JavaScript
21 lines
731 B
JavaScript
/**
|
|
* yt-dlp工具类
|
|
* @returns {Promise<void>}
|
|
* @param path 下载路径
|
|
* @param url 下载链接
|
|
* @param isOversea 是否是海外用户
|
|
*/
|
|
export async function dy2b(path, url, isOversea, proxy) {
|
|
return new Promise((resolve, reject) => {
|
|
const command = `yt-dlp ${ isOversea ? "" : `--proxy ${ proxy }` } -P ${ path } -o "temp.%(ext)s" --merge-output-format "mp4" ${ url }`;
|
|
exec(command, (error, stdout) => {
|
|
if (error) {
|
|
console.error(`Error executing command: ${ error }`);
|
|
reject(error);
|
|
} else {
|
|
console.log(`Command output: ${ stdout }`);
|
|
resolve(stdout);
|
|
}
|
|
});
|
|
});
|
|
} |