It's not like Youtube's engineers can't just. Download yt-dlp and see how it works
It's not proprietary
The yt-dlp devs also talk about this openly, in GitHub issues and elsewhere. I think there have been multiple front page stories about how yt-dlp works here on HN over the last few years.