A PHP script to help you download your videos from Youtube
- PHP >=5.3
- PHP CURL extension is optional
require_once 'vendor/autoload.php';
use PHPYoutubeDl\PHPYoutubeDl;
$php_youtube_dl = new PHPYoutubeDl("http://www.youtube.com/watch?v=xxxxxx");
$php_youtube_dl->startDownload();
require_once 'vendor/autoload.php';
use PHPYoutubeDl\PHPYoutubeDl;
$php_youtube_dl = new PHPYoutubeDl("http://www.youtube.com/watch?v=xxxxxx");
echo $php_youtube_dl->getDirectLink();
require_once 'vendor/autoload.php';
use PHPYoutubeDl\PHPYoutubeDl;
function showProgress($downloaded_size, $download_size){
echo $downloaded_size / $download_size;
echo PHP_EOL;
flush();
}
$php_youtube_dl = new PHPYoutubeDl("http://www.youtube.com/watch?v=xxxxxx");
$php_youtube_dl->setProgressCallback('showProgress');
$php_youtube_dl->startDownload();
Download the PHP script.
Make sure PHP-CLI is installed and added to your PATH variable.
php php-youtube-dl-cli.php -f 28 -t myvideo http://youtube.com/watch?v=xxxxxx
You can use the following arguments:
Option | Description |
---|---|
-c | Prints currently used JS cipher function. |
-t title | Specify a custom filename. The video ID and the extension will still be appended to this argument. |
-f format | Specify a format to download. You can access the list of available format IDs using the -l argument. |
-l | Lists the available formats for the provided video. |
-h | Prints the help section. |