public function invoke(array $args) { /** @var Video $video */ $video = $args['video']; $video->preview = $this->youtube->getImageUrlFor($video->youtubeId); $video->duration = $this->youtube->getDuration($video->youtubeId); $this->orm->flush(); }
protected function updateDurations(RepositoryContainer $orm, Youtube $youtube) { $count = 0; $videos = $orm->contents->findVideosWithoutDuration(); $progress = new ProgressBar($this->out, $videos->count()); $progress->start(); /** @var Video $video */ foreach ($videos as $video) { $video->duration = $youtube->getDuration($video->youtubeId); $progress->advance(); $count++; } $progress->finish(); $this->out->write("\n"); $orm->flush(); $this->out->writeln("<info>Duration updated for {$count} videos.</info>"); }