Ever wanted to implement a YouTube downloader for your website? Here’s a very simple PHP script to make your work easy. You just have to have the link to the video.

Let’s see how to implement this script on your website.

  1. This project is on GitHub. Clone it from there. -> https://github.com/rprabhashvara/DYLoader
  2. Include the PHP file ‘DYLoader.php’ in your PHP code.
  3. Create a new object of DYLoader with the link to the video as a parameter.
  4. Call object->getData() method and assign the returned array to a variable.
  5. Use the new array as you see fit.

To clarify the above said steps 2-5, see the code below.


$vid = new DYLoader("https://www.youtube.com/watch?v=pTuyfQ5CR4Q");
$links = $vid->getData();

echo $links['720p-mp4'];


Here I’m using ‘720p-mp4’ to get the link to the specific format. You can choose the below formats from the array by default. (if exists)

  1. 144p-3gp
  2. 240p-flv
  3. 240p-3gp
  4. 360p-mp4
  5. 360p-flv-video – this is video only format
  6. 480p-flv-video – this is video only format
  7. 720p-mp4

If you want to select from more video formats, you have to specify them in the ‘getData()’ method in the ‘DYLoader.php’ file. You can find out more about video formats and needed iTags here.

As an example, if you want to get ‘1080p-mp4 video only format’, add something like this below to the condition set.

else if(strpos($string, "itag=37")!==false){
    $arr['1080p-mp4-video'] = $string;

Happy coding!!