I remember the request is done with XHTTP, not even fetchAPI. That runs the cgi script with the youtube-dl.
Now with yt-dlp, that needs NodeJS to solve various client side fuckery imposed by youtube. So it doesn't worth making the backend in php, but should be directly in JS. And ofc, fetch for "modern" solution.