libcast / assetdistribution
PHP component that can publish digital assets (video, audio...) across multiple services. Currently supports YouTube, Vimeo and Dailymotion.
Installs: 1 370
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 4
Forks: 3
Open Issues: 0
pkg:composer/libcast/assetdistribution
Requires
- dailymotion/sdk: ~1.6
- doctrine/cache: ~1.0
- google/apiclient: v2.0.0-RC5
- league/flysystem: ~1.0
- psr/log: ~1.0
- symfony/http-foundation: ~3.0
- vimeo/vimeo-api: ~1.2
Requires (Dev)
- monolog/monolog: ~1.0
- phpunit/phpunit: ~3.7
README
AssetDistributor is a PHP component that can publish digital assets (video, audio...) across multiple services.
Currently, AssetDistributor can publish videos across YouTube, Vimeo and DailyMotion. Feel free to help and integrate new Adapters for new services.
Vocabulary
-
Asset— describes a digital media of one of the following type :audio,document,imageorvideo. -
Adapter— implements aservicetoupload,updateordeleteAssetobjetcs from. -
AdapterCollection— contains multipleAdapterobjects and is traversable -
Owner— handles anAdapterCollectionand the correspondingservicesaccount credentials.
Installation
The component may be added through composer :
composer require libcast/assetdistributor
Configuration
All your application oAuth credentials or any other configuration must be stored in a PHP configuration file.
You may have a look on example/configuration.ini as an example.
Usage
First create an Owner called "me" to bear accounts credentials and an AdapterCollection
$cache = new \Doctrine\Common\Cache\FilesystemCache('/tmp'); // Doctrine Cache is a dependency $owner = new Owner('me', $cache);
Then create an Asset from an existing file
$asset = AssetFactory::build( "$root/tests/video.mp4", // path to file of a Flysystem\File object 'My Video', // optional title 'This is an awesome video', // optional description ['test', 'asset-distributor'] // optional array of tags ); $asset->setVisibility('private');
You may create an AdapterCollection manually:
/** @var string $configPath Path to the PHP configuration file */ $adapters = new AdapterCollection; $adapters[] = new YouTubeAdapter($owner, $configPath); $adapters[] = new VimeoAdapter($owner, $configPath);
You also can retrieve the AdapterCollection from the cache:
$adapters = AdapterCollection::retrieveFromCache($owner, $configPath);
Or you can create an AdapterCollection based on the Asset :
$adapters = AdapterCollection::buildForAsset($asset, $owner, $configPath);
Once created, the AdapterCollection must be affiliated to the Owner
$owner->setAdapters($adapters);
At this point, you may manipulate your Asset across all services like this:
// Upload the Asset on all services $owner->upload($asset); $asset->setTitle('Different title'); $asset->addTag('foobar'); // Update the Asset on all services $owner->update($asset); // Delete the Asset on all services $owner->delete($asset);