1. Go to this page and download the library: Download flatgreen/ytdl library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flatgreen / ytdl example snippets
use Flatgreen\Ytdl\Options;
use Flatgreen\Ytdl\Ytdl;
$ytdl_options = new Options();
// merge with default options
$ytdl_options->addOptions(['-f' => '18/worst']);
// with a direct string commnd line
$ytdl_options->addRawOptions('--one_alone --with_value value --second_alone -t');
$ytdl = new Ytdl($ytdl_options);
// optional, change cache options
// default temporary cache directory and duration 3600 sec.
// no cache with ['duration' => 0]
$ytdl->setCache(['directory' => 'cache', 'duration' => 7200])
$ytdl = new Ytdl($ytdl_options, null, 'usr/share/local/yt-dlp');