Completed
Push — master ( ceb518...f28846 )
by Stanislav
01:40
created
src/Command/StatsSend.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
src/Helpers/TableUtils.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Command/WeburgSeriesAdd.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
         $seriesId = $weburgClient->cleanMovieId($seriesArgument);
45 45
 
46 46
         if (!$seriesId) {
47
-            $output->writeln($seriesArgument . ' seems not weburg series url');
47
+            $output->writeln($seriesArgument.' seems not weburg series url');
48 48
             return 1;
49 49
         }
50 50
 
51 51
         $seriesList = $config->get('weburg-series-list');
52
-        if (!empty(array_filter($seriesList, function ($item) use ($seriesId) {
52
+        if (!empty(array_filter($seriesList, function($item) use ($seriesId) {
53 53
             // can be array or id
54 54
             return is_array($item) ? $item['id'] == $seriesId : $item == $seriesId;
55 55
         }))) {
56
-            $output->writeln($seriesId . ' already in list');
56
+            $output->writeln($seriesId.' already in list');
57 57
             return 0;
58 58
         }
59 59
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $config->set('weburg-series-list', $seriesList);
67 67
         $config->saveConfigFile();
68 68
 
69
-        $output->writeln('Series ' . $seriesId . ' ' . $seriesInfo['title'] . ' added to list');
69
+        $output->writeln('Series '.$seriesId.' '.$seriesInfo['title'].' added to list');
70 70
         return 0;
71 71
     }
72 72
 }
Please login to merge, or discard this patch.
src/Command/WeburgInfo.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             $movieArgument = $input->getArgument('movie-id');
37 37
             $movieId = $weburgClient->cleanMovieId($movieArgument);
38 38
             if (!$movieId) {
39
-                throw new \RuntimeException($movieId . ' seems not weburg movie ID or URL');
39
+                throw new \RuntimeException($movieId.' seems not weburg movie ID or URL');
40 40
             }
41 41
 
42 42
             $movieInfo = $weburgClient->getMovieInfoById($movieId);
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
                     );
59 59
 
60 60
                     if (count($seriesUrls)) {
61
-                        $output->writeln('Found series: ' . count($seriesUrls));
61
+                        $output->writeln('Found series: '.count($seriesUrls));
62 62
                     }
63 63
                 }
64 64
             }
Please login to merge, or discard this patch.
src/Command/TorrentRemove.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             try {
82 82
                 $influxDbClient = $this->getApplication()->getInfluxDbClient(
83 83
                     $config->get('influxdb-host'),
Please login to merge, or discard this patch.
src/Command/TorrentRemoveDuplicates.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
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
             try {
65 65
                 $influxDbClient = $this->getApplication()->getInfluxDbClient(
66 66
                     $config->get('influxdb-host'),
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
 
78 78
             $client->removeTorrents($obsoleteList);
79 79
             $names = TorrentListUtils::getArrayField($obsoleteList, Torrent\Get::NAME);
80
-            $output->writeln('Removed torrents:' . implode(', ', $names));
80
+            $output->writeln('Removed torrents:'.implode(', ', $names));
81 81
         }, 'dry-run, don\'t really remove');
82 82
 
83
-        $output->writeln('Found and deleted ' . count($obsoleteList) . ' obsolete torrents from transmission.');
83
+        $output->writeln('Found and deleted '.count($obsoleteList).' obsolete torrents from transmission.');
84 84
         return 0;
85 85
     }
86 86
 }
Please login to merge, or discard this patch.
src/Command/StatsGet.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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',
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         TableUtils::printTable($tableData, $output);
134 134
 
135 135
         $freeSpace = $client->getFreeSpace();
136
-        $output->writeln('Free space: ' . TorrentUtils::getSizeInGb($freeSpace) . ' GB');
136
+        $output->writeln('Free space: '.TorrentUtils::getSizeInGb($freeSpace).' GB');
137 137
 
