PHP Class to download videos from YouTube.
Switch branches/tags
Nothing to show
Clone or download
eyecatchup Updated get_url_map(), fix grabbing file location
Due to changes on YT's side, the regular expression in get_url_map() didn't worked any more. Thus, the function always returned "Grabbing original file location(s) failed.". Regex was updated to work again.
Latest commit fd201e2 Dec 10, 2012

yt_downloader - PHP class to download videos from YouTube and/or convert them to mp3 audio files.


This PHP class takes a YouTube URL (or YouTube Video-ID) and downloads the video to your computer. Optionally, you can convert any YouTube video to an MP3 Audio file (requires ffmpeg to be installed!).

UI Demo

For an example integration, try the demo:


The latest stable version can be downloaded from the downloads tab, or using the following link:

The UI demo code is available here:

Basic Usage

Usage is pretty straight forward:

    try {
        // Instantly download a YouTube video (using the default settings).
        new yt_downloader('', TRUE);

        // Instantly download a YouTube video as MP3 (using the default settings).
        new yt_downloader('', TRUE, 'audio');
    catch (Exception $e) {

You can provide either a YouTube URL (as used in the example), or a Youtube Video-ID. The class will check whether the given input value is a YouTube URL, or a YouTube Video-ID . If it's a URL, the ID will be extracted automatically. So,

new yt_downloader(""); is identical to new yt_downloader(""); is identical to new yt_downloader("aahOEZKTCzU");.

For more (advanced) examples see the example-*.php files.


Use the youtube-dl.config.php file to set your download preferences.

(c) 2012, Stephan Schmitz