libcast / assetdistribution
此包已被弃用,不再维护。没有建议的替代包。
PHP组件,可在多个服务中发布数字资产(视频、音频...)。目前支持YouTube、Vimeo和Dailymotion。
v2.0.1
2016-04-24 15:43 UTC
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是一个PHP组件,可以在多个服务中发布数字资产(视频、音频...)。
目前,AssetDistributor可以在YouTube、Vimeo和Dailymotion上发布视频。欢迎帮助并集成新适配器以支持新服务。
词汇表
-
Asset
— 描述以下类型之一的数字媒体:audio
、document
、image
或video
。 -
Adapter
— 实现一个用于upload
、update
或delete
Asset
对象的service
。 -
AdapterCollection
— 包含多个Adapter
对象,并且是可遍历的。 -
Owner
— 处理一个AdapterCollection
以及相应的services
账户凭证。
安装
可以通过composer添加此组件。
composer require libcast/assetdistributor
配置
所有应用程序的oAuth凭证或任何其他配置必须存储在PHP配置文件中。您可以查看example/configuration.ini
作为示例。
使用方法
首先创建一个名为"me"的Owner
来承载账户凭证和一个AdapterCollection
。
$cache = new \Doctrine\Common\Cache\FilesystemCache('/tmp'); // Doctrine Cache is a dependency $owner = new Owner('me', $cache);
然后从现有文件创建一个Asset
。
$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');
您可以手动创建一个AdapterCollection
。
/** @var string $configPath Path to the PHP configuration file */ $adapters = new AdapterCollection; $adapters[] = new YouTubeAdapter($owner, $configPath); $adapters[] = new VimeoAdapter($owner, $configPath);
您也可以从缓存中检索AdapterCollection
。
$adapters = AdapterCollection::retrieveFromCache($owner, $configPath);
或者您可以根据Asset
创建一个AdapterCollection
。
$adapters = AdapterCollection::buildForAsset($asset, $owner, $configPath);
一旦创建,必须将AdapterCollection
关联到Owner
。
$owner->setAdapters($adapters);
此时,您可以通过以下方式操作所有服务的Asset
:
// 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);