diff --git a/composer.json b/composer.json index 12602a3..ed7e194 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "namshi/jose": "^6.0 || ^7.0", "jms/serializer": "^1.0", "guzzlehttp/guzzle": "^5.0 || ^6.0", - "movingimage/video-manager-meta": "dev-master", + "movingimage/video-manager-meta": "^1.5", "psr/cache": "^1.0", "cache/void-adapter": "^1.0" }, diff --git a/lib/ApiClient/AbstractApiClient.php b/lib/ApiClient/AbstractApiClient.php index adadfe6..010bf79 100644 --- a/lib/ApiClient/AbstractApiClient.php +++ b/lib/ApiClient/AbstractApiClient.php @@ -10,8 +10,12 @@ use MovingImage\Client\VMPro\Entity\EmbedCode; use MovingImage\Client\VMPro\Entity\Video; use MovingImage\Client\VMPro\Entity\Attachment; +use MovingImage\Client\VMPro\Entity\VideoDownloadUrl; use MovingImage\Client\VMPro\Entity\VideoRequestParameters; use MovingImage\Client\VMPro\Entity\VideosRequestParameters; +use MovingImage\Client\VMPro\Entity\VideoThumbnailCollection; +use MovingImage\Client\VMPro\Entity\VideoTranscodingStatus; +use MovingImage\Client\VMPro\Exception; use MovingImage\Client\VMPro\Interfaces\ApiClientInterface; use MovingImage\Client\VMPro\Util\ChannelTrait; use MovingImage\Client\VMPro\Util\Logging\Traits\LoggerAwareTrait; @@ -150,6 +154,20 @@ public function getVideoUploadUrl($videoManagerId, $videoId) : $response->getHeader('location'); } + /** + * {@inheritdoc} + */ + public function getVideoDownloadUrls($videoManagerId, $videoId) + { + $response = $this->makeRequest('GET', sprintf('videos/%s/download-urls', $videoId), [ + self::OPT_VIDEO_MANAGER_ID => $videoManagerId, + ]); + + $response = $response->getBody()->getContents(); + + return $this->deserialize($response, 'ArrayCollection<'.VideoDownloadUrl::class.'>'); + } + /** * {@inheritdoc} */ @@ -284,4 +302,116 @@ public function searchChannels($videoManagerId, ChannelsRequestParameters $param return $collection; } + + /** + * {@inheritdoc} + */ + public function getTranscodingStatus($videoManagerId, $videoId) + { + $response = $this->makeRequest('GET', sprintf('videos/%s/transcoding-status', $videoId), [ + self::OPT_VIDEO_MANAGER_ID => $videoManagerId, + ]); + + $response = $response->getBody()->getContents(); + + return $this->deserialize($response, 'ArrayCollection<'.VideoTranscodingStatus::class.'>'); + } + + /** + * {@inheritdoc} + */ + public function getThumbnailCollection($videoManagerId, $videoId) + { + $response = $this->makeRequest('GET', sprintf('videos/%s/thumbnails', $videoId), [ + self::OPT_VIDEO_MANAGER_ID => $videoManagerId, + ]); + + $response = $response->getBody()->getContents(); + + return $this->deserialize($response, 'ArrayCollection<'.VideoThumbnailCollection::class.'>'); + } + + /** + * {@inheritdoc} + */ + public function createThumbnailForVideo($videoManagerId, $videoId) + { + $response = $this->makeRequest('POST', sprintf('videos/%s/thumbnails', $videoId), [ + self::OPT_VIDEO_MANAGER_ID => $videoManagerId, + ]); + + return $response->getHeader('Location'); + } + + /** + * {@inheritdoc} + */ + public function getThumbnailUploadUrl($videoManagerId, $videoId, $thumbnailId) + { + $response = $this->makeRequest('GET', sprintf('videos/%s/thumbnails/%s/upload-url', $videoId, $thumbnailId), [ + self::OPT_VIDEO_MANAGER_ID => $videoManagerId, + ]); + + return $response->getHeader('Location'); + } + + /** + * {@inheritdoc} + */ + public function publishVideoAsset($videoManagerId, $videoId) + { + $json = $this->buildJsonParameters(['published' => 'true'], ['downloadable' => 'true']); + $response = $this->makeRequest('PATCH', sprintf('videos/%s', $videoId), [ + self::OPT_VIDEO_MANAGER_ID => $videoManagerId, + 'json' => $json + ]); + + return $response->getStatusCode(); + } + + /** + * {@inheritdoc} + */ + public function updateSpecificThumbnail($videoManagerId, $videoId, $thumbnailId) + { + $json = $this->buildJsonParameters(['active' => 'true'], []); + $response = $this->makeRequest('PATCH', sprintf('videos/%s/thumbnails/%s', $videoId, $thumbnailId), [ + self::OPT_VIDEO_MANAGER_ID => $videoManagerId, + 'json' => $json + ]); + + return $response->getStatusCode(); + } + + /** + * @param $videoManagerId + * @return string + * @throws \Exception + */ + public function getAdConfigurations($videoManagerId) + { + $response = $this->makeRequest('GET', 'ad_configurations', [ + self::OPT_VIDEO_MANAGER_ID => $videoManagerId, + ]); + + return $response->getBody()->getContents(); + } + + /** + * @param $videoManagerId + * @param $videoId + * @param array $params + * @return int + * @throws \Exception + */ + public function updateVideoData($videoManagerId, $videoId, array $params = []) + { + $response = $this->makeRequest('PATCH', sprintf('videos/%s', $videoId), [ + self::OPT_VIDEO_MANAGER_ID => $videoManagerId, + 'json' => $params, + ]); + + return $response->getStatusCode(); + } } + diff --git a/lib/Entity/VideoDownloadUrl.php b/lib/Entity/VideoDownloadUrl.php new file mode 100644 index 0000000..9539aa7 --- /dev/null +++ b/lib/Entity/VideoDownloadUrl.php @@ -0,0 +1,136 @@ +quality; + } + + /** + * @param string $quality + * + * @return VideoDownloadUrl + */ + public function setQuality($quality) + { + $this->quality = $quality; + + return $this; + } + + /** + * @return string + */ + public function getProfileKey() + { + return $this->profileKey; + } + + /** + * @param string $profileKey + * + * @return VideoDownloadUrl + */ + public function setProfileKey($profileKey) + { + $this->profileKey = $profileKey; + + return $this; + } + + /** + * @return string + */ + public function getFileExtension() + { + return $this->fileExtension; + } + + /** + * @param string $fileExtension + * + * @return VideoDownloadUrl + */ + public function setFileExtension($fileExtension) + { + $this->fileExtension = $fileExtension; + + return $this; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + * + * @return VideoDownloadUrl + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return int + */ + public function getFileSize() + { + return $this->fileSize; + } + + /** + * @param int $fileSize + * + * @return VideoDownloadUrl + */ + public function setFileSize($fileSize) + { + $this->fileSize = $fileSize; + + return $this; + } +} diff --git a/lib/Entity/VideoThumbnail.php b/lib/Entity/VideoThumbnail.php new file mode 100644 index 0000000..9d28b8a --- /dev/null +++ b/lib/Entity/VideoThumbnail.php @@ -0,0 +1,87 @@ +") + */ + private $dimension; + + /** + * @return mixed + */ + public function getQuality() + { + return $this->quality; + } + + /** + * @param string $quality + * + * @return $this + */ + public function setQuality($quality) + { + $this->quality = $quality; + + return $this; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param mixed $url + * + * @return $this + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * @return mixed + */ + public function getDimension() + { + return $this->dimension; + } + + /** + * @param mixed $dimension + * + * @return $this + */ + public function setDimension($dimension) + { + $this->dimension = $dimension; + + return $this; + } +} \ No newline at end of file diff --git a/lib/Entity/VideoThumbnailCollection.php b/lib/Entity/VideoThumbnailCollection.php new file mode 100644 index 0000000..db6defb --- /dev/null +++ b/lib/Entity/VideoThumbnailCollection.php @@ -0,0 +1,95 @@ +") + */ + private $items; + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * @param mixed $id + * + * @return VideoThumbnailCollection + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * @return mixed + */ + public function getActive() + { + return $this->active; + } + + /** + * @return bool + */ + public function isActive() + { + return $this->active; + } + + /** + * @param mixed $active + * + * @return VideoThumbnailCollection + */ + public function setActive($active) + { + $this->active = $active; + + return $this; + } + + /** + * @return mixed + */ + public function getItems() + { + return $this->items; + } + + /** + * @param mixed $items + * + * @return VideoThumbnailCollection + */ + public function setItems($items) + { + $this->items = $items; + + return $this; + } +} \ No newline at end of file diff --git a/lib/Entity/VideoTranscodingStatus.php b/lib/Entity/VideoTranscodingStatus.php new file mode 100644 index 0000000..f7e6948 --- /dev/null +++ b/lib/Entity/VideoTranscodingStatus.php @@ -0,0 +1,115 @@ +quality; + } + + /** + * @param string $quality + * + * @return VideoTranscodingStatus + */ + public function setQuality($quality) + { + $this->quality = $quality; + + return $this; + } + + /** + * @return string + */ + public function getProfileKey() + { + return $this->profileKey; + } + + /** + * @param string $profileKey + * + * @return VideoTranscodingStatus + */ + public function setProfileKey($profileKey) + { + $this->profileKey = $profileKey; + + return $this; + } + + /** + * @return string + */ + public function getFileExtension() + { + return $this->fileExtension; + } + + /** + * @param string $fileExtension + * + * @return VideoTranscodingStatus + */ + public function setFileExtension($fileExtension) + { + $this->fileExtension = $fileExtension; + + return $this; + } + + /** + * @return mixed + */ + public function getTranscodingCompleted() + { + return $this->transcodingCompleted; + } + + /** + * @param mixed $transcodingCompleted + * + * @return VideoTranscodingStatus + */ + public function setTranscodingCompleted($transcodingCompleted) + { + $this->transcodingCompleted = $transcodingCompleted; + + return $this; + } +} \ No newline at end of file diff --git a/lib/Interfaces/ApiClientInterface.php b/lib/Interfaces/ApiClientInterface.php index 88bd0bd..f0bd600 100644 --- a/lib/Interfaces/ApiClientInterface.php +++ b/lib/Interfaces/ApiClientInterface.php @@ -2,12 +2,14 @@ namespace MovingImage\Client\VMPro\Interfaces; +use Doctrine\Common\Collections\ArrayCollection; use MovingImage\Client\VMPro\Collection\ChannelCollection; use MovingImage\Client\VMPro\Collection\VideoCollection; use MovingImage\Client\VMPro\Entity\Attachment; use MovingImage\Client\VMPro\Entity\Channel; use MovingImage\Client\VMPro\Entity\ChannelsRequestParameters; use MovingImage\Client\VMPro\Entity\EmbedCode; +use MovingImage\Client\VMPro\Entity\VideoDownloadUrl; use MovingImage\Client\VMPro\Entity\VideoRequestParameters; use MovingImage\Client\VMPro\Entity\VideosRequestParameters; use MovingImage\Client\VMPro\Entity\Video; @@ -80,6 +82,16 @@ public function getVideos($videoManagerId, VideosRequestParameters $parameters = */ public function getVideoUploadUrl($videoManagerId, $videoId); + /** + * Get the Download URLs for a specific video. + * + * @param int $videoManagerId + * @param string $videoId + * + * @return ArrayCollection|VideoDownloadUrl[] + */ + public function getVideoDownloadUrls($videoManagerId, $videoId); + /** * Update a video with new values. *