composer require jackal/video-downloader:^0.5
class MyDownloader extends AbstractDownloader
{
public function getURL(): string
{
$videoId = $this->getVideoId();
//$videoLocation = [...code to retreive URL ...]
return $videoLocation;
}
//it needs to identify video ID from public URLS (this example: http://www.sample-site.com/video/1234/)
public static function getPublicUrlRegex(): string
{
return '/www\.sample-site\.com\/video\/([\d]+)\//';
}
public static function getType(): string
{
return 'my_downloader';
}
}
$myVideoIdOrReference = '123456';
$vd = new \Jackal\Downloader\VideoDownloader();
$vd->registerDownloader(MyDownloader::class);
$downloader = $vd->getDownloader('my_downloader', $myVideoIdOrReference, [
//[...additional custom options...]
]);
$downloader->download(__DIR__ . '/output.avi');
$myVideoIdOrReference = '123456';
$vd = new \Jackal\Downloader\VideoDownloader();
$vd->registerDownloader(MyDownloader::class);
$downloader = $vd->getDownloaderByPublicUrl('http://www.sample-site.com/video/1234/', [
//[...additional custom options...]
]);
$downloader->download(__DIR__ . '/output.avi');