A small wrapper around yt-dlp, which allows you to invoke it as a child process in your node project. Inspired by youtube-dl-exec. Made for personal use/learning, but anyone is welcome to use/extend it.
- Downloads appropriate
yt-dlp
for OS (seedownload-yt-dlp.js
) - Allows you to pass any supported
yt-dlp
arguments
- Node version 12 or greater
npm install @alpacamybags118/yt-dlp-exec
const yt = require('@alpacamybags118/yt-dlp-exec');
const result = yt.createYtDlpAsProcess('https://some.url', {
f: 'bestaudio',
preferFreeFormats: true,
});
result.on('exit', (exit) => {
console.log(exit);
})
import createYtDlpAsProcess from '@alpacamybags118/yt-dlp-exec'
const process = createYtDlpAsProcess(
'https://some.url',
{
o: '-',
q: '',
f: 'bestaudio',
preferFreeFormats: true,
r: '100K',
}
);
You can also pass custom process options (in execa
format: see https://github.com/sindresorhus/execa) for more control over settings such as stdio.
const yt = require('@alpacamybags118/yt-dlp-exec');
const result = yt.createYtDlpAsProcess('https://some.url', {
f: 'bestaudio',
preferFreeFormats: true,
}, { stdio: ['pipe', 'pipe', 'pipe'] });
result.on('exit', (exit) => {
console.log(exit);
})
Argument list fo commands uses dargs
formatting. Returned child process is in execa
format