$ingester = FeedIngesterFactory::getIngester($provider);
// get WikiFactory data
$ingestionData = $ingester->getWikiIngestionData();
if (empty($ingestionData)) {
    die("No ingestion data found in wikicities. Aborting.\n");
}
// keywords for page categories
$categories = array('International', 'Foreign', 'Movies', 'TV', 'Gaming', 'Games', 'Others', 'Entertainment', 'Trailers', 'Webinars', 'Support', 'Community', 'Clips', 'Anime', 'Gameplay', 'Books', 'Trailer', 'Television', 'Interviews', 'SciFi', 'Featurettes', 'Featurette', 'Community Support', 'How-to', 'How To', 'Intro', 'Comedy', 'Animation', 'Overhaul', 'Wikia Webinars', 'Epic', 'SOE', 'EA', 'Konami', 'ubisoft', 'WBIE', 'Comics', 'Comic-Con', 'Food', 'Walkthroughs', 'Walkthrough', 'Remake', 'Expert Showcase', 'Wikia Productions', 'Adventure', 'Pixar', 'Disney', 'RPG', 'Namco Bandai', 'Cartoon', 'Wikia Fan Media', 'Action', 'Multiplayer', 'Online', 'Marvel', 'Walt Disney', 'Shooter', 'Horror', 'Drama');
$nextPage = '';
$page = 1;
$total = 0;
$failed = 0;
$skipped = 0;
do {
    // connect to provider API
    $url = OoyalaAsset::getApiUrlAssets($apiPageSize, $nextPage, $extraCond);
    echo "\nConnecting to {$url}...\n";
    $response = OoyalaAsset::getApiContent($url);
    if ($response === false) {
        exit;
    }
    $videos = empty($response['items']) ? array() : $response['items'];
    $nextPage = empty($response['next_page']) ? '' : $response['next_page'];
    $total += count($videos);
    $cnt = 0;
    foreach ($videos as $video) {
        $cnt++;
        $videoTitle = trim($video['name']);
        $msg = "[Page {$page}: {$cnt} of {$total}] Video: {$videoTitle} ({$video['embed_code']})";
        echo "\n{$msg}";
        // skip if 'name' field exists
 /**
  * import videos
  * @param array $params
  * @return integer $articlesCreated
  */
 public function importVideos($params = [])
 {
     wfProfileIn(__METHOD__);
     $articlesCreated = 0;
     $nextPage = '';
     do {
         // connect to provider API
         $url = OoyalaAsset::getApiUrlAssets(self::API_PAGE_SIZE, $nextPage, $params['cond']);
         print "Connecting to {$url}...\n";
         $response = OoyalaAsset::getApiContent($url);
         if ($response === false) {
             $this->logger->videoErrors("ERROR: problem downloading content.\n");
             wfProfileOut(__METHOD__);
             return 0;
         }
         $videos = empty($response['items']) ? [] : $response['items'];
         $nextPage = empty($response['next_page']) ? '' : $response['next_page'];
         $this->logger->videoFound(count($videos));
         foreach ($videos as $video) {
             if (!empty($video['time_restrictions']['start_date']) && strtotime($video['time_restrictions']['start_date']) > $params['now']) {
                 $this->logger->videoSkipped("Skipping {$video['name']} (Id:{$video['embed_code']}). Time restriction.\n");
                 continue;
             }
             $clipData = [];
             $clipData['titleName'] = trim($video['name']);
             $clipData['videoId'] = $video['embed_code'];
             $clipData['thumbnail'] = $video['preview_image_url'];
             $clipData['duration'] = $video['duration'] / 1000;
             $clipData['published'] = empty($video['metadata']['published']) ? '' : strtotime($video['metadata']['published']);
             $clipData['name'] = empty($video['metadata']['name']) ? '' : $video['metadata']['name'];
             $clipData['type'] = empty($video['metadata']['type']) ? '' : $video['metadata']['type'];
             $clipData['category'] = empty($video['metadata']['category']) ? '' : $this->getCategory($video['metadata']['category']);
             $clipData['keywords'] = empty($video['metadata']['keywords']) ? '' : $video['metadata']['keywords'];
             $clipData['description'] = trim($video['description']);
             $clipData['ageRequired'] = empty($video['metadata']['age_required']) ? 0 : $video['metadata']['age_required'];
             $clipData['ageGate'] = empty($clipData['ageRequired']) ? 0 : 1;
             $clipData['hd'] = empty($video['metadata']['hd']) ? 0 : 1;
             $clipData['industryRating'] = '';
             if (!empty($video['metadata']['industryrating'])) {
                 $clipData['industryRating'] = $this->getIndustryRating($video['metadata']['industryrating']);
             }
             $clipData['categoryName'] = OoyalaApiWrapper::getProviderName($video['labels']);
             // check for videos under '/Providers/' labels
             if (empty($clipData['categoryName'])) {
                 $this->logger->videoSkipped("Skipping {$clipData['titleName']} - {$clipData['description']}. No provider name.\n");
                 continue;
             }
             $clipData['provider'] = OoyalaApiWrapper::formatProviderName($clipData['categoryName']);
             $clipData['language'] = empty($video['metadata']['lang']) ? '' : $video['metadata']['lang'];
             $clipData['subtitle'] = empty($video['metadata']['subtitle']) ? '' : $video['metadata']['subtitle'];
             $clipData['genres'] = empty($video['metadata']['genres']) ? '' : $video['metadata']['genres'];
             $clipData['actors'] = empty($video['metadata']['actors']) ? '' : $video['metadata']['actors'];
             $clipData['startDate'] = empty($video['time_restrictions']['start_date']) ? '' : strtotime($video['time_restrictions']['start_date']);
             $clipData['expirationDate'] = empty($video['time_restrictions']['end_date']) ? '' : strtotime($video['time_restrictions']['end_date']);
             $clipData['regionalRestrictions'] = empty($video['metadata']['regional_restrictions']) ? '' : strtoupper($video['metadata']['regional_restrictions']);
             $clipData['targetCountry'] = empty($video['metadata']['targetcountry']) ? '' : $video['metadata']['targetcountry'];
             $clipData['source'] = empty($video['metadata']['source']) ? '' : $video['metadata']['source'];
             $clipData['sourceId'] = empty($video['metadata']['sourceid']) ? '' : $video['metadata']['sourceid'];
             $clipData['series'] = empty($video['metadata']['series']) ? '' : $video['metadata']['series'];
             $clipData['season'] = empty($video['metadata']['season']) ? '' : $video['metadata']['season'];
             $clipData['episode'] = empty($video['metadata']['episode']) ? '' : $video['metadata']['episode'];
             $clipData['characters'] = empty($video['metadata']['characters']) ? '' : $video['metadata']['characters'];
             $clipData['resolution'] = empty($video['metadata']['resolution']) ? '' : $video['metadata']['resolution'];
             $clipData['aspectRatio'] = empty($video['metadata']['aspectratio']) ? '' : $video['metadata']['aspectratio'];
             $clipData['distributor'] = empty($video['metadata']['distributor']) ? '' : $video['metadata']['distributor'];
             $clipData['pageCategories'] = empty($video['metadata']['pagecategories']) ? '' : $video['metadata']['pagecategories'];
             // Howdini has specific metadata which we want to map to our own
             if ($clipData['provider'] == "ooyala/howdini") {
                 $clipData["genres"] = $this->getHowdiniGenre($video['metadata']['category']);
                 $clipData["category"] = "Lifestyle";
                 $clipData["type"] = "How To";
                 $clipData["pageCategories"] = "Lifestyle, Howdini, How To";
                 // Genres need to be applied to categories VID-1787
                 if (!empty($clipData['genres'])) {
                     $clipData["pageCategories"] .= ', ' . $clipData['genres'];
                 }
                 $ooyalaAsset = new OoyalaAsset();
                 // Make sure all Howdini assets use the Howdini ad set
                 $ooyalaAsset->setAdSet($clipData["videoId"], F::app()->wg->OoyalaApiConfig['adSetHowdini']);
             }
             $articlesCreated += $this->createVideo($clipData);
         }
     } while (!empty($nextPage));
     wfProfileOut(__METHOD__);
     return $articlesCreated;
 }