@@ -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) { |
@@ -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 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | public function getSeriesTorrents($movieId, $hashes, $daysMax = 1, $allowedMisses = 0) |
| 52 | 52 | { |
| 53 | 53 | $torrentsUrls = []; |
| 54 | - $timestampFrom = strtotime('-' . $daysMax . 'days'); |
|
| 54 | + $timestampFrom = strtotime('-'.$daysMax.'days'); |
|
| 55 | 55 | |
| 56 | 56 | $hashes = array_reverse($hashes); |
| 57 | 57 | foreach ($hashes as $hash) { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public function getMovieUrl($movieId) |
| 94 | 94 | { |
| 95 | - return 'https://weburg.net/movies/info/' . $movieId; |
|
| 95 | + return 'https://weburg.net/movies/info/'.$movieId; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | ]); |
| 112 | 112 | |
| 113 | 113 | if ($res->getStatusCode() != 200) { |
| 114 | - throw new \RuntimeException('Error ' . $res->getStatusCode() . 'while get url ' . $url); |
|
| 114 | + throw new \RuntimeException('Error '.$res->getStatusCode().'while get url '.$url); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | sleep($this->requestDelay); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | preg_match('/filename="(.*?)"/', $disposition[0], $res); |
| 148 | 148 | $filename = $res[1]; |
| 149 | 149 | |
| 150 | - $filePath = $torrentsDir . '/' . $filename; |
|
| 150 | + $filePath = $torrentsDir.'/'.$filename; |
|
| 151 | 151 | file_put_contents($filePath, $torrentBody); |
| 152 | 152 | |
| 153 | 153 | return $filePath; |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | private function getMovieTorrentUrl($movieId, $hash = '') |
| 175 | 175 | { |
| 176 | 176 | return 'https://weburg.net/ajax/download/movie?' |
| 177 | - . ($hash ? 'hash=' . $hash . '&' : '') |
|
| 178 | - . 'obj_id=' . $movieId; |
|
| 177 | + . ($hash ? 'hash='.$hash.'&' : '') |
|
| 178 | + . 'obj_id='.$movieId; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | private function getMovieInfo($body) |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | ]; |
| 192 | 192 | |
| 193 | 193 | foreach ($checks as $name => $regexp) { |
| 194 | - preg_match('/' . $regexp . '/mis', $body, $res); |
|
| 194 | + preg_match('/'.$regexp.'/mis', $body, $res); |
|
| 195 | 195 | $info[$name] = count($res) ? $res[1] : null; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -44,16 +44,16 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -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 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | } else { |
| 236 | 236 | $seriesId = $seriesTitle = $seriesItem; |
| 237 | 237 | } |
| 238 | - $progress->setMessage('Check series ' . $seriesTitle . '...'); |
|
| 238 | + $progress->setMessage('Check series '.$seriesTitle.'...'); |
|
| 239 | 239 | $progress->advance(); |
| 240 | 240 | |
| 241 | 241 | $movieInfo = $weburgClient->getMovieInfoById($seriesId); |
@@ -262,18 +262,18 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | $movieId = $weburgClient->cleanMovieId($movieId); |
| 264 | 264 | if (!$movieId) { |
| 265 | - throw new \RuntimeException($movieId . ' seems not weburg movie ID or URL'); |
|
| 265 | + throw new \RuntimeException($movieId.' seems not weburg movie ID or URL'); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | $movieInfo = $weburgClient->getMovieInfoById($movieId); |
| 269 | - $logger->info('Search series ' . $movieId); |
|
| 269 | + $logger->info('Search series '.$movieId); |
|
| 270 | 270 | if (!empty($movieInfo['hashes'])) { |
| 271 | 271 | $seriesUrls = $weburgClient->getSeriesTorrents($movieId, $movieInfo['hashes'], $daysMax, $allowedMisses); |
| 272 | 272 | $torrentsUrls = array_merge($torrentsUrls, $seriesUrls); |
| 273 | 273 | |
| 274 | 274 | if (count($seriesUrls)) { |
| 275 | - $logger->info('Download series ' . $movieId . ': ' |
|
| 276 | - . $movieInfo['title'] . ' (' . count($seriesUrls) . ')'); |
|
| 275 | + $logger->info('Download series '.$movieId.': ' |
|
| 276 | + . $movieInfo['title'].' ('.count($seriesUrls).')'); |
|
| 277 | 277 | } |
| 278 | 278 | } else { |
| 279 | 279 | $torrentsUrls = array_merge($torrentsUrls, $weburgClient->getMovieTorrentUrlsById($movieId)); |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | if (!file_exists($torrentsDir)) { |
| 302 | - throw new \RuntimeException('Destination directory not exists: ' . $torrentsDir); |
|
| 302 | + throw new \RuntimeException('Destination directory not exists: '.$torrentsDir); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $downloadDir = $torrentsDir . '/downloaded'; |
|
| 305 | + $downloadDir = $torrentsDir.'/downloaded'; |
|
| 306 | 306 | if (!file_exists($downloadDir)) { |
| 307 | 307 | mkdir($downloadDir, 0777); |
| 308 | 308 | } |
@@ -318,24 +318,24 @@ discard block |
||
| 318 | 318 | $whitelist = $config->get('download-filename-whitelist'); |
| 319 | 319 | $blacklist = $config->get('download-filename-blacklist'); |
| 320 | 320 | |
| 321 | - $torrentFiles = array_filter($torrentFiles, function ($torrentFile) use ($whitelist, $blacklist, $logger) { |
|
| 321 | + $torrentFiles = array_filter($torrentFiles, function($torrentFile) use ($whitelist, $blacklist, $logger) { |
|
| 322 | 322 | if (!empty($whitelist)) { |
| 323 | 323 | $matched = false; |
| 324 | 324 | foreach ($whitelist as $white) { |
| 325 | - if (preg_match('/' . $white . '/i', $torrentFile)) { |
|
| 326 | - $logger->info($torrentFile . ' matched whitelist: ' . $white); |
|
| 325 | + if (preg_match('/'.$white.'/i', $torrentFile)) { |
|
| 326 | + $logger->info($torrentFile.' matched whitelist: '.$white); |
|
| 327 | 327 | $matched = true; |
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | if (!$matched) { |
| 331 | - $logger->info($torrentFile . ' not matched any whitelist: ' . implode(', ', $whitelist)); |
|
| 331 | + $logger->info($torrentFile.' not matched any whitelist: '.implode(', ', $whitelist)); |
|
| 332 | 332 | return false; |
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | 335 | if (!empty($blacklist)) { |
| 336 | 336 | foreach ($blacklist as $black) { |
| 337 | - if (preg_match('/' . $black . '/i', $torrentFile)) { |
|
| 338 | - $logger->info($torrentFile . ' matched blacklist: ' . $black); |
|
| 337 | + if (preg_match('/'.$black.'/i', $torrentFile)) { |
|
| 338 | + $logger->info($torrentFile.' matched blacklist: '.$black); |
|
| 339 | 339 | return false; |
| 340 | 340 | } |
| 341 | 341 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | ); |
| 371 | 371 | |
| 372 | 372 | $addInput = new ArrayInput($arguments); |
| 373 | - $output->writeln("\nAdd torrents to " . $host); |
|
| 373 | + $output->writeln("\nAdd torrents to ".$host); |
|
| 374 | 374 | $command->run($addInput, $output); |
| 375 | 375 | } |
| 376 | 376 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 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 |
||
| 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 | } |