nnscripts = $nnscripts; // Set the database variable $this->db = $db; // Set the movie variable $this->movie = $movie; } /** * Process the missing movie information * * @return void */ public function update() { // Gather the movie IMDB id's $sql = "SELECT r.imdbID, r.name FROM `releases` r LEFT JOIN `movieinfo` mi ON (mi.imdbID = r.imdbID) WHERE r.imdbID IS NOT NULL AND r.imdbID != '0000000' AND mi.ID IS NULL GROUP BY r.imdbID"; $movies = $this->db->query( $sql ); if( is_array( $movies ) && 0 < count( $movies ) ) { // Build the regexes array foreach( $movies AS $row ) { $name = $row['name']; if( preg_match('/^([a-z\.\_0-9\'\s]+)[\s\._]\(?(19[0-9]{2}|2[0-9]{3})\)?[\s\._].*?$/i', $row['name'], $matches) ) { $name = sprintf("%s (%s)", str_replace(array('.', '_'), ' ', trim($matches[1])), $matches[2]); } $this->nnscripts->display( sprintf( "Updating: %s ", $name ) ); if( defined('UPDATE') && true === UPDATE ) { // Update the movie info $this->movie->updateMovieInfo( $row['imdbID'] ); // Prevent overloading the remote servers sleep(2); } $this->nnscripts->display( PHP_EOL ); } } else { $this->nnscripts->display( 'No missing movie information found'. PHP_EOL ); } $this->nnscripts->display( PHP_EOL ); } } try { // Init $scriptName = 'Update missing movie information'; $scriptVersion = '0.1'; // Load the NNscript class $nnscripts = new NNScripts( $scriptName, $scriptVersion ); // Display the header $nnscripts->displayHeader(); // Load the application part $movie = new Movie; if( !$movie ) throw new Exception("Error loading movie library"); $db = new DB; if( !$db ) throw new Exception("Error loading database library"); // Load the blacklistReleases class $mi = new movieInfo( $nnscripts, $db, $movie ); $mi->update(); } catch( Exception $e ) { echo $e->getMessage() . PHP_EOL; }