aladdindev / php-youtube-dl
A PHP script to help download your videos from Youtube
dev-master
2018-02-08 11:10 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2025-06-12 00:14:52 UTC
README
A PHP script to help you download your videos from Youtube
Requirements
- PHP >=5.3
- PHP CURL extension is optional
PHPYoutubeDL
Example #1: Basic download
require_once 'vendor/autoload.php'; use PHPYoutubeDl\PHPYoutubeDl; $php_youtube_dl = new PHPYoutubeDl("http://www.youtube.com/watch?v=xxxxxx"); $php_youtube_dl->startDownload();
Example #2: Prints direct download link
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();
Example #3: With progress function
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();
php-youtube-dl-cli
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
Arguments
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. |