Added a simple JSON API for getting information about the video
Error correction and optimization
Added the ability to choose the download method: "Download via client" or "Download via server"
PHP 5.3 or higher
Download the script to a folder on your web server
Open the link in the browser http://you_server/path_to_downloader/
Enter the youtube link in the input field and click on the "Get download links"
If the link is correct, a page with information about the video and a table of various formats for download will open
In most cases, the "Download via client" button will work - this is a direct link to the resource from the server youtube, which will open in the user's browser
For some videos, youtube generates direct links available ONLY for the same IP with which this link was requested, hence such a link will not open on the client. You can bypass this restriction by uploading video through your server and giving the uploaded stream to the client. The "Download via server" button does this. Attention: loading a video in this way will increase the load on your server.
The entry point for the JSON API is located at http://you_server/path_to_downloader/api.php
Request information about the video
Send request: GET http://you_server/path_to_downloader/api.php?action=info&id=youtube_id Response:
"name": "Video name",
"previewUrl": "Url to preview video image, e.g. https://img.youtube.com/vi/RCXnOsc5ajY/hqdefault.jpg",
"description": "Video description"
"downloadInfo": [ // array of file formats
"fileSize": "file size in bytes, e.g. 101055832",
"fileSizeHuman": "a human-readable file size, e.g. 96.37 MB",
"url": "direct download link for 'download via client'",
"youtubeItag": "itag format for file, e.g. 43",
"fileType": "MIME file type, e.g. video/webm",
"name": "file name, e.g. Bio-Dome - Nostalgia Critic.webm",
"format": "file extension, e.g. mp4",
"withVideo": "true if the file contains a video",
"withAudio": "true if the file contains a audio"
//... other files
If an error occurs during the request, the response will be as follows:
A regular license allows an item to be used in one project for either personal or commercial use by you or on behalf of a client. The item cannot be offered for resale either on its own or as part of a project. Distribution of source files is not permitted.
An extended license allows an item to be used in unlimited projects for either personal or commercial use. The item cannot be offered for resale "as-is". It is allowed to distribute/sublicense the source files as part of a larger project.