/** * Build a map of attribute names => attribute values for the video construction event. * * @param tubepress_api_event_EventInterface $event The video construction event. * * @return array An associative array of attribute names => attribute values */ protected final function buildAttributeMap(tubepress_api_event_EventInterface $event) { $toReturn = array(); $index = $event->getArgument('zeroBasedFeedIndex'); $videoArray = $event->getArgument('videoArray'); /* Author */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_AUTHOR_DISPLAY_NAME] = $videoArray[$index]->owner->display_name; $toReturn[tubepress_api_video_Video::ATTRIBUTE_AUTHOR_USER_ID] = $videoArray[$index]->owner->username; /* Description */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_DESCRIPTION] = $this->trimDescription($videoArray[$index]->description); /* Duration */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_DURATION_SECONDS] = $videoArray[$index]->duration; $toReturn[tubepress_api_video_Video::ATTRIBUTE_DURATION_FORMATTED] = tubepress_impl_util_TimeUtils::secondsToHumanTime($toReturn[tubepress_api_video_Video::ATTRIBUTE_DURATION_SECONDS]); /* Home URL */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_HOME_URL] = 'http://vimeo.com/' . $videoArray[$index]->id; /* ID */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_ID] = $videoArray[$index]->id; /* Keywords */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_KEYWORD_ARRAY] = $this->_gatherArrayOfContent($videoArray[$index], 'tags', 'tag'); /* Likes. */ if (isset($videoArray[$index]->number_of_likes)) { $toReturn[tubepress_api_video_Video::ATTRIBUTE_LIKES_COUNT] = $videoArray[$index]->number_of_likes; } /* Thumbnail. */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_THUMBNAIL_URL] = $this->_getThumbnailUrl($videoArray, $index); /* Time published. Vimeo dates are in US Eastern Time.*/ $reset = date_default_timezone_get(); date_default_timezone_set('America/New_York'); $toReturn[tubepress_api_video_Video::ATTRIBUTE_TIME_PUBLISHED_UNIXTIME] = strtotime($videoArray[$index]->upload_date); $toReturn[tubepress_api_video_Video::ATTRIBUTE_TIME_PUBLISHED_FORMATTED] = $this->unixTimeToHumanReadable($toReturn[tubepress_api_video_Video::ATTRIBUTE_TIME_PUBLISHED_UNIXTIME]); date_default_timezone_set($reset); /* Title. */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_TITLE] = $videoArray[$index]->title; /* Views. */ if (isset($videoArray[$index]->number_of_plays)) { $toReturn[tubepress_api_video_Video::ATTRIBUTE_VIEW_COUNT] = number_format($videoArray[$index]->number_of_plays); } return $toReturn; }
/** * Build a map of attribute names => attribute values for the video construction event. * * @param tubepress_api_event_EventInterface $event The video construction event. * * @return array An associative array of attribute names => attribute values */ protected final function buildAttributeMap(tubepress_api_event_EventInterface $event) { $toReturn = array(); $xpath = $event->getArgument('xPath'); $index = $event->getArgument('zeroBasedFeedIndex'); /* Author */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_AUTHOR_DISPLAY_NAME] = $this->_relativeQuery($xpath, $index, 'atom:author/atom:name')->item(0)->nodeValue; $toReturn[tubepress_api_video_Video::ATTRIBUTE_AUTHOR_USER_ID] = $toReturn[tubepress_api_video_Video::ATTRIBUTE_AUTHOR_DISPLAY_NAME]; /* Category */ /** @noinspection PhpUndefinedMethodInspection */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_CATEGORY_DISPLAY_NAME] = trim($this->_relativeQuery($xpath, $index, 'media:group/media:category')->item(0)->getAttribute('label')); /* Description */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_DESCRIPTION] = $this->trimDescription($this->_relativeQuery($xpath, $index, 'media:group/media:description')->item(0)->nodeValue); /* Duration */ /** @noinspection PhpUndefinedMethodInspection */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_DURATION_SECONDS] = $this->_relativeQuery($xpath, $index, 'media:group/yt:duration')->item(0)->getAttribute('seconds'); $toReturn[tubepress_api_video_Video::ATTRIBUTE_DURATION_FORMATTED] = tubepress_impl_util_TimeUtils::secondsToHumanTime($toReturn[tubepress_api_video_Video::ATTRIBUTE_DURATION_SECONDS]); /* Home URL */ /** @noinspection PhpUndefinedMethodInspection */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_HOME_URL] = $this->_relativeQuery($xpath, $index, "atom:link[@rel='alternate']")->item(0)->getAttribute('href'); /* ID */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_ID] = $this->_relativeQuery($xpath, $index, 'media:group/yt:videoid')->item(0)->nodeValue; /* Keywords. */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_KEYWORD_ARRAY] = array(); /* Rating */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_RATING_AVERAGE] = $this->_getRatingAverage($xpath, $index); $toReturn[tubepress_api_video_Video::ATTRIBUTE_RATING_COUNT] = $this->_getRatingCount($xpath, $index); /* Thumbnail. */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_THUMBNAIL_URL] = $this->pickThumbnailUrl($this->_getThumbnailUrls($xpath, $index)); /* Time published. */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_TIME_PUBLISHED_UNIXTIME] = $this->_getTimePublishedUnixTime($xpath, $index); $toReturn[tubepress_api_video_Video::ATTRIBUTE_TIME_PUBLISHED_FORMATTED] = $this->unixTimeToHumanReadable($toReturn[tubepress_api_video_Video::ATTRIBUTE_TIME_PUBLISHED_UNIXTIME]); /* Title. */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_TITLE] = $this->_relativeQuery($xpath, $index, 'atom:title')->item(0)->nodeValue; /* Views. */ $toReturn[tubepress_api_video_Video::ATTRIBUTE_VIEW_COUNT] = $this->fancyNumber($this->_getRawViewCount($xpath, $index)); return $toReturn; }