PHP Classes

PHP Media Search Engine: Search multiple video sites for given keywords

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 62%Total: 344 All time: 7,051 This week: 524Up
Version License PHP version Categories
awesomemedia 1.0.0The PHP License5.3PHP 5, Searching, Web services, Audio, V...
Description 

Author

This package can search multiple video, audio and picture sites for given keywords.

It can send HTTP requests to the API Web servers of several sites to search for given keywords.

The package provides different classes for each site but the results are returned in arrays with the same format.

Currently it supports DailyMotion, YouTube, Vimeo, SoundCloud and Flickr.

Innovation Award
PHP Programming Innovation award nominee
May 2015
Number 5


Prize: SourceGuarding PHP encoder tool
Sometimes you need to search for videos that can be in multiple sites. Most popular video sites provide an API for searching for videos. However, each one returns results in a different format.

This package that can search multiple video and audio sites at the same time returning results in the same format for all sites.

Manuel Lemos
Picture of Ghali Ahmed
  Performance   Level  
Name: Ghali Ahmed <contact>
Classes: 5 packages by
Country: Tunisia Tunisia
Age: 41
All time rank: 22618 in Tunisia Tunisia
Week rank: 192 Up1 in Tunisia Tunisia Up
Innovation award
Innovation award
Nominee: 3x

Example

<?php
$loader
= require '../vendor/autoload.php';
require
'config_dev.php';

use
MediaGateway\Provider\ProviderChain;
use
MediaGateway\ProviderClientFactory;
use
MediaGateway\Provider\YoutubeProvider;
use
MediaGateway\Provider\VimeoProvider;
use
MediaGateway\Provider\DailymotionProvider;
use
MediaGateway\Provider\SoundcloudProvider;
use
MediaGateway\Provider\FlickrProvider;

$providerChain = new ProviderChain();

$providerChain->addProviders([
    new
YoutubeProvider(new MediaGateway\Client\YoutubeClient($youtubeConfig)),
    new
VimeoProvider(new MediaGateway\Client\VimeoClient($vimeoConfig)),
    new
DailymotionProvider(new MediaGateway\Client\DailymotionClient($dailymotionConfig)),
    new
SoundcloudProvider(new MediaGateway\Client\SoundcloudClient($soundcloudConfig)),
    new
FlickrProvider(new MediaGateway\Client\FlickrClient($flickerConfig))
]);

$query = new \MediaGateway\Query();
$query->setTerm('kittens')->setLimit(10);

$result = $providerChain->search($query);

print
'<pre>';
print_r($result);


Details

AwesomeMedia

Extensible MediaProvider management script that can query several provider such as Youtube/dailymotion/vimeo and return a list of normalized results.

Installation

Composer

Add the AwesomeMedia library to your composer.json file's require field

{
    "require" : {
        "ghaliano/AwesomeMedia" : "dev-master"
    }
}

How to use?

Client configuration

This is a typical configuration used on the demo https://github.com/ghaliano/awesome-media/blob/master/Demo/config.php

<?php
$youtubeConfig = [
    'developer_key' => null
];    
    
$dailymotionConfig = [
    'api_key' => null, 
    'secret_key'=> null
];

$vimeoConfig = [
    'api_key' => null, 
    'secret_key'=> null, 
    'access_token' => null
];

$soundcloudConfig = [
    'api_key' => '',
    'secret_key' => '',
    'login' => '',
    'password' => ''
];

Single provider

<?php
$loader = require '../vendor/autoload.php';
require 'config_dev.php';
use MediaGateway\ProviderClientFactory;
use MediaGateway\Provider\YoutubeProvider;
$youtubeProvider = new YoutubeProvider(
    ProviderClientFactory::create('youtube', $youtubeConfig)
);
$query = new \MediaGateway\Query();
$query->setTerm('kittens')->setLimit(10);
 
$result = $youtubeProvider->search($query);
print '<pre>';
print_r($result);

Multiple provider

The component use a Chain class to manipulate mutiple providers like one

<?php
$loader = require '../vendor/autoload.php';
require 'config_dev.php';
use MediaGateway\Provider\ProviderChain;
use MediaGateway\ProviderClientFactory;
use MediaGateway\Provider\YoutubeProvider;
use MediaGateway\Provider\VimeoProvider;
use MediaGateway\Provider\DailymotionProvider;
use MediaGateway\Provider\SoundcloudProvider;
use MediaGateway\Provider\FlickrProvider;
$providerChain = new ProviderChain();

