2017 © Pedro Peláez
 

library php-video-url-parser

A Simple and efficient PHP Video URL Parser that gives you thumbnails and embed codes for various services as Youtube, Vimeo, DailyMotion and Facebook

image

ricardofiorani/php-video-url-parser

A Simple and efficient PHP Video URL Parser that gives you thumbnails and embed codes for various services as Youtube, Vimeo, DailyMotion and Facebook

  • Saturday, July 28, 2018
  • by ricardofiorani
  • Repository
  • 2 Watchers
  • 29 Stars
  • 6,373 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 3 Open issues
  • 11 Versions
  • 17 % Grown

The README.md

DEPRECATED !

If you have PHP 7.4 or newer then please use https://github.com/ricardofiorani/oembed instead.
This lib will receive only small bugfixes, not new features anymore., (*1)

PHP Video URL Parser

Build Status Minimum PHP Version License Total Downloads Coding Standards Scrutinizer Code Quality Code Coverage, (*2)

PHP Video URL Parser is a parser that detects a given video url and returns an object containing information like the video's embed code, title, description, thumbnail and other information that the service's API may give., (*3)

Installation

Install the latest version with, (*4)

$ composer require ricardofiorani/php-video-url-parser

Requirements

  • PHP 5.3
  • cURL (Or at least file_get_contents() enabled if you want to use it with Vimeo, otherwise it's not required)

Basic Usage

<?php
use RicardoFiorani\Matcher\VideoServiceMatcher;

require __DIR__ . '/vendor/autoload.php';

$vsm = new VideoServiceMatcher();

//Detects which service the url belongs to and returns the service's implementation
//of RicardoFiorani\Adapter\VideoAdapterInterface
$video = $vsm->parse('https://www.youtube.com/watch?v=PkOcm_XaWrw');

//Checks if service provides embeddable videos (most services does)
if ($video->isEmbeddable()) {
    //Will echo the embed html element with the size 200x200
    echo $video->getEmbedCode(200, 200);

    //Returns the embed html element with the size 1920x1080 and autoplay enabled
    echo $video->getEmbedCode(1920, 1080, true);

    //Returns the embed html element with the size 1920x1080, autoplay enabled and force the URL schema to be https.
    echo $video->getEmbedCode(1920, 1080, true, true);
}

//If you don't want to check if service provides embeddable videos you can try/catch
try {
    echo $video->getEmbedUrl();
} catch (\RicardoFiorani\Exception\NotEmbeddableException $e) {
    die(sprintf("The URL %s service does not provide embeddable videos.", $video->getRawUrl()));
}

//Gets URL of the smallest thumbnail size available
echo $video->getSmallThumbnail();

//Gets URL of the largest thumbnail size available
//Note some services (such as Youtube) does not provide the largest thumbnail for some low quality videos (like the one used in this example)
echo $video->getLargestThumbnail();

Registering your own service video (it's easy !)

If you want to register an implementation of some service your class just needs to implement the "RicardoFiorani\Adapter\VideoAdapterInterface" or extend the RicardoFiorani\Adapter\AbstractServiceAdapter, (*5)

A Fully functional example can be found Here., (*6)

PS: If you've made your awesome implementation of some well known service, feel free to send a Pull Request. All contributions are welcome :), (*7)

Using your own framework's template engine

A Fully functional example can be found Here., (*8)

Currently Suported Services

  • Youtube
  • Vimeo
  • Dailymotion
  • Facebook Videos

Currently Supported PHP Versions

  • PHP 5.3
  • PHP 5.4
  • PHP 5.5
  • PHP 5.6
  • PHP 7.0
  • PHP 7.1
  • PHP 7.2

Please note that lib is not passing tests on HHVM, therefore, we can't guarantee it will work properly. Please use it on your own risk., (*9)

The Versions

28/07 2018

dev-general_improvements

dev-general_improvements

A Simple and efficient PHP Video URL Parser that gives you thumbnails and embed codes for various services as Youtube, Vimeo, DailyMotion and Facebook

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Ricardo Fiorani

17/04 2018

1.0.x-dev

1.0.9999999.9999999-dev

A Simple and efficient PHP Video URL Parser that gives you thumbnails and embed codes for various services as Youtube, Vimeo, DailyMotion and Facebook

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani

17/04 2018

dev-master

9999999-dev

A Simple and efficient PHP Video URL Parser that gives you thumbnails and embed codes for various services as Youtube, Vimeo, DailyMotion and Facebook

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani

17/04 2018

v1.0.0

1.0.0.0

A Simple and efficient PHP Video URL Parser that gives you thumbnails and embed codes for various services as Youtube, Vimeo, DailyMotion and Facebook

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani

16/04 2018

v0.4.0

0.4.0.0

A Simple and efficient PHP Video URL Parser that gives you thumbnails and embed codes for various services as Youtube, Vimeo, DailyMotion and Facebook

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani

17/03 2016

v0.3.1

0.3.1.0

PHP Video URL Parser is a simple video url parser.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani

11/02 2016

v0.3

0.3.0.0

PHP Video URL Parser is a simple video url parser.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani

26/11 2015

0.2.2

0.2.2.0

PHP Video URL Parser is a simple video url parser.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani

03/09 2015

v0.2.1

0.2.1.0

PHP Video URL Parser is a simple video url parser.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani

01/09 2015

0.2

0.2.0.0

PHP Video URL Parser is a simple video url parser.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani

31/08 2015

0.1

0.1.0.0

PHP Video URL Parser is a simple video url parser.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Ricardo Fiorani