The actual youtube metadata extraction is performed by the awesome ytdl-core library https://www.npmjs.com/package/ytdl-core https://github.com/fent/node-ytdl-core
For local work, https://www.npmjs.com/package/ytdl is a CLI powered by the same module. There is also a python-based youtube-dl command https://rg3.github.io/youtube-dl/ that supports a ton of sites