Example #1
0
/**
 * Constructs a URL to get live remote assets from Ooyala API
 * @param integer $apiPageSize
 * @param integer $page
 * @param string $provider
 * @param string $keyword
 * @return string $url
 */
function getApiAssets($apiPageSize, $page, $provider, $keyword)
{
    $cond = array("status = 'live'", "asset_type = 'remote_asset'", "metadata.source = '{$provider}'");
    if (!empty($keyword)) {
        $cond[] = "metadata.keywords = '{$keyword}'";
    }
    $params = array('limit' => $apiPageSize, 'where' => implode(' AND ', $cond));
    if (!empty($page)) {
        $parsed = explode("?", $page);
        parse_str(array_pop($parsed), $params);
    }
    $method = 'GET';
    $reqPath = '/v2/assets';
    $url = OoyalaApiWrapper::getApi($method, $reqPath, $params);
    return $url;
}
     $skipped++;
     continue;
 }
 // skip if 'name' field exists
 if (array_key_exists('name', $video['metadata'])) {
     echo " ... SKIPPED ('name' field found in metadata. metadata already mapped).\n";
     $skipped++;
     continue;
 }
 // backup data to csv file
 if (!empty($backupFile)) {
     backupFile($backupFile, $msg, $video);
 }
 // get provider
 $label = OoyalaApiWrapper::getProviderName($video['labels']);
 $label = empty($label) ? "No provider name" : OoyalaApiWrapper::formatProviderName($label);
 echo " ({$label})";
 $newMeta = mapMetadata($ingester, $video['metadata']);
 if (!array_key_exists('name', $newMeta)) {
     $newMeta['name'] = '';
 }
 echo " ... DONE \n\tNEW Metadata:\n";
 compareMetadata($video['metadata'], $newMeta);
 if (!$dryRun) {
     $resp = OoyalaAsset::updateMetadata($video['embed_code'], $newMeta);
     if (!$resp) {
         $failed++;
     }
 }
 if ($compareWithFile) {
     compareMetadataFile($video, $msg, $newMeta);
Example #3
0
 /**
  * Send request
  * @param string $method
  * @param string $reqPath
  * @param array $params
  * @return boolean $result
  */
 protected function sendRequest($method, $reqPath, $params = [])
 {
     wfProfileIn(__METHOD__);
     $reqBody = empty($params) ? '' : json_encode($params);
     $url = OoyalaApiWrapper::getApi($method, $reqPath, [], $reqBody);
     //print( "Connecting to $url...\n" );
     $options = ['method' => $method, 'postData' => $reqBody, 'noProxy' => true];
     $req = MWHttpRequest::factory($url, $options);
     $status = $req->execute();
     if ($status->isGood()) {
         $result = true;
         print "Ooyala: sent {$reqPath} request: \n";
     } else {
         $result = false;
         print "ERROR: problem sending {$reqPath} request (" . $status->getMessage() . ").\n";
     }
     wfProfileOut(__METHOD__);
     return $result;
 }
 /**
  * get feed url
  * @param array $params
  * @param string $nextPage
  * @return string $url
  */
 private function initFeedUrl($params, $nextPage)
 {
     $method = 'GET';
     $reqPath = '/v2/assets';
     if (!empty($nextPage)) {
         $parsed = explode("?", $nextPage);
         parse_str(array_pop($parsed), $params);
     }
     $url = OoyalaApiWrapper::getApi($method, $reqPath, $params);
     return $url;
 }