Little YouTube PHP: Search and get data from YouTube videos

Recommend this page to a friend!
  Info   Documentation   View files (11)   Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 294 This week: 1All time: 7,354 This week: 242
Version License PHP version Categories
little-youtube-php 1.0.0The PHP License5PHP 5, Web services
Description Author

This package can search and get data from YouTube videos.

It calls YouTube API to retrieves several types of information about videos, playlist, channels and search results. Currently it can:

- Video: get video image preview, get embed link, parse subtitle, get video data
- Channel: get RSS URL, get channel data,
- Playlist: get playlist data
- Search: get search data, next result, previous result

Picture of StefansArya
  Performance   Level  
Name: StefansArya <contact>
Classes: 1 package by
Country: Indonesia Indonesia
Age: 23
All time rank: 376163 in Indonesia Indonesia
Week rank: 246 6 in Indonesia Indonesia


<a href=""><img src="" height="20"></a> Build Status Latest Version Software License


Have you ever dreamed put your own channel on your own website? LittleYoutube is here to help you

> Note: > Please use this library for fair use when downloading any youtube content. If you want to display youtube video to your website, please embed youtube link rather than download it. And don't ever use this for commercial use.

Table of contents

- LittleYoutube - Table of contents - Getting Started - Download via composer - Sample Usage - Documentation - LittleYoutube Options - Video Class

  - Get video image preview
  - Get embed link
  - Parse subtitle
  - Get video data

- Channel Class

  - Get RSS URL
  - Get channel data

- Playlist Class

  - Get playlist data

- Search Class

  - Get search data
  - Next result
  - Previous result

- Get last error message - Change settings dynamically - Contribution - License

Getting Started

> * Clone/download this repo > * Include LittleYoutube.php to your php script

Download via composer

Add LittleYoutube to composer.json configuration file.

$ composer require scarletsfiction/littleyoutube

And update it

$ composer update

Sample Usage

    // require 'vendor/autoload.php';
    require_once "LittleYoutube.php";

    use ScarletsFiction\LittleYoutube;

    $video = LittleYoutube::video("");
    echo("Video ID:".$video->data['videoID']."\n");


LittleYoutube Options

Available options


Video Class

> $video = LittleYoutube::video("videoURLHere", options); > > //Reinit video class > $video->init("videoURLHere");

Return video class

Get video image preview

> $video->getImage();

Return Indexed Array

[ "HighQualityURL", "MediumQualityURL", "DefaultQualityURL" ]

Get embed link

> $video->getEmbedLink();

// Usually we will wrap it with iframe

echo('<iframe width="480" height="360" src="'.$video->getEmbedLink().'" frameborder="0" allowfullscreen></iframe>');

Parse subtitle

> $video->parseSubtitle(args, asSRT); > > * args: subtitle index or xml string > * asSRT: return as srt format > * note: if you pass subtitle index, ProcessDetails must be enabled/called

        [time] => 1.31,
        [duration] => 6.609,
        [text]=>"in a single lifetime we can take a days"

Get video data

> $video->data; > > * You can also call $video->processDetails() to refresh data

Return Associative Array of current video data


    //When ProcessDetail was enabled/called
    "playerID", "title", "duration", "viewCount", "like", "dislike", "author", "subtitle", "uploaded", "description", "metatag", "channelID",

    // Not available when ProcessDetails = false
            [0] => {
                    [0] => Media    //video
                    [1] => Format   //mp4
                    [2] => Encoder  //avc1.64001F, mp4a.40.2
                "expire",  //timestamp
                "quality", //hd720, medium, small
                "size" //When loadVideoSize was enabled
            [0] => {
                    [0] => Media    //video
                    [1] => Format   //mp4
                    [2] => Encoder  //avc1.4d401f
                "expire",  //timestamp
                "quality", //1080p, 720p, 192k, 144k
                "size" //When loadVideoSize was enabled

        //If it's a live stream, then return m3u8 url only

    //When signatureDebug was enabled
        "playerID", //Log for current playerID 
        "log" //Last video log

Channel Class

> $channel = LittleYoutube::channel("channelURLHere", options); > > //Reinit channel class > $channel->init("channelURLHere");

Return channel class


> $channel->getChannelRSS();

Return string

Get channel data

> $channel->data; > > * You can also call $channel->processDetails() to refresh data

Return Associative Array of current channel data

    //Some data will available when ProcessDetail was enabled/called
    "channelID", "userID",

            "title", "playlistID"
    "videos"=> [
            "title", "duration", "videoID"

Playlist Class

> $playlist = LittleYoutube::playlist("playlistURLHere", options); > > //Reinit playlist class > $playlist->init("playlistURLHere");

Return playlist class

Get playlist data

> $playlist->data; > > * You can also call $playlist->processDetails() to refresh data

Return string

  //Some data will available when ProcessDetail was enabled/called
  "playlistID", "channelID", "userID",

    "name", image

      "title", "videoID"

Search Class

> $search = LittleYoutube::search("searchQueryHere", options); > > //Reinit search class > $search->init("searchQueryHere");

Return search class

Get search data

> $search->data; > > * You can also call $search->processDetails() to refresh data

Return string


  // Not available when ProcessDetails = false
      "videoID", "title", "duration", "userID", "userName", "uploaded", "views"

  //When available
  "next", "previous"

Next result

> $search->next();

This will add result from the next page to current data

Previous result

> $search->previous();

This will add result from the previous page to current data > Actually this is useless might

Get last error message

> $classes->error;

Return string

errorMsg //Failed to do stuff

Change settings dynamically

You can also change the settings after initialize LittleYoutube class > $classes->settings[options] = value;


If you want to help in LittleYoutube library, please make it even better and start a pull request into it.

Keep it simple and keep it clear.


LittleYoutube is under the GPL license.

File Role Description
example (4 files)
tests (1 file)
.travis.yml Data Auxiliary data
composer.json Data Auxiliary data
LICENSE Lic. License text
LittleYoutube.php Class Class source
phpunit.xml Data Auxiliary data Doc. Documentation

  Files  /  example  
File Role Description
   base.php Example Example script
   index.php Aux. Auxiliary script
   script.js Data Auxiliary data
   style.css Data Auxiliary data

  Files  /  tests  
File Role Description
   index.php Example Example script

 Version Control Unique User Downloads Download Rankings  
This week:1
All time:7,354
This week:242

For more information send a message to info at phpclasses dot org.