$movie = \Repository\Movies::getInstance()->findOneByGoogleId($googleId); if (!$movie) { $movie = \Repository\Movies::getInstance()->getNew(array('google_id' => $googleId, 'name' => html_entity_decode($domMovie->find('.name a', 0)->text()), 'info' => html_entity_decode($domMovie->find('.info', 0)->text()))); \Repository\Movies::getInstance()->save($movie); $output->writeln('[CMD] Added movie: ' . $movie->id . ' ' . $movie->name); } $times = $domMovie->find('.times', 0)->plaintext; preg_match_all('#[0-9]+\\:[0-9]+#', $times, $hours); $dateObj = new \DateTime(); $dateObj->add(new \DateInterval('P' . $date . 'D')); // $this->getService('repository.showtime')->deleteByMovieAndTheaterAndDate($movie, $theater, $dateObj->format('Y-m-d')); // $this->output->writeln('Removed showtimes: movie(' . $movie->id . ') theater(' . $theater->id . ') date(' . $dateObj->format('Y-m-d') . ')'); foreach ($hours[0] as $hour) { $dateObj->setTime(substr($hour, 0, 2), substr($hour, 3, 2)); $showtime = \Repository\Showtimes::getInstance()->getNew(array('movie_id' => $movie->id, 'theater_id' => $theater->id, 'date' => $dateObj->format('Y-m-d H:i:s'))); \Repository\Showtimes::getInstance()->save($showtime); $output->writeln('[CMD] Added showtime: movie(' . $movie->id . ') theater(' . $theater->id . ') date(' . $showtime->date . ')'); } //return $movie; } } $output->writeln('[CMD] Done'); }); $app->command('fetch movies', function ($input, $output) { $output->writeLn('[CMD] Fetching movies data'); $output->writeLn('[HTTP] GET http://www.clarin.com/extrashow/cine/cartelera.html'); $crawler = file_get_html('http://www.clarin.com/extrashow/cine/cartelera.html'); /** * http://www.clarin.com/extrashow/cine/_PEL_6662.html */ $movies = array();
public function getShowtimes() { return \Repository\Showtimes::getInstance()->findAllByMovieIdAndDate($this->id, $this->date); }