1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
Oinktube/install/updateSecondsWatchingFromViewsInfo.php
2022-12-16 09:37:44 -03:00

24 lines
900 B
PHP

<?php
//streamer config
require_once '../videos/configuration.php';
ob_end_flush();
if (!isCommandLineInterface()) {
return die('Command Line only');
}
$global['rowCount'] = 99999;
$total = Video::getTotalVideos("", false, true, true, false, false);
$videos = Video::getAllVideosLight("", false, true, false);
$count = 0;
foreach ($videos as $value) {
$count++;
$newTotal = VideoStatistic::getSecondsWatchedFromVideos_id($value['id']);
if($newTotal>$value['total_seconds_watching']){
$sql = "UPDATE videos SET total_seconds_watching = ?, modified = now() WHERE id = ?";
sqlDAL::writeSql($sql, "ii", [intval($newTotal), intval($value['id'])]);
echo "{$count}/{$total} SUCCESS $newTotal>{$value['total_seconds_watching']}".PHP_EOL;
}else{
echo "{$count}/{$total} SKIPP $newTotal>{$value['total_seconds_watching']}".PHP_EOL;
}
}
die();