private function FeedsYoutubeParser::parseVideoItems in Feeds: YouTube Parser 7.3
Parse YouTube video feed.
Parameters
Google_Service_YouTube_VideoListResponse $video_items:
FeedsFetcherResult $fetcher_result:
FeedsSource $source:
1 call to FeedsYoutubeParser::parseVideoItems()
- FeedsYoutubeParser::feeds_youtube_api_do_request in plugins/
FeedsYoutubeParser.inc - Perform API request to youtube API and retreive search result.
File
- plugins/
FeedsYoutubeParser.inc, line 157 - Feeds parser class for YouTube.
Class
- FeedsYoutubeParser
- Class definition for YouTube Parser.
Code
private function parseVideoItems(Google_Service_YouTube_VideoListResponse $video_items, FeedsSource $source, FeedsFetcherResult $fetcher_result) {
$fetcher_result->title = 'test';
$result = new FeedsParserResult();
foreach ($video_items->items as $key => $video) {
$feed_title = $video['snippet']['title'];
$id = $video->id;
$video_url = 'http://www.youtube.com/watch?v=' . $video->id;
$thumbnail_default = $video['snippet']['thumbnails']->default->url;
$thumbnail_medium = $video['snippet']['thumbnails']->medium->url;
$thumbnail_high = $video['snippet']['thumbnails']->high->url;
$thumbnail_standard = $video['snippet']['thumbnails']->standard->url;
$description = $video['snippet']['description'];
$categoryId = $video['snippet']['categoryId'];
$duration = $video['contentDetails']['duration'];
$tags = implode(', ', $video['snippet']['tags']);
$published = $video['snippet']->publishedAt;
$item = array(
'feed_title' => $feed_title,
'video_id' => $id,
'video_url' => $video_url,
'title' => $feed_title,
'description' => $description,
'thumbnail_default' => $thumbnail_default,
'thumbnail_medium' => $thumbnail_medium,
'thumbnail_high' => $thumbnail_high,
'thumbnail_standard' => $thumbnail_standard,
'category' => $categoryId,
'tags' => $tags,
'duration' => $this
->youTubeTimetoDuration($duration),
'duration_raw' => $duration,
'published_datetime' => date('Y-m-d H:i:s', strtotime($published)),
'published_timestamp' => strtotime($published),
);
if (isset($this->config['authenticated_on_channel']) && $this->config['authenticated_on_channel']) {
$viewCount = $video['statistics']['viewCount'];
$favCount = $video['statistics']['favoriteCount'];
$likes = $video['statistics']['likeCount'];
$dislikes = $video['statistics']['dislikeCount'];
$embed = $video['player']->embedHtml;
$item += array(
'view_count' => $viewCount,
'fav_count' => $favCount,
'likes' => $likes,
'dislikes' => $dislikes,
'embedded_player' => $embed,
);
}
$result->items[] = $item;
}
return $result;
}