@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | try { |
91 | 91 | $databaseExists = $database->exists(); |
92 | 92 | } catch (ConnectException $e) { |
93 | - throw new \RuntimeException('InfluxDb connection error: ' . $e->getMessage()); |
|
93 | + throw new \RuntimeException('InfluxDb connection error: '.$e->getMessage()); |
|
94 | 94 | } |
95 | 95 | if (!$databaseExists) { |
96 | - $this->log('info', 'Database ' . $this->databaseName . ' not exists, creating'); |
|
96 | + $this->log('info', 'Database '.$this->databaseName.' not exists, creating'); |
|
97 | 97 | $database->create(null, false); |
98 | 98 | } |
99 | 99 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $points[] = $this->buildPoint($torrent, $transmissionHost); |
172 | 172 | } |
173 | 173 | $isSuccess = $this->writePoints($points); |
174 | - $this->log('info', 'InfluxDB write ' . ($isSuccess ? 'success' : 'failed')); |
|
174 | + $this->log('info', 'InfluxDB write '.($isSuccess ? 'success' : 'failed')); |
|
175 | 175 | return $isSuccess; |
176 | 176 | } |
177 | 177 | |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | $where = []; |
188 | 188 | |
189 | 189 | if (isset($torrent[Torrent\Get::NAME])) { |
190 | - $where[] = "torrent_name = '" . $torrent[Torrent\Get::NAME] . "'"; |
|
190 | + $where[] = "torrent_name = '".$torrent[Torrent\Get::NAME]."'"; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | if ($transmissionHost) { |
194 | - $where[] = "host = '" . $transmissionHost . "'"; |
|
194 | + $where[] = "host = '".$transmissionHost."'"; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | if ($lastDays) { |
198 | - $fromTimestamp = strtotime('-' . $lastDays . ' days'); |
|
198 | + $fromTimestamp = strtotime('-'.$lastDays.' days'); |
|
199 | 199 | $fromDate = date('c', $fromTimestamp); |
200 | 200 | $where[] = "time >= '$fromDate'"; |
201 | 201 | } |
@@ -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'], $logger); |
@@ -44,8 +44,8 @@ |
||
44 | 44 | ]; |
45 | 45 | } |
46 | 46 | |
47 | - $cleanedIds = array_map(function ($torrentId) { |
|
48 | - return (int)$torrentId; |
|
47 | + $cleanedIds = array_map(function($torrentId) { |
|
48 | + return (int) $torrentId; |
|
49 | 49 | }, $ids); |
50 | 50 | |
51 | 51 | $this->getSessionId(); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | - $this->dryRun($input, $output, function () use ($client, $obsoleteList, $config, $input, $output) { |
|
63 | + $this->dryRun($input, $output, function() use ($client, $obsoleteList, $config, $input, $output) { |
|
64 | 64 | $influxDbClient = $this->getApplication()->getInfluxDbClient( |
65 | 65 | $config->get('influxdb-host'), |
66 | 66 | $config->get('influxdb-port'), |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | |
74 | 74 | $client->removeTorrents($obsoleteList); |
75 | 75 | $names = TorrentListUtils::getArrayField($obsoleteList, Torrent\Get::NAME); |
76 | - $output->writeln('Removed torrents:' . implode(', ', $names)); |
|
76 | + $output->writeln('Removed torrents:'.implode(', ', $names)); |
|
77 | 77 | }, 'dry-run, don\'t really remove'); |
78 | 78 | |
79 | - $output->writeln('Found and deleted ' . count($obsoleteList) . ' obsolete torrents from transmission.'); |
|
79 | + $output->writeln('Found and deleted '.count($obsoleteList).' obsolete torrents from transmission.'); |
|
80 | 80 | return 0; |
81 | 81 | } |
82 | 82 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $data['rows'] = TableUtils::limitRows($data['rows'], $limit); |
88 | 88 | |
89 | 89 | $data['totals'] = [ |
90 | - 'Total: ' . count($data['rows']), |
|
90 | + 'Total: '.count($data['rows']), |
|
91 | 91 | '', |
92 | 92 | '', |
93 | 93 | self::sumArrayField($data['rows'], 3), |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $obsolete = []; |
105 | 105 | |
106 | 106 | foreach ($torrentList as $torrent) { |
107 | - $key = $torrent[Torrent\Get::NAME] . '_' . $torrent[Torrent\Get::DOWNLOAD_DIR]; |
|
107 | + $key = $torrent[Torrent\Get::NAME].'_'.$torrent[Torrent\Get::DOWNLOAD_DIR]; |
|
108 | 108 | $sameNamesAndDirectory[$key][$torrent[Torrent\Get::ID]] = $torrent; |
109 | 109 | } |
110 | 110 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | |
159 | 159 | private static function getFilesArray($torrent) |
160 | 160 | { |
161 | - return array_map(function ($file) { |
|
162 | - return $file['length'] . '_' . $file['name']; |
|
161 | + return array_map(function($file) { |
|
162 | + return $file['length'].'_'.$file['name']; |
|
163 | 163 | }, $torrent[Torrent\Get::FILES]); |
164 | 164 | } |
165 | 165 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $obsoleteList = TorrentListUtils::getObsoleteTorrents($torrentList); |
44 | 44 | if (!empty($obsoleteList)) { |
45 | 45 | $output->writeln('<comment>Found obsolete torrents, ' |
46 | - . 'remove it using transmission-cli torrent-remove-duplicates</comment>'); |
|
46 | + . 'remove it using transmission-cli torrent-remove-duplicates</comment>'); |
|
47 | 47 | TorrentListUtils::printTorrentsTable($obsoleteList, $output); |
48 | 48 | return 1; |
49 | 49 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | |
76 | 76 | $points[] = $influxDbClient->buildStatus($torrentList, $transmissionHost); |
77 | 77 | |
78 | - $this->dryRun($input, $output, function () use ($influxDbClient, $points) { |
|
78 | + $this->dryRun($input, $output, function() use ($influxDbClient, $points) { |
|
79 | 79 | $influxDbClient->writePoints($points); |
80 | 80 | }, 'dry-run, don\'t really send points'); |
81 | 81 | } catch (\Exception $e) { |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ); |
88 | 88 | } |
89 | 89 | |
90 | - $this->dryRun($input, $output, function () use ( |
|
90 | + $this->dryRun($input, $output, function() use ( |
|
91 | 91 | $input, |
92 | 92 | $output, |
93 | 93 | $weburgClient, |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | $progress->start(); |
162 | 162 | |
163 | 163 | foreach ($moviesIds as $movieId) { |
164 | - $progress->setMessage('Check movie ' . $movieId . '...'); |
|
164 | + $progress->setMessage('Check movie '.$movieId.'...'); |
|
165 | 165 | $progress->advance(); |
166 | 166 | |
167 | - $downloadedLogfile = $downloadDir . '/' . $movieId; |
|
167 | + $downloadedLogfile = $downloadDir.'/'.$movieId; |
|
168 | 168 | |
169 | 169 | $isDownloaded = file_exists($downloadedLogfile); |
170 | 170 | if ($isDownloaded) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $movieInfo = $weburgClient->getMovieInfoById($movieId); |
175 | 175 | foreach (array_keys($movieInfo) as $infoField) { |
176 | 176 | if (!isset($movieInfo[$infoField])) { |
177 | - $logger->warning('Cannot find ' . $infoField . ' in movie ' . $movieId); |
|
177 | + $logger->warning('Cannot find '.$infoField.' in movie '.$movieId); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | ); |
188 | 188 | |
189 | 189 | if ($isTorrentPopular) { |
190 | - $progress->setMessage('Download movie ' . $movieId . '...'); |
|
190 | + $progress->setMessage('Download movie '.$movieId.'...'); |
|
191 | 191 | |
192 | 192 | $movieUrls = $weburgClient->getMovieTorrentUrlsById($movieId); |
193 | 193 | $torrentsUrls = array_merge($torrentsUrls, $movieUrls); |
194 | - $logger->info('Download movie ' . $movieId . ': ' . $movieInfo['title']); |
|
194 | + $logger->info('Download movie '.$movieId.': '.$movieInfo['title']); |
|
195 | 195 | |
196 | 196 | file_put_contents( |
197 | 197 | $downloadedLogfile, |
198 | - date('Y-m-d H:i:s') . "\n" . implode("\n", $torrentsUrls) |
|
198 | + date('Y-m-d H:i:s')."\n".implode("\n", $torrentsUrls) |
|
199 | 199 | ); |
200 | 200 | } |
201 | 201 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $progress->start(); |
230 | 230 | |
231 | 231 | foreach ($seriesIds as $seriesId) { |
232 | - $progress->setMessage('Check series ' . $seriesId . '...'); |
|
232 | + $progress->setMessage('Check series '.$seriesId.'...'); |
|
233 | 233 | $progress->advance(); |
234 | 234 | |
235 | 235 | $movieInfo = $weburgClient->getMovieInfoById($seriesId); |
@@ -256,18 +256,18 @@ discard block |
||
256 | 256 | |
257 | 257 | $movieId = $weburgClient->cleanMovieId($movieId); |
258 | 258 | if (!$movieId) { |
259 | - throw new \RuntimeException($movieId . ' seems not weburg movie ID or URL'); |
|
259 | + throw new \RuntimeException($movieId.' seems not weburg movie ID or URL'); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | $movieInfo = $weburgClient->getMovieInfoById($movieId); |
263 | - $logger->info('Search series ' . $movieId); |
|
263 | + $logger->info('Search series '.$movieId); |
|
264 | 264 | if (!empty($movieInfo['hashes'])) { |
265 | 265 | $seriesUrls = $weburgClient->getSeriesTorrents($movieId, $movieInfo['hashes'], $daysMax, $allowedMisses); |
266 | 266 | $torrentsUrls = array_merge($torrentsUrls, $seriesUrls); |
267 | 267 | |
268 | 268 | if (count($seriesUrls)) { |
269 | - $logger->info('Download series ' . $movieId . ': ' |
|
270 | - . $movieInfo['title'] . ' (' . count($seriesUrls) . ')'); |
|
269 | + $logger->info('Download series '.$movieId.': ' |
|
270 | + . $movieInfo['title'].' ('.count($seriesUrls).')'); |
|
271 | 271 | } |
272 | 272 | } else { |
273 | 273 | $torrentsUrls = array_merge($torrentsUrls, $weburgClient->getMovieTorrentUrlsById($movieId)); |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | if (!file_exists($torrentsDir)) { |
296 | - throw new \RuntimeException('Destination directory not exists: ' . $torrentsDir); |
|
296 | + throw new \RuntimeException('Destination directory not exists: '.$torrentsDir); |
|
297 | 297 | } |
298 | 298 | |
299 | - $downloadDir = $torrentsDir . '/downloaded'; |
|
299 | + $downloadDir = $torrentsDir.'/downloaded'; |
|
300 | 300 | if (!file_exists($downloadDir)) { |
301 | 301 | mkdir($downloadDir, 0777); |
302 | 302 | } |
@@ -312,24 +312,24 @@ discard block |
||
312 | 312 | $whitelist = $config->get('download-filename-whitelist'); |
313 | 313 | $blacklist = $config->get('download-filename-blacklist'); |
314 | 314 | |
315 | - $torrentFiles = array_filter($torrentFiles, function ($torrentFile) use ($whitelist, $blacklist, $logger) { |
|
315 | + $torrentFiles = array_filter($torrentFiles, function($torrentFile) use ($whitelist, $blacklist, $logger) { |
|
316 | 316 | if (!empty($whitelist)) { |
317 | 317 | $matched = false; |
318 | 318 | foreach ($whitelist as $white) { |
319 | - if (preg_match('/' . $white . '/i', $torrentFile)) { |
|
320 | - $logger->info($torrentFile . ' matched whitelist: ' . $white); |
|
319 | + if (preg_match('/'.$white.'/i', $torrentFile)) { |
|
320 | + $logger->info($torrentFile.' matched whitelist: '.$white); |
|
321 | 321 | $matched = true; |
322 | 322 | } |
323 | 323 | } |
324 | 324 | if (!$matched) { |
325 | - $logger->info($torrentFile . ' not matched any whitelist: ' . implode(', ', $whitelist)); |
|
325 | + $logger->info($torrentFile.' not matched any whitelist: '.implode(', ', $whitelist)); |
|
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | } |
329 | 329 | if (!empty($blacklist)) { |
330 | 330 | foreach ($blacklist as $black) { |
331 | - if (preg_match('/' . $black . '/i', $torrentFile)) { |
|
332 | - $logger->info($torrentFile . ' matched blacklist: ' . $black); |
|
331 | + if (preg_match('/'.$black.'/i', $torrentFile)) { |
|
332 | + $logger->info($torrentFile.' matched blacklist: '.$black); |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | ); |
365 | 365 | |
366 | 366 | $addInput = new ArrayInput($arguments); |
367 | - $output->writeln("\nAdd torrents to " . $host); |
|
367 | + $output->writeln("\nAdd torrents to ".$host); |
|
368 | 368 | $command->run($addInput, $output); |
369 | 369 | } |
370 | 370 | } |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | { |
61 | 61 | $filters = self::parseFilters($filters); |
62 | 62 | |
63 | - return array_filter($rows, function ($row) use ($filters) { |
|
63 | + return array_filter($rows, function($row) use ($filters) { |
|
64 | 64 | foreach ($filters as $columnKey => $filter) { |
65 | 65 | if (!isset($row[$columnKey])) { |
66 | - throw new \RuntimeException('Column ' . $columnKey . ' not exists, cannot filter'); |
|
66 | + throw new \RuntimeException('Column '.$columnKey.' not exists, cannot filter'); |
|
67 | 67 | } |
68 | 68 | $columnValue = $row[$columnKey]; |
69 | 69 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | if ((isset($filter['min']) && $value <= $filter['min']) || |
81 | 81 | (isset($filter['max']) && $value >= $filter['max']) || |
82 | 82 | (isset($filter['equals']) && $value != $filter['equals']) || |
83 | - (isset($filter['regex']) && !preg_match('/' . $filter['regex'] . '/i', $value)) |
|
83 | + (isset($filter['regex']) && !preg_match('/'.$filter['regex'].'/i', $value)) |
|
84 | 84 | ) { |
85 | 85 | return false; |
86 | 86 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | ); |
108 | 108 | $columnIndex--; |
109 | 109 | |
110 | - usort($rowsSorted, function ($first, $second) use ($columnIndex, $sortOrder) { |
|
110 | + usort($rowsSorted, function($first, $second) use ($columnIndex, $sortOrder) { |
|
111 | 111 | return $first[$columnIndex] > $second[$columnIndex] ? $sortOrder : $sortOrder * -1; |
112 | 112 | }); |
113 | 113 |