/** * load metadata * @param array $overrideFields */ protected function loadMetadata(array $overrideFields = array()) { parent::loadMetadata($overrideFields); if (!isset($this->metadata['sourceId'])) { $this->metadata['sourceId'] = $this->getSourceId(); } }
public function getAspectRatio() { if (!empty($this->interfaceObj)) { return $this->interfaceObj['width'] / $this->interfaceObj['height']; } return parent::getAspectRatio(); }
protected function processResponse($response, $type) { wfProfileIn(__METHOD__); $replaced_count = 0; $response = str_replace("blip_ws_results([[{", "[{", $response, $replaced_count); if ($replaced_count > 0) { $response = str_replace("]);", "", $response); } else { $response = str_replace("blip_ws_results([{", "[{", $response, $replaced_count); $response = str_replace("]);", "]", $response); } wfProfileOut(__METHOD__); return parent::processResponse($response, $type); }
protected function loadMetadata(array $overrideFields = array()) { parent::loadMetadata($overrideFields); if ($this->isAgeGate()) { throw new WikiaException(wfMsg("videohandler-error-restricted-video")); } if (!isset($metadata['genres'])) { $metadata['genres'] = $this->getGenres(); } if (!isset($metadata['actors'])) { $metadata['actors'] = $this->getActors(); } if (!isset($metadata['uniqueName'])) { $metadata['uniqueName'] = $this->getUniqueName(); } if (!isset($metadata['videoUrl'])) { $metadata['videoUrl'] = $this->getVideoUrl(); } $this->metadata = array_merge($this->metadata, $metadata); }
/** * Handle response errors * @param $status - The response status object * @param $content - Json content from the provider * @param $apiUrl - The URL for the providers API * @throws VideoNotFoundException - Video cannot be found */ protected function checkForResponseErrors($status, $content, $apiUrl) { $error_code = ""; // true parameter here has json_decode return an array, rather than an object $error_json = json_decode($content, true); if (isset($error_json['error']['code'])) { $error_code = $error_json['error']['code']; } if ($error_code == self::VIDEO_NOT_FOUND_ERROR) { throw new VideoNotFoundException($status, $content, $apiUrl); } parent::checkForResponseErrors($status, $content, $apiUrl); }
public function getAspectRatio() { wfProfileIn(__METHOD__); $embed_code = $this->interfaceObj['video']['embed_code']; $matches = array(); $width = $height = null; if (preg_match('/width="(\\d+)"/', $embed_code, $matches)) { $width = $matches[1]; $matches = array(); if (preg_match('/height="(\\d+)"/', $embed_code, $matches)) { $height = $matches[1]; } } if ($width && $height) { wfProfileOut(__METHOD__); return $width / $height; } wfProfileOut(__METHOD__); return parent::getAspectRatio(); }
/** * Override method from parent class. * Firstly, set the value for $this->interfaceObj - by calling the parent method. * Secondly, check if 'items' key exists and if yes update value of $this->interfaceObj. */ protected function initializeInterfaceObject() { parent::initializeInterfaceObject(); if (!empty($this->interfaceObj['items'][0])) { $this->interfaceObj = $this->interfaceObj['items'][0]; } }
protected function checkForResponseErrors($status, $content, $apiUrl) { wfProfileIn(__METHOD__); if ($content == $this->videoId . ' not found.') { wfProfileOut(__METHOD__); throw new VideoNotFoundException($status, $content, $apiUrl); } wfProfileOut(__METHOD__); // return default parent::checkForResponseErrors($status, $content, $apiUrl); }
protected function loadMetadata(array $overrideFields = array()) { parent::loadMetadata($overrideFields); if (!isset($this->metadata['source'])) { $this->metadata['source'] = $this->getSource(); } if (!isset($this->metadata['sourceId'])) { $this->metadata['sourceId'] = $this->getSourceId(); } if (!isset($this->metadata['startDate'])) { $this->metadata['startDate'] = $this->getVideoStartDate(); } if (!isset($this->metadata['distributor'])) { $this->metadata['distributor'] = $this->getDistributor(); } if (!isset($this->metadata['pageCategories'])) { $this->metadata['pageCategories'] = $this->getPageCategories(); } }
protected function checkForResponseErrors($status, $content, $apiUrl) { wfProfileIn(__METHOD__); // check if still exists $code = $status->errors[0]['params'][0]; if ($code == 404) { wfProfileOut(__METHOD__); throw new VideoNotFoundException($status, $content, $apiUrl); } // interpret error XML response $sp = new SimplePie(); $sp->set_raw_data($content); $sp->init(); // check if private $googleShemas = 'http://schemas.google.com/g/2005'; if (isset($sp->data['child'][$googleShemas])) { $err = $sp->data['child'][$googleShemas]['errors'][0]['child'][$googleShemas]['error'][0]['child'][$googleShemas]['internalReason'][0]['data']; if ($err == 'Private video') { wfProfileOut(__METHOD__); throw new VideoIsPrivateException($status, $content, $apiUrl); } } // check if quota exceeded if (isset($sp->data['child'][''])) { $err = $sp->data['child']['']['errors'][0]['child']['']['error'][0]['child']['']['code'][0]['data']; if ($err == 'too_many_recent_calls') { wfProfileOut(__METHOD__); throw new VideoQuotaExceededException($status, $content, $apiUrl); } } wfProfileOut(__METHOD__); // return default parent::checkForResponseErrors($status, $content, $apiUrl); }