diff --git a/library/Unl/Plist.php b/library/Unl/Plist.php index 0a7e33bf778c0e4f74aece70053600233efd5704..82ae14b9ed01591598f27809d6b40e572f5cd616 100644 --- a/library/Unl/Plist.php +++ b/library/Unl/Plist.php @@ -19,6 +19,7 @@ class Unl_Plist static public function arrayToPlist($array) { $dom = new DOMDocument('1.0', 'UTF-8'); + $dom->formatOutput = true; $root = $dom->createElement('plist'); $root->setAttribute('version', '1.0'); $dom->appendChild($root); diff --git a/library/Unl/Service/PodcastProducer.php b/library/Unl/Service/PodcastProducer.php index 32fc3ecaaf8a916cbca93f401fdc82c819d58f60..12adb5760b14cfd5ec66434cf7ec4561808ddb96 100644 --- a/library/Unl/Service/PodcastProducer.php +++ b/library/Unl/Service/PodcastProducer.php @@ -43,6 +43,17 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract return Unl_Service_PodcastProducer_Workflow::fromXML($response); } + public function getWorkflow($uuid) + { + $selectedWorkflow = null; + foreach ($this->getWorkflows() as $workflow) { + if ($workflow->getUuid() == $uuid) { + $selectedWorkflow = $workflow; + } + } + return $selectedWorkflow; + } + public function getCameras() { $uri = clone $this->_uri; @@ -57,6 +68,17 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract return Unl_Service_PodcastProducer_Camera::fromXML($response); } + public function getCamera($uuid) + { + $selectedCamera = null; + foreach ($this->getCameras() as $camera) { + if ($camera->getUuid() == $uuid) { + $selectedCamera = $camera; + } + } + return $selectedCamera; + } + public function getCameraPreview(Unl_Service_PodcastProducer_Camera $camera) { curl_setopt($this->_curl, CURLOPT_URL, $camera->getPreviewUrl()); @@ -64,7 +86,7 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract return $response; } - public function createForFile(Unl_Service_PodcastProducer_Workflow $workflow, $filePath) + public function createForFile(Unl_Service_PodcastProducer_Workflow $workflow, $filePath, $metadata = array()) { $fileContents = file_get_contents($filePath); $fileSize = strlen($fileContents); @@ -101,13 +123,16 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract echo $response . "\n\n\n"; + $plist = Unl_Plist::arrayToPlist($metadata); + $plistLength = strlen($plist); + curl_setopt($this->_curl, CURLOPT_URL, $uploadUri); curl_setopt($this->_curl, CURLOPT_HTTPHEADER, array( 'File-name: user_metadata.plist', 'Recording-UUID: ' . $recordingUUID )); curl_setopt($this->_curl, CURLOPT_POST, true); - curl_setopt($this->_curl, CURLOPT_POSTFIELDS, ''); + curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $plist); $response = curl_exec($this->_curl); echo $response . "\n\n\n"; @@ -118,7 +143,7 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract curl_setopt($this->_curl, CURLOPT_POST, true); curl_setopt($this->_curl, CURLOPT_POSTFIELDS, 'submission_uuid=' . $UUID - . '&submitted_files=user_metadata.plist:0;' . $fileName . ':' . $fileSize + . '&submitted_files=user_metadata.plist:' . $plistLength . ';' . $fileName . ':' . $fileSize . '&primary_content_file=' . $fileName . '&recording_uuid=' . $recordingUUID );