I have an old system (nodejs) that extracts the HLS link from a youtube livestream. Its code looks something like:
ydl = require('youtube-dl');
ydl.exec(stream.url, ['--format=96', '-g'], {}, (err, output) => {
if (err) throw err
console.log('\nyoutube-dl finished HLS link extraction:');
console.log(output.join('\n'));
console.log('\n');
hls_link = output[0];
stream.vCap = new cv.VideoCapture(hls_link);//0);
stream.vCap.set(cv.CAP_PROP_FRAME_WIDTH, width);
stream.vCap.set(cv.CAP_PROP_FRAME_HEIGHT, height);
});
}
I need to switch to the package youtube-dl-exec since youtube-dl's node wrapper is no longer supported and is out of date w.r.t. YouTube's formatting for my use case.
I've tried rewriting the above to something like the following:
ydl = require('youtube-dl-exec');
ydl(url, {format: 96, getUrl: true}).then((result) => {
console.log(`got hls result: ${result}`);
}).catch((fail) => {
console.log(`hls failure`};
});
However, I get that the failure case is always reached even though when I run the following in the terminal I get reasonable output:
yt-dlp -f 96 -g <url>
Am I converting the flags properly or is perhaps something else wrong with my approach?
Thanks!