// Main entry point
public function mywrite(Route $route, Console $console)
{
// Max records is 500, the range cannot be too big.
$range = 3600 * 24;
$this->__mywrite($route, $console, $range);
}
// Count how many objects we can get
// $veryStartDate == 1446173087, sep 2015
// $maxDate == 1526469375, may 2018
public function __mywrite($route, $console, $range) {
$configObj = $this->readMyWriteHistoryConfigFile();
$lastProcessObj = $this->readMyWriteLastProcessFile();
//
$veryStartDate = $configObj->veryStartDate;
$maxDate = $configObj->maxDate;
// Set start Date
$startDate = $veryStartDate;
$endDate = $startDate + $range;
//
$totalCount = 0;
while($startDate <= $maxDate) {
$objs = $this->listMediaByLastPlay($startDate, $endDate);
$totalCount += count($objs);
echo "\n$startDate - $endDate:\n";
echo "\n". count($objs). "\n";
$startDate = $endDate + 1;
$endDate = $endDate + $range;
} // end while loop
// we get like 25k records, but we have 90k records....
echo "\ncount: $totalCount\n";
}
// we call the client and get records by start last play date and end last play date
public function listMediaByLastPlay($startDate, $endDate) {
// Page size
$pageSize = 1000;
// Client with admin
$client = $this->getClient(\KalturaSessionType::ADMIN);
// media
$mediaObj = $client->media;
// Set a range to pull, order by last played at
$filter = new \KalturaMediaEntryFilter();
$filter->lastPlayedAtGreaterThanOrEqual = $startDate;
$filter->lastPlayedAtLessThanOrEqual = $endDate;
$filter->orderBy = '+lastPlayedAt';
// We still want more records
$pager = new \KalturaFilterPager();
$pager->pageSize = $pageSize;
// now list.....
$arr = $mediaObj->listAction($filter, $pager)->objects;
$buf = array();
foreach($arr as $k => $v) {
$t = array();
$t['dataUrl'] = $v->dataUrl;
$t['flavorParamsIds'] = $v->flavorParamsIds;
$t['plays'] = $v->plays;
$t['views'] = $v->views;
$t['lastPlayedAt'] = $v->lastPlayedAt;
$buf[] = $t;
}
return $buf;
}
Since you’re filtering by lastPlayedAtGreaterThanOrEqual and incrementing it in every request you should be able to list all your entries that ever played.
If you want to list all your entries, you can filter be create date instead.
I’m not sure I understand the current situation… are you saying that when you make a media->list() [or baseEntry->list() if done via KMC] request without using the KalturaMediaEntryFilter and setting one of the following members/criteria:
You get back ~90,000 records and when passing one of the category filters you are getting ~50,000?
If so, that’s certainly possible since entries do not have to be attached to a category in order to be available/playable.
Passing disableentitlement in privileges when generating a KS will disable that mechanism entirely, thus returning ALL entries and categories, regardless of their entitlement configuration.
Let’s start by checking the results you get when using https://github.com/kaltura/Kaltura-Library-Export-Excel [see my reply to you on the other thread you started].
If this returns the expected results, then you should compare it against what you’re doing in your own code [feel free to share the full code you’re running after verifying]. If it doesn’t return the expected results, seeing how you are a paying Kaltura customer, I suggest you open a ticket with our support team. This is because further investigation of your specific content should not be discussed in a public forum such as this one, of course.
Like I said, KMC calls baseEntry->list(), not media->list(). If all your entries are media entries [videos, audio files, images] then that shouldn’t make a difference. If you have other type of entries associated with your partner, it might:)
Unless specified otherwise by setting one of the below members of KalturaMediaEntryFilter: