242 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Command;
|
|
|
6 |
|
|
|
7 |
use Symfony\Component\Console\Command\Command;
|
|
|
8 |
use Symfony\Component\Console\Input\InputInterface;
|
|
|
9 |
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
10 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
11 |
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
|
|
|
12 |
use Laminas\Log\LoggerInterface;
|
|
|
13 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
14 |
use LeadersLinked\Mapper\CompanyMapper;
|
|
|
15 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
|
|
16 |
use LeadersLinked\Model\User;
|
|
|
17 |
use LeadersLinked\Model\UserType;
|
|
|
18 |
use LeadersLinked\Model\CompanyUser;
|
|
|
19 |
use LeadersLinked\Mapper\FeedMapper;
|
|
|
20 |
|
|
|
21 |
class CheckPreviewPosterForFeedCommand extends Command
|
|
|
22 |
{
|
|
|
23 |
/**
|
|
|
24 |
*
|
|
|
25 |
* @var AdapterInterface
|
|
|
26 |
*/
|
|
|
27 |
private $adapter;
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
*
|
|
|
32 |
* @var AbstractAdapter
|
|
|
33 |
*/
|
|
|
34 |
private $cache;
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
*
|
|
|
38 |
* @var LoggerInterface
|
|
|
39 |
*/
|
|
|
40 |
private $logger;
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
*
|
|
|
44 |
* @var array
|
|
|
45 |
*/
|
|
|
46 |
private $config;
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
*
|
|
|
51 |
* @param AdapterInterface $adapter
|
|
|
52 |
* @param AbstractAdapter $cache
|
|
|
53 |
* @param LoggerInterface $logger
|
|
|
54 |
* @param array $config
|
|
|
55 |
*/
|
|
|
56 |
public function __construct($adapter, $cache, $logger, $config)
|
|
|
57 |
{
|
|
|
58 |
$this->adapter = $adapter;
|
|
|
59 |
$this->cache = $cache;
|
|
|
60 |
$this->logger = $logger;
|
|
|
61 |
$this->config = $config;
|
|
|
62 |
|
|
|
63 |
parent::__construct();
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
protected function execute(InputInterface $input, OutputInterface $output) : int
|
|
|
68 |
{
|
|
|
69 |
$output->writeln('Cargando los feed');
|
|
|
70 |
|
|
|
71 |
$feedMapper = FeedMapper::getInstance($this->adapter);
|
|
|
72 |
$feeds = $feedMapper->fetchAllTypeVideo();
|
|
|
73 |
|
|
|
74 |
$size = $this->config['leaderslinked.image_sizes.feed_image_size'];
|
|
|
75 |
foreach($feeds as $feed)
|
|
|
76 |
{
|
|
|
77 |
$target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
|
|
|
78 |
if(!file_exists($target_path)) {
|
|
|
79 |
mkdir($target_path, 0755);
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
$full_video_filename = $target_path . DIRECTORY_SEPARATOR . $feed->file_name;
|
|
|
83 |
|
|
|
84 |
$full_filename_preview = substr($feed->file_name, 0, strrpos($feed->file_name, '.'));
|
|
|
85 |
$full_filename_preview = $target_path . DIRECTORY_SEPARATOR . $full_filename_preview . '.png';
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
if(!file_exists($full_filename_preview)) {
|
|
|
89 |
echo 'Procesando el Video ' . PHP_EOL;
|
|
|
90 |
echo 'UUID : ' . $feed->uuid . PHP_EOL;
|
|
|
91 |
echo 'Image : ' . $feed->file_image_preview . PHP_EOL;
|
|
|
92 |
echo 'Video : ' . $feed->file_name . PHP_EOL;
|
|
|
93 |
echo 'Video Filename : ' . $full_video_filename . PHP_EOL;
|
|
|
94 |
echo 'Cover Filename : ' . $full_filename_preview . PHP_EOL;
|
|
|
95 |
|
|
|
96 |
$cmd = "/usr/bin/ffmpeg -i $full_video_filename -frames:v 1 -s $size $full_filename_preview";
|
|
|
97 |
echo 'CMD = ' . $cmd . PHP_EOL. PHP_EOL;
|
|
|
98 |
exec($cmd);
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
$feed->file_image_preview = basename($full_filename_preview);
|
|
|
103 |
$feedMapper->update($feed);
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
$output->writeln('Fin del proceso');
|
|
|
108 |
|
|
|
109 |
return 0;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
}
|