|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the XabbuhPandaBundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Xabbuh\PandaBundle\Command; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
18
|
|
|
use Xabbuh\PandaClient\Model\Video; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Command to create an encoding. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Christian Flothmann <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
final class CreateEncodingCommand extends CloudCommand |
|
26
|
|
|
{ |
|
27
|
|
|
protected static $defaultName = 'panda:encoding:create'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* {@inheritDoc} |
|
31
|
|
|
*/ |
|
32
|
8 |
|
protected function configure() |
|
33
|
|
|
{ |
|
34
|
8 |
|
$this->setDescription('Create an encoding'); |
|
35
|
8 |
|
$this->addArgument( |
|
36
|
8 |
|
'video-id', |
|
37
|
8 |
|
InputArgument::REQUIRED, |
|
38
|
8 |
|
'Id of the video being encoded' |
|
39
|
|
|
); |
|
40
|
8 |
|
$this->addOption( |
|
41
|
8 |
|
'profile-id', |
|
42
|
8 |
|
null, |
|
43
|
8 |
|
InputOption::VALUE_REQUIRED, |
|
44
|
8 |
|
'Id of the profile' |
|
45
|
|
|
); |
|
46
|
8 |
|
$this->addOption( |
|
47
|
8 |
|
'profile-name', |
|
48
|
8 |
|
null, |
|
49
|
8 |
|
InputOption::VALUE_REQUIRED, |
|
50
|
8 |
|
'A profile\'s name' |
|
51
|
|
|
); |
|
52
|
|
|
|
|
53
|
8 |
|
parent::configure(); |
|
54
|
8 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritDoc} |
|
58
|
|
|
*/ |
|
59
|
6 |
|
protected function doExecuteCommand(InputInterface $input, OutputInterface $output) |
|
60
|
|
|
{ |
|
61
|
6 |
|
$profileId = $input->getOption('profile-id'); |
|
62
|
6 |
|
$profileName = $input->getOption('profile-name'); |
|
63
|
|
|
|
|
64
|
6 |
|
if (null !== $profileId && null === $profileName) { |
|
65
|
3 |
|
$video = new Video(); |
|
66
|
3 |
|
$video->setId($input->getArgument('video-id')); |
|
67
|
3 |
|
$encoding = $this->getCloud($input)->createEncodingWithProfileId( |
|
68
|
3 |
|
$video, |
|
69
|
|
|
$profileId |
|
70
|
|
|
); |
|
71
|
1 |
|
$output->writeln( |
|
72
|
|
|
sprintf( |
|
73
|
1 |
|
'<info>Successfully created encoding with id %s</info>', |
|
74
|
1 |
|
$encoding->getId() |
|
75
|
|
|
) |
|
76
|
|
|
); |
|
77
|
3 |
|
} elseif (null === $profileId && null !== $profileName) { |
|
78
|
1 |
|
$video = new Video(); |
|
79
|
1 |
|
$video->setId($input->getArgument('video-id')); |
|
80
|
1 |
|
$encoding = $this->getCloud($input)->createEncodingWithProfileName( |
|
81
|
1 |
|
$video, |
|
82
|
|
|
$profileName |
|
83
|
|
|
); |
|
84
|
1 |
|
$output->writeln( |
|
85
|
|
|
sprintf( |
|
86
|
1 |
|
'<info>Successfully created encoding with id %s</info>', |
|
87
|
1 |
|
$encoding->getId() |
|
88
|
|
|
) |
|
89
|
|
|
); |
|
90
|
|
|
} else { |
|
91
|
2 |
|
$output->writeln( |
|
92
|
2 |
|
'<error>Exactly one option of --profile-id or --profile-name must be given.</error>' |
|
93
|
|
|
); |
|
94
|
|
|
} |
|
95
|
4 |
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|