/** * Fetch a video gallery page. * * @param int $currentPage The requested page number of the gallery. * * @return tubepress_api_video_VideoGalleryPage The video gallery page for this page. May be empty, never null. */ public final function fetchVideoGalleryPage($currentPage) { $this->_cacheLogger(); $result = new tubepress_api_video_VideoGalleryPage(); $debugEnabled = $this->_logger->isHandling(ehough_epilog_Logger::DEBUG); if ($debugEnabled) { $this->_logger->debug(sprintf('Current page number is %d', $currentPage)); } $url = $this->buildGalleryUrl($currentPage); if ($debugEnabled) { $this->_logger->debug(sprintf('URL to fetch is <code>%s</code>', $url)); } $rawFeed = $this->_fetchFeedAndPrepareForAnalysis($url); $reportedTotalResultCount = $this->getTotalResultCount($rawFeed); /** * If no results, we can shortcut things here. */ if ($reportedTotalResultCount < 1) { $result->setTotalResultCount(0); $result->setVideos(array()); return $result; } if ($debugEnabled) { $this->_logger->debug(sprintf('Reported total result count is %d video(s)', $reportedTotalResultCount)); } /* convert the feed to videos */ $videoArray = $this->_feedToVideoArray($rawFeed); if (count($videoArray) == 0) { $result->setTotalResultCount(0); $result->setVideos(array()); return $result; } $result->setTotalResultCount($reportedTotalResultCount); $result->setVideos($videoArray); return $result; }