libcast/assetdistribution

此包已被弃用,不再维护。没有建议的替代包。

PHP组件,可在多个服务中发布数字资产(视频、音频...)。目前支持YouTube、Vimeo和Dailymotion。

v2.0.1 2016-04-24 15:43 UTC

This package is auto-updated.

Last update: 2020-01-23 18:02:40 UTC


README

Scrutinizer Code Quality Build Status

AssetDistributor是一个PHP组件,可以在多个服务中发布数字资产(视频、音频...)。

目前,AssetDistributor可以在YouTube、Vimeo和Dailymotion上发布视频。欢迎帮助并集成新适配器以支持新服务。

词汇表

  • Asset — 描述以下类型之一的数字媒体:audiodocumentimagevideo

  • Adapter — 实现一个用于uploadupdatedelete 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);