devswebdev/devtube

A Laravel package for downloading videos from the net by simply passing a URL


README

alt text

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());

});