Update misc/testing/PostProc/getMovieCovers.php script

This commit is contained in:
DariusIII
2017-08-08 12:08:20 +02:00
parent cc424c9fda
commit 3c19f193cf
2 changed files with 18 additions and 12 deletions
+1
View File
@@ -1,4 +1,5 @@
2017-08-08 DariusIII
* Chg: Update misc/testing/PostProc/getMovieCovers.php script
* Chg: Update misc/testing/PostProc/getImdb.php script
* Chg: Update Steam class
* Fix: Use proper type casting in groupfixrelnames (Fixes issue #159)
+17 -12
View File
@@ -4,24 +4,29 @@ require_once dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'bootstrap.php';
use nntmux\db\DB;
use nntmux\Movie;
use nntmux\ColorCLI;
$pdo = new DB();
$movie = new Movie(['Echo' => true, 'Settings' => $pdo]);
$movies = $pdo->queryDirect("SELECT imdbid FROM movieinfo WHERE cover = 0 ORDER BY year ASC, id DESC");
if ($movies instanceof \Traversable) {
echo $pdo->log->primary("Updating " . number_format($movies->rowCount()) . " movie covers.");
foreach ($movies as $mov) {
$starttime = microtime(true);
$mov = $movie->updateMovieInfo($mov['imdbid']);
$movies = $pdo->queryDirect('SELECT imdbid FROM movieinfo WHERE cover = 0 ORDER BY year ASC, id DESC');
$count = $movies->rowCount();
if ($count > 0) {
if ($movies instanceof \Traversable) {
echo ColorCLI::primary('Updating ' . number_format($count) . ' movie covers.');
foreach ($movies as $mov) {
$startTime = microtime(true);
$mov = $movie->updateMovieInfo($mov['imdbid']);
// tmdb limits are 30 per 10 sec, not certain for imdb
$diff = floor((microtime(true) - $starttime) * 1000000);
if (333333 - $diff > 0) {
echo "\nsleeping\n";
usleep(333333 - $diff);
// tmdb limits are 30 per 10 sec, not certain for imdb
$diff = floor((microtime(true) - $startTime) * 1000000);
if (333333 - $diff > 0) {
echo "\nsleeping\n";
usleep(333333 - $diff);
}
}
}
echo "\n";
} else {
echo ColorCLI::header('No movie covers to update');
}