From 3c19f193cf54afb0cbce599cc14b451037b25810 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Tue, 8 Aug 2017 12:08:20 +0200 Subject: [PATCH] Update misc/testing/PostProc/getMovieCovers.php script --- Changelog | 1 + misc/testing/PostProc/getMovieCovers.php | 29 ++++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Changelog b/Changelog index 4d9302d5c..fff1ad870 100755 --- a/Changelog +++ b/Changelog @@ -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) diff --git a/misc/testing/PostProc/getMovieCovers.php b/misc/testing/PostProc/getMovieCovers.php index b6bae956f..866ff4f45 100644 --- a/misc/testing/PostProc/getMovieCovers.php +++ b/misc/testing/PostProc/getMovieCovers.php @@ -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'); }