|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Popstas\Transmission\Console\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
8
|
|
|
|
|
9
|
|
|
class WeburgInfo extends Command |
|
10
|
|
|
{ |
|
11
|
|
|
protected function configure() |
|
12
|
|
|
{ |
|
13
|
|
|
parent::configure(); |
|
14
|
|
|
$this |
|
15
|
|
|
->setName('weburg-info') |
|
16
|
|
|
->setAliases(['wi']) |
|
17
|
|
|
->setDescription('Info about movie on weburg.net') |
|
18
|
|
|
->addArgument('movie-id', InputArgument::REQUIRED, 'Movie ID or URL') |
|
19
|
|
|
->setHelp(<<<EOT |
|
20
|
|
|
## Info about movie on Weburg.net |
|
21
|
|
|
|
|
22
|
|
|
Command for test internal weburg parser. |
|
23
|
|
|
EOT |
|
24
|
|
|
); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
28
|
|
|
{ |
|
29
|
|
|
$config = $this->getApplication()->getConfig(); |
|
30
|
|
|
$config->set('weburg-request-delay', 0); |
|
31
|
|
|
$weburgClient = $this->getApplication()->getWeburgClient(); |
|
32
|
|
|
$daysMax = $config->overrideConfig($input, 'days', 'weburg-series-max-age'); |
|
33
|
|
|
$allowedMisses = $config->get('weburg-series-allowed-misses'); |
|
34
|
|
|
|
|
35
|
|
|
try { |
|
36
|
|
|
$movieArgument = $input->getArgument('movie-id'); |
|
37
|
|
|
$movieId = $weburgClient->cleanMovieId($movieArgument); |
|
38
|
|
|
if (!$movieId) { |
|
39
|
|
|
throw new \RuntimeException($movieId . ' seems not weburg movie ID or URL'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$movieInfo = $weburgClient->getMovieInfoById($movieId); |
|
43
|
|
|
foreach ($movieInfo as $name => $value) { |
|
44
|
|
|
if ($name == 'hashes') { |
|
45
|
|
|
continue; |
|
46
|
|
|
} |
|
47
|
|
|
$output->writeln("$name: $value"); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
if (!empty($movieInfo['hashes'])) { |
|
51
|
|
|
$output->writeln('Search series...'); |
|
52
|
|
|
if (!empty($movieInfo['hashes'])) { |
|
53
|
|
|
$seriesUrls = $weburgClient->getSeriesTorrents( |
|
54
|
|
|
$movieId, |
|
55
|
|
|
$movieInfo['hashes'], |
|
56
|
|
|
$daysMax, |
|
57
|
|
|
$allowedMisses |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
if (count($seriesUrls)) { |
|
61
|
|
|
$output->writeln('Found series: ' . count($seriesUrls)); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
} catch (\RuntimeException $e) { |
|
66
|
|
|
$output->writeln($e->getMessage()); |
|
67
|
|
|
return 1; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return 0; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|