$providerChain->addProviders([
    new YoutubeProvider(new MediaGateway\Client\YoutubeClient($youtubeConfig)),
    new VimeoProvider(new MediaGateway\Client\VimeoClient($vimeoConfig)),
    new DailymotionProvider(new MediaGateway\Client\DailymotionClient($dailymotionConfig)),
    new SoundcloudProvider(new MediaGateway\Client\SoundcloudClient($soundcloudConfig)),
    new FlickrProvider(new MediaGateway\Client\FlickrClient($flickerConfig))
]);

$query = new \MediaGateway\Query();
$query->setTerm('kittens')->setLimit(10);
$result = $providerChain->search($query);
print '<pre>';
print_r($result);

Demo

https://github.com/ghaliano/awesome-media/blob/master/Demo/demo.php

TODO

  • Only Search Future is now available: Adding more future (Upload/remove/update MEdia)
  • DATA formating can be in a separate class for each provider
  • Adding other Media type (only video provider are now implemented)
  • Adding test !!!

  Files folder image Files (36)  
File Role Description
Files folder imageDemo (3 files)
Files folder imageMediaGateway (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file README.md Doc. Auxiliary data

  Files folder image Files (36)  /  Demo  
File Role Description
  Accessible without login Plain text file config.php Conf. Configuration script
  Accessible without login Plain text file demo.php Example Example script
  Accessible without login Plain text file multipleDemo.php Example Example script

  Files folder image Files (36)  /  MediaGateway  
File Role Description
Files folder imagesrc (1 directory)

  Files folder image Files (36)  /  MediaGateway  /  src  
File Role Description
Files folder imageMediaGateway (6 files, 4 directories)

  Files folder image Files (36)  /  MediaGateway  /  src  /  MediaGateway  
File Role Description
Files folder imageClient (6 files)
Files folder imageModel (6 files)
Files folder imageNormalizer (5 files)
Files folder imageProvider (7 files)
  Plain text file MediaItemNormalizerInterface.php Class Class source
  Plain text file MediaProviderAuthenticationException.php Class Class source
  Plain text file MediaProviderClientInterface.php Class Class source
  Plain text file MediaProviderException.php Class Class source
  Plain text file MediaProviderInterface.php Class Class source
  Plain text file Query.php Class Class source

  Files folder image Files (36)  /  MediaGateway  /  src  /  MediaGateway  /  Client  
File Role Description
  Plain text file DailymotionClient.php Class Class source
  Plain text file FlickrClient.php Class Class source
  Plain text file MediaProviderClient.php Class Class source
  Plain text file SoundcloudClient.php Class Class source
  Plain text file VimeoClient.php Class Class source
  Plain text file YoutubeClient.php Class Class source

  Files folder image Files (36)  /  MediaGateway  /  src  /  MediaGateway  /  Model  
File Role Description
  Plain text file Dailymotion.php Class Class source
  Plain text file Flickr.php Class Class source
  Plain text file MediaProvider.php Class Class source
  Plain text file Soundcloud.php Class Class source
  Plain text file Vimeo.php Class Class source
  Plain text file Youtube.php Class Class source

  Files folder image Files (36)  /  MediaGateway  /  src  /  MediaGateway  /  Normalizer  
File Role Description
  Plain text file DailymotionNormalizer.php Class Class source
  Plain text file FlickrNormalizer.php Class Class source
  Plain text file SoundcloudNormalizer.php Class Class source
  Plain text file VimeoNormalizer.php Class Class source
  Plain text file YoutubeNormalizer.php Class Class source

  Files folder image Files (36)  /  MediaGateway  /  src  /  MediaGateway  /  Provider  
File Role Description
  Plain text file AbstractProvider.php Class Class source
  Plain text file DailymotionProvider.php Class Class source
  Plain text file FlickrProvider.php Class Class source
  Plain text file ProviderChain.php Class Class source
  Plain text file SoundcloudProvider.php Class Class source
  Plain text file VimeoProvider.php Class Class source
  Plain text file YoutubeProvider.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:344
This week:0
All time:7,051
This week:524Up
 User Ratings  
 
 All time
Utility:80%StarStarStarStarStar
Consistency:75%StarStarStarStar
Documentation:80%StarStarStarStarStar
Examples:70%StarStarStarStar
Tests:-
Videos:-
Overall:62%StarStarStarStar
Rank:907