Rev 6849 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Command;use Symfony\Component\Console\Command\Command;use Symfony\Component\Console\Input\InputInterface;use Symfony\Component\Console\Output\OutputInterface;use Laminas\Db\Adapter\AdapterInterface;use Laminas\Log\LoggerInterface;use LeadersLinked\Mapper\FeedMapper;use Laminas\Mvc\I18n\Translator;use LeadersLinked\Cache\CacheInterface;class CheckPreviewPosterForFeedCommand extends Command{/**** @var \Laminas\Db\Adapter\AdapterInterface*/private $adapter;/**** @var \LeadersLinked\Cache\CacheInterface*/private $cache;/**** @var \Laminas\Log\LoggerInterface*/private $logger;/**** @var array*/private $config;/**** @var \Laminas\Mvc\I18n\Translator*/private $translator;/**** @param \Laminas\Db\Adapter\AdapterInterface $adapter* @param \LeadersLinked\Cache\CacheInterface $cache* @param \Laminas\Log\LoggerInterface* @param array $config* @param \Laminas\Mvc\I18n\Translator $translator*/public function __construct($adapter, $cache, $logger, $config, $translator){$this->adapter = $adapter;$this->cache = $cache;$this->logger = $logger;$this->config = $config;$this->translator = $translator;parent::__construct();}protected function execute(InputInterface $input, OutputInterface $output) : int{$output->writeln('Cargando los feed');$feedMapper = FeedMapper::getInstance($this->adapter);$feeds = $feedMapper->fetchAllTypeVideo();$size = $this->config['leaderslinked.image_sizes.feed_image_size'];foreach($feeds as $feed){$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;if(!file_exists($target_path)) {mkdir($target_path, 0755);}$full_video_filename = $target_path . DIRECTORY_SEPARATOR . $feed->file_name;$full_filename_preview = substr($feed->file_name, 0, strrpos($feed->file_name, '.'));$full_filename_preview = $target_path . DIRECTORY_SEPARATOR . $full_filename_preview . '.png';if(!file_exists($full_filename_preview)) {echo 'Procesando el Video ' . PHP_EOL;echo 'UUID : ' . $feed->uuid . PHP_EOL;echo 'Image : ' . $feed->file_image_preview . PHP_EOL;echo 'Video : ' . $feed->file_name . PHP_EOL;echo 'Video Filename : ' . $full_video_filename . PHP_EOL;echo 'Cover Filename : ' . $full_filename_preview . PHP_EOL;@unlink($full_filename_preview);$cmd = "/usr/bin/ffmpeg -i $full_video_filename -frames:v 1 -s $size $full_filename_preview";echo 'CMD = ' . $cmd . PHP_EOL. PHP_EOL;exec($cmd);}$feed->file_image_preview = basename($full_filename_preview);$feedMapper->update($feed);}$output->writeln('Fin del proceso');return 0;}}