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
|
|
|
class CreateEncodingCommand extends CloudCommand |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* {@inheritDoc} |
29
|
|
|
*/ |
30
|
7 |
|
protected function configure() |
31
|
|
|
{ |
32
|
7 |
|
$this->setName('panda:encoding:create'); |
33
|
7 |
|
$this->setDescription('Create an encoding'); |
34
|
7 |
|
$this->addArgument( |
35
|
7 |
|
'video-id', |
36
|
7 |
|
InputArgument::REQUIRED, |
37
|
7 |
|
'Id of the video being encoded' |
38
|
|
|
); |
39
|
7 |
|
$this->addOption( |
40
|
7 |
|
'profile-id', |
41
|
7 |
|
null, |
42
|
7 |
|
InputOption::VALUE_REQUIRED, |
43
|
7 |
|
'Id of the profile' |
44
|
|
|
); |
45
|
7 |
|
$this->addOption( |
46
|
7 |
|
'profile-name', |
47
|
7 |
|
null, |
48
|
7 |
|
InputOption::VALUE_REQUIRED, |
49
|
7 |
|
'A profile\'s name' |
50
|
|
|
); |
51
|
|
|
|
52
|
7 |
|
parent::configure(); |
53
|
7 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritDoc} |
57
|
|
|
*/ |
58
|
6 |
|
protected function doExecuteCommand(InputInterface $input, OutputInterface $output) |
59
|
|
|
{ |
60
|
6 |
|
$profileId = $input->getOption('profile-id'); |
61
|
6 |
|
$profileName = $input->getOption('profile-name'); |
62
|
|
|
|
63
|
6 |
|
if (null !== $profileId && null === $profileName) { |
64
|
3 |
|
$video = new Video(); |
65
|
3 |
|
$video->setId($input->getArgument('video-id')); |
66
|
3 |
|
$encoding = $this->getCloud($input)->createEncodingWithProfileId( |
67
|
3 |
|
$video, |
68
|
3 |
|
$profileId |
69
|
|
|
); |
70
|
1 |
|
$output->writeln( |
71
|
1 |
|
sprintf( |
72
|
1 |
|
'<info>Successfully created encoding with id %s</info>', |
73
|
1 |
|
$encoding->getId() |
74
|
|
|
) |
75
|
|
|
); |
76
|
3 |
|
} elseif (null === $profileId && null !== $profileName) { |
77
|
1 |
|
$video = new Video(); |
78
|
1 |
|
$video->setId($input->getArgument('video-id')); |
79
|
1 |
|
$encoding = $this->getCloud($input)->createEncodingWithProfileName( |
80
|
1 |
|
$video, |
81
|
1 |
|
$profileName |
82
|
|
|
); |
83
|
1 |
|
$output->writeln( |
84
|
1 |
|
sprintf( |
85
|
1 |
|
'<info>Successfully created encoding with id %s</info>', |
86
|
1 |
|
$encoding->getId() |
87
|
|
|
) |
88
|
|
|
); |
89
|
|
|
} else { |
90
|
2 |
|
$output->writeln( |
91
|
2 |
|
'<error>Exactly one option of --profile-id or --profile-name must be given.</error>' |
92
|
|
|
); |
93
|
|
|
} |
94
|
4 |
|
} |
95
|
|
|
} |
96
|
|
|
|