lolikillers / youtube-downloader
Extract & download video, audio, subtitles from YouTube
dev-master / 1.0.x-dev
2023-05-28 10:23 UTC
Requires
- php: >=7.2.5
- ext-json: *
- lolikillers/rublix-downloader: *
- symfony/http-client: >=5.3.3
Requires (Dev)
- phpunit/phpunit: 9.5.x-dev
This package is auto-updated.
Last update: 2024-05-28 12:32:40 UTC
README
Get video source with preview image from YouTube
Install via Composer
composer require lolikillers/youtube-downloader
You have two options of how to use this package
- Use it standalone
<?php use LoliKillers\RublixDownloader\Model\URL; use LoliKillers\YouTubeDownloader\YouTubeHandler; use Symfony\Component\HttpClient\HttpClient; include_once 'vendor/autoload.php'; $httpClient = HttpClient::create(); $youtubeHandler = new YouTubeHandler($httpClient); $res = $youtubeHandler->fetchResource(URL::fromString('https://www.youtube.com/watch?v=zIwLWfaAg-8')); print_r($res->toArray()); //
- Use it with RublixDownloader. Useful in case if your application is willing to download files from different sources (i.e. has more than one download handler)
<?php use LoliKillers\RublixDownloader\RublixDownloader; use LoliKillers\RublixDownloader\Model\URL; use LoliKillers\YouTubeDownloader\YouTubeHandler; use Symfony\Component\HttpClient\HttpClient; include_once 'vendor/autoload.php'; $rublixDownloader = new RublixDownloader(); $rublixDownloader->addHandler(new YouTubeHandler(HttpClient::create())); $YouTubePageUrl = URL::fromString('https://www.youtube.com/watch?v=zIwLWfaAg-8'); $video = $rublixDownloader->fetchResource($YouTubePageUrl); print_r($video->toArray());