burakerenel / devtube
A Laravel package for downloading videos from the net by simply passing a URL
2.0.6
2020-04-30 01:22 UTC
Requires
- athlon1600/youtube-downloader: ^1.0
- illuminate/support: >=5
- laravel/framework: >=5
- masih/youtubedownloader: ~2.9.0
- norkunas/youtube-dl-php: ^1.3
Requires (Dev)
- orchestra/testbench: ^3.4
- vlucas/phpdotenv: ^2.4
This package is not auto-updated.
Last update: 2024-12-19 04:54:55 UTC
README
Install FFMPEG only if you want to convert videos to mp3 etc
Ubuntu:
sudo apt install ffmpeg
Install youtube-dl
sudo apt install youtube-dl
Install via composer
composer require devswebdev/devtube
Publish vendor assets
php artisan vendor:publish --provider="DevsWebDev\DevTube\DevTubeServiceProvider"
This publishes a devtube.php
file in your config/
directory
Please set your default options there.
Make sure your youtube-dl
path is correct by comparing the output of which youtube-dl
to the bin_path
in devtube.php
"bin_path" => "/usr/bin/youtube-dl",
An Example
namespace App\Http\Controllers; use DevsWebDev\DevTube\Download; class YoutubeDownloadController extends Controller { public function download() { $dl = new Download($url = "https://www.youtube.com/watch?v=ye5BuYf8q4o", $format = "mp4", $download_path = "music" ); //Saves the file to specified directory $media_info = $dl->download(); $media_info = $media_info->first(); // Return as a download return response()->download($media_info['file']->getPathname()); } }
Or in your web.php routes file
use DevsWebDev\DevTube\Download; Route::get('/', function () { $dl = new Download($url = "https://www.youtube.com/watch?v=ye5BuYf8q4o", $format = "mp3", $download_path = "music" ); //Saves the file to specified directory $media_info = $dl->download(); $media_info = $media_info->first(); // Return as a download return response()->download($media_info['file']->getPathname()); });