// include cldr extension for language code ($languageNames), country code ($countryNames)
include dirname(__FILE__) . '/../../../extensions/cldr/CldrNames/CldrNamesEn.php';
$extraCond[] = "created_at < '2013-08-29T00:00:00Z'";
if (!empty($videoTitle)) {
    $extraCond[] = "name='{$videoTitle}'";
}
if ($iva) {
    $provider = 'iva';
    $isRemoteAsset = true;
    $extraCond[] = "asset_type='remote_asset'";
} else {
    $provider = 'ooyala';
    $isRemoteAsset = false;
    $extraCond[] = "asset_type!='remote_asset'";
}
$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);
if (wfReadOnly()) {
    die("Read only mode.\n");
}
// Make it clear when we're in debug mode
if ($ingesterParams['debug']) {
    echo "== DEBUG MODE ==\n";
}
// Populate $wgUser with Wikia Video Library
loadUser('Wikia Video Library');
// Determine which providers to pull from
$providersVideoFeed = loadProviders($provider);
// Loop through each provider and ingest video metadata
foreach ($providersVideoFeed as $provider) {
    print "Starting import for provider {$provider}...\n";
    /** @var VideoFeedIngester $feedIngester */
    $feedIngester = FeedIngesterFactory::getIngester($provider, $ingesterParams);
    // get WikiFactory data
    $ingestionData = $feedIngester->getWikiIngestionData();
    if (empty($ingestionData)) {
        die("No ingestion data found in wikicities. Aborting.");
    }
    // When necessary download a list of resources into $file and reformat
    // the start and end date for each provider
    $file = '';
    $startDate = $endDate = '';
    switch ($provider) {
        case FeedIngesterFactory::PROVIDER_SCREENPLAY:
            // no file needed
            $startDate = date('m/d/y', $startDateTS);
            $endDate = date('m/d/y', $endDateTS);
            break;