Download the PHP package masih/youtubedownloader without Composer

On this page you can find all versions of the php package masih/youtubedownloader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
masih/youtubedownloader
Rate from 1 - 5
Rated 1.00 based on 2 reviews

Informations about the package youtubedownloader

Youtube Downloader

Youtube video downloader

Build Status Latest Stable Version Latest Unstable Version Coverage Status Total Downloads License

CLI

If you are not a developer and just need this tool to download videos, only read this part. Next parts are for developers who want to use this package in their projects. We assume that you already installed PHP and Composer. To install the CLI, open terminal and write this command:

After installation you'll have a new youtube command. Just write youtube --help to get more information.

Installation

Youtube Downloader is PSR-0 compliant and can be installed using composer. Simply add masih/youtubedownloader to your composer.json file.

and run composer update command

Needs PHP 5.5 or newer. Tested with PHP 5.5, 5.6, 7.0, 7.1, hhvm and nightly

By default videos will download to videos folder, if you want to change it, you should use setPath method.

When you install it as a dependency, there need to be a cache directory beside vendor and it should be writable (e.g. chmod 777).

Usage

Video or Playlist info

To get video or playlist information, you should instantiate YoutubeDownloader with video or playlist url or id. for example for http://youtube.com/watch?v=gmFn62dr0D8, video id is gmFn62dr0D8. or for https://www.youtube.com/playlist?list=PLbjM1u8Yb9I0rK4hkPa9TWe4N_idJOnrJ, playlist id is PLbjM1u8Yb9I0rK4hkPa9TWe4N_idJOnrJ.

the getInfo() method will call getVideoInfo() or getPlaylistInfo() according to url or id. there is a response_type field in result of each one, indicating type of response that can be "playlist" or "video".

getVideoInfo() method will return an object containing video title, images, url, captions and itag of all formats (full and adaptive), ...

getPlaylistInfo() method will return an object containing title, description, author, videos, views, likes, dislikes, ...

Both getInfo(true) and getPlaylistInfo(true) can get an optional boolean parameter to get result of getVideoInfo() for each video.

Video urls can be in these formats (Vevo videos are also supported, but cannot be downloaded in all countries):

Video formats are in two category; Full & adaptive in Full formats, videos and sounds are muxed and are in one file. but in Adaptive formats, videos and sounds are in separated urls.

Each format has it's own itag. it's just an identifier. You can get list of known itags and their descriptions by calling getItags() static method, or description of a single itag by calling getItagInfo($itag) with the itag number. You can call setDefaultItag($itag) method with an itag number to download further videos in that format.

Download video(s)

the download() method gets itag of a format and downloads it. if no itag is passed, it will download highest quality of Full format. For playlists, it will download all videos one by one.

Second parameter of download method is a boolean named $resume. When it is true, it will continue downloading videos that are partially downloaded last time. Third parameter of download method is a mixed named $caption. When it is false (default), it will not download caption (subtitle). When it is null, it will download caption in default language (english). Else, it should be a name of language. See Caption section below.

Download progress

Download progress is available via onProgress parameter. it's a closure and has four parameters $downloadedBytes, $fileSize, $index and $count. $index and $count are useful for tracking download progress of playlist and both values are 1 for single videos.

Download complete

Download complete event is available via onComplete parameter. it's a closure and has four parameters $filePath, $fileSize, $index and $count. $index and $count are useful for tracking download progress of playlist and both values are 1 for single videos.

Finalized

After completing download, Finalized event will be fired. it is available via onFinalized parameter. it's a closure and has four parameters $filePath, $fileSize, $index and $count. $index and $count are 1 for single videos.

Filename Sanitizing

File names are consist of video title and format extension. Video titles can contain any character but filesystems doesn't allow all characters. So filename should be sanitized first. by default there is a public method named pathSafeFilename that replaces unwanted characters (including space) to underscore (_). If you are not happy with this method, you can set a closure for sanitizeFileName property that receives a filename and returns sanitized filename.

Caption (Subtitle)

When you get video info, and array is also return named captions which it's keys are short language names and values are long names. You should pass one of those short names as the third parameter of download method to download in that language. Captions (subtitle) are downloaded in srt format. you can change this by passing one on srt, sub or ass to setCaptionFormat($format) method.
You can call setDefaultCaptionLanguage($language) with a short language name to download further captions in that language.

Please note that sub format depends on videos FPS (frame per second) and FPS is not known for all itags. So this may not work as excepted. It will be fixed in future.

Changes

see CHANGELOG.md.

Experimental Feature

I'm currently working on a pure php implementation of MP4 file editor and muxer. You can enable this feature by calling

As of now, it will set Track name, Artist and Cover Art of videos (and Track number for playlists) according to the video information. In near future releases all subtitles will be muxed in the MP4 file and in far future hopefully muxing adaptive files in one MP4 file will be added.

License

MIT, see LICENSE.


All versions of youtubedownloader with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
guzzlehttp/guzzle Version ~6.0
dflydev/apache-mime-types Version 1.0.*
nategood/commando Version ~0.2.8
dariuszp/cli-progress-bar Version ~1.0.2
debach/zend-mp3 Version ~1.8.1
patchwork/utf8 Version ~1.3.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package masih/youtubedownloader contains the following files

Loading the files please wait ....