@@ -47,8 +47,8 @@ |
||
47 | 47 | ]; |
48 | 48 | } |
49 | 49 | |
50 | - $cleanedIds = array_map(function ($torrentId) { |
|
51 | - return (int)$torrentId; |
|
50 | + $cleanedIds = array_map(function($torrentId) { |
|
51 | + return (int) $torrentId; |
|
52 | 52 | }, $ids); |
53 | 53 | |
54 | 54 | $this->createSession(); |
@@ -13,8 +13,7 @@ |
||
13 | 13 | public static function getTorrentAge($torrent) |
14 | 14 | { |
15 | 15 | $date = isset($torrent[Torrent\Get::DONE_DATE]) && $torrent[Torrent\Get::DONE_DATE] ? |
16 | - $torrent[Torrent\Get::DONE_DATE] : |
|
17 | - (isset($torrent[Torrent\Get::ADDED_DATE]) ? $torrent[Torrent\Get::ADDED_DATE] : 0); |
|
16 | + $torrent[Torrent\Get::DONE_DATE] : (isset($torrent[Torrent\Get::ADDED_DATE]) ? $torrent[Torrent\Get::ADDED_DATE] : 0); |
|
18 | 17 | return $date ? time() - $date : 0; |
19 | 18 | } |
20 | 19 |
@@ -64,7 +64,7 @@ |
||
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - $this->dryRun($input, $output, function () use ($influxDbClient, $points) { |
|
67 | + $this->dryRun($input, $output, function() use ($influxDbClient, $points) { |
|
68 | 68 | $influxDbClient->writePoints($points); |
69 | 69 | }, 'dry-run, don\'t really send points'); |
70 | 70 | } catch (\Exception $e) { |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Popstas\Transmission\Console\Command; |
4 | 4 | |
5 | -use Martial\Transmission\API\Argument\Torrent; |
|
6 | 5 | use Popstas\Transmission\Console\TransmissionClient; |
7 | 6 | use Symfony\Component\Console\Input\InputArgument; |
8 | 7 | use Symfony\Component\Console\Input\InputInterface; |
@@ -50,13 +50,13 @@ |
||
50 | 50 | |
51 | 51 | private function addFile(InputInterface $input, OutputInterface $output, TransmissionClient $client, $torrentFile) |
52 | 52 | { |
53 | - $this->dryRun($input, $output, function () use ($torrentFile, $client, $input, $output) { |
|
53 | + $this->dryRun($input, $output, function() use ($torrentFile, $client, $input, $output) { |
|
54 | 54 | $torrentAdded = $client->addTorrent($torrentFile); |
55 | 55 | if ($torrentAdded) { |
56 | 56 | if (isset($torrentAdded['duplicate'])) { |
57 | - $output->writeln($torrentFile . ' was not added. Probably it was added before.'); |
|
57 | + $output->writeln($torrentFile.' was not added. Probably it was added before.'); |
|
58 | 58 | } else { |
59 | - $output->writeln($torrentFile . ' added. Waiting for Transmission...'); |
|
59 | + $output->writeln($torrentFile.' added. Waiting for Transmission...'); |
|
60 | 60 | $client->waitForTransmission(10); |
61 | 61 | } |
62 | 62 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
89 | - $this->dryRun($input, $output, function () use ( |
|
89 | + $this->dryRun($input, $output, function() use ( |
|
90 | 90 | $input, |
91 | 91 | $output, |
92 | 92 | $weburgClient, |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | $progress->start(); |
156 | 156 | |
157 | 157 | foreach ($moviesIds as $movieId) { |
158 | - $progress->setMessage('Check movie ' . $movieId . '...'); |
|
158 | + $progress->setMessage('Check movie '.$movieId.'...'); |
|
159 | 159 | $progress->advance(); |
160 | 160 | |
161 | - $downloadedLogfile = $downloadDir . '/' . $movieId; |
|
161 | + $downloadedLogfile = $downloadDir.'/'.$movieId; |
|
162 | 162 | |
163 | 163 | $isDownloaded = file_exists($downloadedLogfile); |
164 | 164 | if ($isDownloaded) { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $movieInfo = $weburgClient->getMovieInfoById($movieId); |
169 | 169 | foreach (array_keys($movieInfo) as $infoField) { |
170 | 170 | if (!isset($movieInfo[$infoField])) { |
171 | - $logger->warning('Cannot find ' . $infoField . ' in movie ' . $movieId); |
|
171 | + $logger->warning('Cannot find '.$infoField.' in movie '.$movieId); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | ); |
182 | 182 | |
183 | 183 | if ($isTorrentPopular) { |
184 | - $progress->setMessage('Download movie ' . $movieId . '...'); |
|
184 | + $progress->setMessage('Download movie '.$movieId.'...'); |
|
185 | 185 | |
186 | 186 | $movieUrls = $weburgClient->getMovieTorrentUrlsById($movieId); |
187 | 187 | $torrentsUrls = array_merge($torrentsUrls, $movieUrls); |
188 | - $logger->info('Download movie ' . $movieId . ': ' . $movieInfo['title']); |
|
188 | + $logger->info('Download movie '.$movieId.': '.$movieInfo['title']); |
|
189 | 189 | |
190 | 190 | file_put_contents( |
191 | 191 | $downloadedLogfile, |
192 | - date('Y-m-d H:i:s') . "\n" . implode("\n", $torrentsUrls) |
|
192 | + date('Y-m-d H:i:s')."\n".implode("\n", $torrentsUrls) |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $progress->start(); |
224 | 224 | |
225 | 225 | foreach ($seriesIds as $seriesId) { |
226 | - $progress->setMessage('Check series ' . $seriesId . '...'); |
|
226 | + $progress->setMessage('Check series '.$seriesId.'...'); |
|
227 | 227 | $progress->advance(); |
228 | 228 | |
229 | 229 | $movieInfo = $weburgClient->getMovieInfoById($seriesId); |
@@ -250,18 +250,18 @@ discard block |
||
250 | 250 | |
251 | 251 | $movieId = $weburgClient->cleanMovieId($movieId); |
252 | 252 | if (!$movieId) { |
253 | - throw new \RuntimeException($movieId . ' seems not weburg movie ID or URL'); |
|
253 | + throw new \RuntimeException($movieId.' seems not weburg movie ID or URL'); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | $movieInfo = $weburgClient->getMovieInfoById($movieId); |
257 | - $logger->info('Search series ' . $movieId); |
|
257 | + $logger->info('Search series '.$movieId); |
|
258 | 258 | if (!empty($movieInfo['hashes'])) { |
259 | 259 | $seriesUrls = $weburgClient->getSeriesTorrents($movieId, $movieInfo['hashes'], $daysMax, $allowedMisses); |
260 | 260 | $torrentsUrls = array_merge($torrentsUrls, $seriesUrls); |
261 | 261 | |
262 | 262 | if (count($seriesUrls)) { |
263 | - $logger->info('Download series ' . $movieId . ': ' |
|
264 | - . $movieInfo['title'] . ' (' . count($seriesUrls) . ')'); |
|
263 | + $logger->info('Download series '.$movieId.': ' |
|
264 | + . $movieInfo['title'].' ('.count($seriesUrls).')'); |
|
265 | 265 | } |
266 | 266 | } else { |
267 | 267 | $torrentsUrls = array_merge($torrentsUrls, $weburgClient->getMovieTorrentUrlsById($movieId)); |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | if (!file_exists($torrentsDir)) { |
290 | - throw new \RuntimeException('Destination directory not exists: ' . $torrentsDir); |
|
290 | + throw new \RuntimeException('Destination directory not exists: '.$torrentsDir); |
|
291 | 291 | } |
292 | 292 | |
293 | - $downloadDir = $torrentsDir . '/downloaded'; |
|
293 | + $downloadDir = $torrentsDir.'/downloaded'; |
|
294 | 294 | if (!file_exists($downloadDir)) { |
295 | 295 | mkdir($downloadDir, 0777); |
296 | 296 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | ); |
322 | 322 | |
323 | 323 | $addInput = new ArrayInput($arguments); |
324 | - $output->writeln("\nAdd torrents to " . $host); |
|
324 | + $output->writeln("\nAdd torrents to ".$host); |
|
325 | 325 | $command->run($addInput, $output); |
326 | 326 | } |
327 | 327 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $config->loadConfigFile(); |
61 | 61 | } catch (\RuntimeException $e) { |
62 | 62 | $logger->critical($e->getMessage()); |
63 | - $this->setCode(function () { |
|
63 | + $this->setCode(function() { |
|
64 | 64 | return 1; |
65 | 65 | }); |
66 | 66 | return; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $firstTransmission = $config->get('transmission')[0]; |
74 | 74 | $vars = ['host', 'port', 'user', 'password']; |
75 | 75 | foreach ($vars as $var) { |
76 | - $configName = 'transmission-' . $var; |
|
76 | + $configName = 'transmission-'.$var; |
|
77 | 77 | $config->set($configName, $this->getInputOption($input, $configName, $firstTransmission[$var])); |
78 | 78 | } |
79 | 79 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $connect = ['host' => $host, 'port' => $port, 'user' => $user, 'password' => $password]; |
105 | 105 | |
106 | - $baseUri = 'http://' . $connect['host'] . ':' . $connect['port'] . '/transmission/rpc'; |
|
106 | + $baseUri = 'http://'.$connect['host'].':'.$connect['port'].'/transmission/rpc'; |
|
107 | 107 | $httpClient = new GuzzleHttp\Client(['base_uri' => $baseUri]); |
108 | 108 | |
109 | 109 | $api = new API\RpcClient($httpClient, $connect['user'], $connect['password']); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | if (count($notExistsIds)) { |
62 | 62 | foreach ($notExistsIds as $notExistsId) { |
63 | - $output->writeln($notExistsId . ' not exists'); |
|
63 | + $output->writeln($notExistsId.' not exists'); |
|
64 | 64 | } |
65 | 65 | return 1; |
66 | 66 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - $this->dryRun($input, $output, function () use ($config, $torrentList, $client, $input, $output) { |
|
80 | + $this->dryRun($input, $output, function() use ($config, $torrentList, $client, $input, $output) { |
|
81 | 81 | $influxDbClient = $this->getApplication()->getInfluxDbClient( |
82 | 82 | $config->get('influxdb-host'), |
83 | 83 | $config->get('influxdb-port'), |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | $config->get('influxdb-database') |
86 | 86 | ); |
87 | 87 | |
88 | - $lastDays = (int)$input->getOption('days') ? (int)$input->getOption('days') : 0; |
|
89 | - $limit = (int)$input->getOption('limit') ? (int)$input->getOption('limit') : 0; |
|
88 | + $lastDays = (int) $input->getOption('days') ? (int) $input->getOption('days') : 0; |
|
89 | + $limit = (int) $input->getOption('limit') ? (int) $input->getOption('limit') : 0; |
|
90 | 90 | |
91 | 91 | $torrentList = $client->getTorrentData(); |
92 | 92 | |
93 | - $torrentList = array_map(function ($torrent) { |
|
93 | + $torrentList = array_map(function($torrent) { |
|
94 | 94 | $torrent['age'] = TorrentUtils::getTorrentAgeInDays($torrent); |
95 | 95 | return $torrent; |
96 | 96 | }, $torrentList); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | $transmissionHost = $config->get('transmission-host'); |
104 | 104 | |
105 | - $torrentList = array_map(function ($torrent) use ($influxDbClient, $transmissionHost, $lastDays) { |
|
105 | + $torrentList = array_map(function($torrent) use ($influxDbClient, $transmissionHost, $lastDays) { |
|
106 | 106 | $torrent['uploaded'] = $influxDbClient->getTorrentSum( |
107 | 107 | $torrent, |
108 | 108 | 'uploaded_last', |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | TableUtils::printTable($tableData, $output); |
133 | 133 | |
134 | 134 | $freeSpace = $client->getFreeSpace(); |
135 | - $output->writeln('Free space: ' . TorrentUtils::getSizeInGb($freeSpace) . ' GB'); |
|
135 | + $output->writeln('Free space: '.TorrentUtils::getSizeInGb($freeSpace).' GB'); |
|
136 | 136 | |
137 | 137 | if ($input->getOption('rm')) { |
138 | 138 | return $this->removeTorrents($input, $output, $tableData['rows']); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | 'headers' => ['Name', 'Id', 'Age, days', 'Size, GB', 'Uploaded, GB', 'Per day, GB', 'Profit, %'], |
181 | 181 | 'rows' => $rows, |
182 | 182 | 'totals' => [ |
183 | - 'Total: ' . count($rows), |
|
183 | + 'Total: '.count($rows), |
|
184 | 184 | '', |
185 | 185 | '', |
186 | 186 | TorrentListUtils::sumArrayField($rows, 3), |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | return 0; |
46 | 46 | } |
47 | 47 | |
48 | - $this->dryRun($input, $output, function () use ($client, $obsoleteList, $config, $input, $output) { |
|
48 | + $this->dryRun($input, $output, function() use ($client, $obsoleteList, $config, $input, $output) { |
|
49 | 49 | $influxDbClient = $this->getApplication()->getInfluxDbClient( |
50 | 50 | $config->get('influxdb-host'), |
51 | 51 | $config->get('influxdb-port'), |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | |
59 | 59 | $client->removeTorrents($obsoleteList); |
60 | 60 | $names = TorrentListUtils::getArrayField($obsoleteList, Torrent\Get::NAME); |
61 | - $output->writeln('Removed torrents:' . implode(', ', $names)); |
|
61 | + $output->writeln('Removed torrents:'.implode(', ', $names)); |
|
62 | 62 | }, 'dry-run, don\'t really remove'); |
63 | 63 | |
64 | - $output->writeln('Found and deleted ' . count($obsoleteList) . ' obsolete torrents from transmission:'); |
|
64 | + $output->writeln('Found and deleted '.count($obsoleteList).' obsolete torrents from transmission:'); |
|
65 | 65 | TorrentListUtils::printTorrentsTable($obsoleteList, $output); |
66 | 66 | return 0; |
67 | 67 | } |