138 138
         if ($input->getOption('rm') && count($torrentList) > 0) {
139 139
             return $this->removeTorrents($input, $output, $tableData['rows']);
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             'headers' => ['Name', 'Id', 'Age, days', 'Size, GB', 'Uploaded, GB', 'Per day, GB', 'Profit, %'],
182 182
             'rows' => $rows,
183 183
             'totals' => [
184
-                'Total: ' . count($rows),
184
+                'Total: '.count($rows),
185 185
                 '',
186 186
                 '',
187 187
                 TorrentListUtils::sumArrayField($rows, 3),
Please login to merge, or discard this patch.
src/WeburgClient.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     public function getSeriesTorrents($movieId, $hashes, $daysMax = 1, $allowedMisses = 0)
68 68
     {
69 69
         $torrentsUrls = [];
70
-        $timestampFrom = strtotime('-' . $daysMax . 'days');
70
+        $timestampFrom = strtotime('-'.$daysMax.'days');
71 71
 
72 72
         $hashes = array_reverse($hashes);
73 73
         foreach ($hashes as $hash) {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function movieQuery($q)
138 138
     {
139
-        $resultUrl = 'https://weburg.net/ajax/autocomplete/search/main?' . http_build_query(['q' => $q]);
139
+        $resultUrl = 'https://weburg.net/ajax/autocomplete/search/main?'.http_build_query(['q' => $q]);
140 140
 
141 141
         $jsonRaw = $this->getUrlBody($resultUrl, [
142 142
             'Content-Type' => 'text/html; charset=utf-8',
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
     public static function getMovieUrl($movieId)
153 153
     {
154
-        return 'https://weburg.net/movies/info/' . $movieId;
154
+        return 'https://weburg.net/movies/info/'.$movieId;
155 155
     }
156 156
 
157 157
     /**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         ]);
172 172
 
173 173
         if ($res->getStatusCode() != 200) {
174
-            throw new RuntimeException('Error ' . $res->getStatusCode() . 'while get url ' . $url);
174
+            throw new RuntimeException('Error '.$res->getStatusCode().'while get url '.$url);
175 175
         }
176 176
 
177 177
         sleep($this->requestDelay);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         preg_match('/filename="(.*?)"/', $disposition[0], $res);
210 210
         $filename = $res[1];
211 211
 
212
-        $filePath = $torrentsDir . '/' . $filename;
212
+        $filePath = $torrentsDir.'/'.$filename;
213 213
         file_put_contents($filePath, $torrentBody);
214 214
 
215 215
         return $filePath;
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
     private static function getMovieTorrentUrl($movieId, $hash = '')
237 237
     {
238 238
         return 'https://weburg.net/ajax/download/movie?'
239
-            . ($hash ? 'hash=' . $hash . '&' : '')
240
-            . 'obj_id=' . $movieId;
239
+            . ($hash ? 'hash='.$hash.'&' : '')
240
+            . 'obj_id='.$movieId;
241 241
     }
242 242
 
243 243
     private static function getMovieInfo($body)
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         ];
254 254
 
255 255
         foreach ($checks as $name => $regexp) {
256
-            preg_match('/' . $regexp . '/mis', $body, $res);
256
+            preg_match('/'.$regexp.'/mis', $body, $res);
257 257
             $info[$name] = count($res) ? $res[1] : null;
258 258
         }
259 259
 
Please login to merge, or discard this patch.
src/Command/WeburgDownload.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 );
91 91
             }
92 92
 
93
-            $this->dryRun($input, $output, function () use (
93
+            $this->dryRun($input, $output, function() use (
94 94
                 $input,
95 95
                 $output,
96 96
                 $weburgClient,
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
                 $limit = $input->getOption('limit');
106 106
                 if ($limit && count($torrentsUrls) > $limit) {
107
-                    $output->writeln("\nLimit list from " . count($torrentsUrls) . " to $limit");
107
+                    $output->writeln("\nLimit list from ".count($torrentsUrls)." to $limit");
108 108
                     $torrentsUrls = array_slice($torrentsUrls, 0, $limit);
109 109
                 }
110 110
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             $output->writeln("\nNot found any for query $query");
180 180
         }
181 181
 
182
-        $downloadedLogfile = $downloadDir . '/' . $movieId;
182
+        $downloadedLogfile = $downloadDir.'/'.$movieId;
183 183
 
184 184
         $isDownloaded = file_exists($downloadedLogfile);
185 185
         if ($isDownloaded) {
@@ -189,17 +189,17 @@  discard block
 block discarded – undo
189 189
         $movieInfo = $weburgClient->getMovieInfoById($movieId);
190 190
         foreach (array_keys($movieInfo) as $infoField) {
191 191
             if (!isset($movieInfo[$infoField])) {
192
-                $logger->warning('Cannot find ' . $infoField . ' in movie ' . $movieId);
192
+                $logger->warning('Cannot find '.$infoField.' in movie '.$movieId);
193 193
             }
194 194
         }
195 195
 
196 196
         $movieUrls = $weburgClient->getMovieTorrentUrlsById($movieId);
197 197
         $torrentsUrls = array_merge($torrentsUrls, $movieUrls);
198
-        $logger->info('Download movie ' . $movieId . ': ' . $movieInfo['title']);
198
+        $logger->info('Download movie '.$movieId.': '.$movieInfo['title']);
199 199
 
200 200
         file_put_contents(
201 201
             $downloadedLogfile,
202
-            date('Y-m-d H:i:s') . "\n" . implode("\n", $torrentsUrls)
202
+            date('Y-m-d H:i:s')."\n".implode("\n", $torrentsUrls)
203 203
         );
204 204
 
205 205
         return $torrentsUrls;
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
         $progress->start();
225 225
 
226 226
         foreach ($moviesIds as $movieId) {
227
-            $progress->setMessage('Check movie ' . $movieId . '...');
227
+            $progress->setMessage('Check movie '.$movieId.'...');
228 228
             $progress->advance();
229 229
 
230
-            $downloadedLogfile = $downloadDir . '/' . $movieId;
230
+            $downloadedLogfile = $downloadDir.'/'.$movieId;
231 231
 
232 232
             $isDownloaded = file_exists($downloadedLogfile);
233 233
             if ($isDownloaded) {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             $movieInfo = $weburgClient->getMovieInfoById($movieId);
238 238
             foreach (array_keys($movieInfo) as $infoField) {
239 239
                 if (!isset($movieInfo[$infoField])) {
240
-                    $logger->warning('Cannot find ' . $infoField . ' in movie ' . $movieId);
240
+                    $logger->warning('Cannot find '.$infoField.' in movie '.$movieId);
241 241
                 }
242 242
             }
243 243
 
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
             );
251 251
 
252 252
             if ($isTorrentPopular) {
253
-                $progress->setMessage('Download movie ' . $movieId . '...');
253
+                $progress->setMessage('Download movie '.$movieId.'...');
254 254
 
255 255
                 $movieUrls = $weburgClient->getMovieTorrentUrlsById($movieId);
256 256
                 $torrentsUrls = array_merge($torrentsUrls, $movieUrls);
257
-                $logger->info('Download movie ' . $movieId . ': ' . $movieInfo['title']);
257
+                $logger->info('Download movie '.$movieId.': '.$movieInfo['title']);
258 258
 
259 259
                 file_put_contents(
260 260
                     $downloadedLogfile,
261
-                    date('Y-m-d H:i:s') . "\n" . implode("\n", $torrentsUrls)
261
+                    date('Y-m-d H:i:s')."\n".implode("\n", $torrentsUrls)
262 262
                 );
263 263
             }
264 264
         }
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
             } else {
299 299
                 $seriesId = $seriesTitle = $seriesItem;
300 300
             }
301
-            $progress->setMessage('Check series ' . $seriesTitle . '...');
301
+            $progress->setMessage('Check series '.$seriesTitle.'...');
302 302
             $progress->advance();
303 303
 
304 304
             $movieInfo = $weburgClient->getMovieInfoById($seriesId);
@@ -325,18 +325,18 @@  discard block
 block discarded – undo
325 325
 
326 326
         $movieId = $weburgClient->cleanMovieId($movieId);
327 327
         if (!$movieId) {
328
-            throw new \RuntimeException($movieId . ' seems not weburg movie ID or URL');
328
+            throw new \RuntimeException($movieId.' seems not weburg movie ID or URL');
329 329
         }
330 330
 
331 331
         $movieInfo = $weburgClient->getMovieInfoById($movieId);
332
-        $logger->info('Search series ' . $movieId);
332
+        $logger->info('Search series '.$movieId);
333 333
         if (!empty($movieInfo['hashes'])) {
334 334
             $seriesUrls = $weburgClient->getSeriesTorrents($movieId, $movieInfo['hashes'], $daysMax, $allowedMisses);
335 335
             $torrentsUrls = array_merge($torrentsUrls, $seriesUrls);
336 336
 
337 337
             if (count($seriesUrls)) {
338
-                $logger->info('Download series ' . $movieId . ': '
339
-                    . $movieInfo['title'] . ' (' . count($seriesUrls) . ')');
338
+                $logger->info('Download series '.$movieId.': '
339
+                    . $movieInfo['title'].' ('.count($seriesUrls).')');
340 340
             }
341 341
         } else {
342 342
             $torrentsUrls = array_merge($torrentsUrls, $weburgClient->getMovieTorrentUrlsById($movieId));
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
         }
363 363
 
364 364
         if (!file_exists($torrentsDir)) {
365
-            throw new \RuntimeException('Destination directory not exists: ' . $torrentsDir);
365
+            throw new \RuntimeException('Destination directory not exists: '.$torrentsDir);
366 366
         }
367 367
 
368
-        $downloadDir = $torrentsDir . '/downloaded';
368
+        $downloadDir = $torrentsDir.'/downloaded';
369 369
         if (!file_exists($downloadDir)) {
370 370
             mkdir($downloadDir, 0777);
371 371
         }
@@ -381,24 +381,24 @@  discard block
 block discarded – undo
381 381
         $whitelist = $config->get('download-filename-whitelist');
382 382
         $blacklist = $config->get('download-filename-blacklist');
383 383
 
384
-        $torrentFiles = array_filter($torrentFiles, function ($torrentFile) use ($whitelist, $blacklist, $logger) {
384
+        $torrentFiles = array_filter($torrentFiles, function($torrentFile) use ($whitelist, $blacklist, $logger) {
385 385
             if (!empty($whitelist)) {
386 386
                 $matched = false;
387 387
                 foreach ($whitelist as $white) {
388
-                    if (preg_match('/' . $white . '/i', $torrentFile)) {
389
-                        $logger->info($torrentFile . ' matched whitelist: ' . $white);
388
+                    if (preg_match('/'.$white.'/i', $torrentFile)) {
389
+                        $logger->info($torrentFile.' matched whitelist: '.$white);
390 390
                         $matched = true;
391 391
                     }
392 392
                 }
393 393
                 if (!$matched) {
394
-                    $logger->info($torrentFile . ' not matched any whitelist: ' . implode(', ', $whitelist));
394
+                    $logger->info($torrentFile.' not matched any whitelist: '.implode(', ', $whitelist));
395 395
                     return false;
396 396
                 }
397 397
             }
398 398
             if (!empty($blacklist)) {
399 399
                 foreach ($blacklist as $black) {
400
-                    if (preg_match('/' . $black . '/i', $torrentFile)) {
401
-                        $logger->info($torrentFile . ' matched blacklist: ' . $black);
400
+                    if (preg_match('/'.$black.'/i', $torrentFile)) {
401
+                        $logger->info($torrentFile.' matched blacklist: '.$black);
402 402
                         return false;
403 403
                     }
404 404
                 }
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             );
434 434
 
435 435
             $addInput = new ArrayInput($arguments);
436
-            $output->writeln("\nAdd " . count($torrentFiles) . " torrents to " . $host);
436
+            $output->writeln("\nAdd ".count($torrentFiles)." torrents to ".$host);
437 437
             $command->run($addInput, $output);
438 438
         }
439 439
     }
Please login to merge, or discard this patch.