项目作者: Hemant-Mann

项目描述 :
A YouTube Downloader library made for php using ffmpeg + youtube-dl
高级语言: PHP
项目地址: git://github.com/Hemant-Mann/YTDownloader.git
创建时间: 2015-11-04T12:42:10Z
项目社区:https://github.com/Hemant-Mann/YTDownloader

开源协议:MIT License

下载


YTDownloader

It is library for downloading and converting youtube videos to desired formats

Dependencies

Youtube-dl

  1. # Linux/Mac Users
  2. sudo wget https://yt-dl.org/downloads/2016.05.10/youtube-dl -O /usr/local/bin/youtube-dl
  3. sudo chmod a+rx /usr/local/bin/youtube-dl

FFMPEG

  1. # For Ubuntu 15.10 above
  2. sudo apt-get install ffmpeg

Setup

  1. # Linux/Unix Based System
  2. git clone https://github.com/Hemant-Mann/YTDownloader.git
  3. cd YTDownloader
  4. mkdir downloads
  5. chmod 777 downloads/

Usage

```php
<?php
require ‘autoloader.php’;
use YTDownloader\Service\Download as Downloader;
use YTDownloader\Helper\Convert as Convert;

$url = “https://www.youtube.com/watch?v=YykjpeuMNEk“;

try {
// $opts = [‘path’ => ‘/home/user/Download’, ‘bitrate’ => ‘128K’];
// $ytdl = new Downloader($url, $opts);

$ytdl = new Downloader($url);

// Get Available Qualities
// $q = $ytdl->availableQualities();

// Dont need to manually Mention the quality code just pass the human
// readable string - ‘144p’, ‘240p’ etc
// $file = $ytdl->download(22, ‘mp4’); (prev version)

// Current and more readable
$mp4File = $ytdl->convert(‘mp4’, [‘type’ => ‘video’, ‘quality’ => ‘360p’, ‘fullPath’ => true]);
// $mp4File = $ytdl->convert(‘mp4’, [‘type’ => ‘video’, ‘quality’ => ‘244p’]);

$mp3File = $ytdl->convert(‘mp3’, [‘type’ => ‘audio’, ‘fullPath’ => true]);

// prev Version
// $mp3File = Downloader::getDownloadPath() . $mp3File;

// Current Version — Pass fullPath to convert function to get fullpath of the downloaded file

var_dump($mp3File);
var_dump($mp4File);
} catch (\Exception $e) {
echo print_r($e, true);
}