You are here

public function FeedsYoutubeParser::parse in Feeds: YouTube Parser 7.3

Same name and namespace in other branches
  1. 6 FeedsYoutubeParser.inc \FeedsYoutubeParser::parse()
  2. 7.2 FeedsYoutubeParser.inc \FeedsYoutubeParser::parse()

Parse the extra mapping sources provided by this parser.

Parameters

$fetcher_result FeedsFetcherResult:

$source FeedsSource:

See also

FeedsParser::parse()

File

plugins/FeedsYoutubeParser.inc, line 22
Feeds parser class for YouTube.

Class

FeedsYoutubeParser
Class definition for YouTube Parser.

Code

public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
  $result = new FeedsParserResult();
  $libraries = libraries_load('google-api-php-client');
  $client = feeds_youtube_googleapi_youtube_client_factory();
  $youtube = new Google_Service_YouTube($client);
  $url = $source->config['FeedsHTTPFetcher']['source'];
  $limit = $this->config['import_video_limit'];
  $number_of_pages = $limit / 50;
  if ($number_of_pages < 1) {
    $number_of_pages = 1;
  }
  $nextPageToken = '';
  for ($i = 0; $i <= $number_of_pages; $i++) {
    $api_request_result = $this
      ->feeds_youtube_api_do_request($url, $next_page_token, $source, $fetcher_result, $client, $youtube);
    $next_page_token = !empty($api_request_result['next_page_token']) ? $api_request_result['next_page_token'] : '';
    $result->items = array_merge($result->items, $api_request_result['result']->items);
  }
  return $result;
}