@@ -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 | |
@@ -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 | } |
@@ -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 | } |
@@ -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 | try { |
| 82 | 82 | $influxDbClient = $this->getApplication()->getInfluxDbClient( |
| 83 | 83 | $config->get('influxdb-host'), |
@@ -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 | try { |
| 65 | 65 | $influxDbClient = $this->getApplication()->getInfluxDbClient( |
| 66 | 66 | $config->get('influxdb-host'), |
@@ -77,10 +77,10 @@ discard block |
||
| 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 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public function getSeriesTorrents($movieId, $hashes, $daysMax = 1, $allowedMisses = 0) |
| 64 | 64 | { |
| 65 | 65 | $torrentsUrls = []; |
| 66 | - $timestampFrom = strtotime('-' . $daysMax . 'days'); |
|
| 66 | + $timestampFrom = strtotime('-'.$daysMax.'days'); |
|
| 67 | 67 | |
| 68 | 68 | $hashes = array_reverse($hashes); |
| 69 | 69 | foreach ($hashes as $hash) { |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function movieQuery($q) |
| 131 | 131 | { |
| 132 | - $resultUrl = 'https://weburg.net/ajax/autocomplete/search/main?' . http_build_query(['q' => $q]); |
|
| 132 | + $resultUrl = 'https://weburg.net/ajax/autocomplete/search/main?'.http_build_query(['q' => $q]); |
|
| 133 | 133 | |
| 134 | 134 | $jsonRaw = $this->getUrlBody($resultUrl, [ |
| 135 | 135 | 'Content-Type' => 'text/html; charset=utf-8', |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | public static function getMovieUrl($movieId) |
| 146 | 146 | { |
| 147 | - return 'https://weburg.net/movies/info/' . $movieId; |
|
| 147 | + return 'https://weburg.net/movies/info/'.$movieId; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | ]); |
| 165 | 165 | |
| 166 | 166 | if ($res->getStatusCode() != 200) { |
| 167 | - throw new \RuntimeException('Error ' . $res->getStatusCode() . 'while get url ' . $url); |
|
| 167 | + throw new \RuntimeException('Error '.$res->getStatusCode().'while get url '.$url); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | sleep($this->requestDelay); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | preg_match('/filename="(.*?)"/', $disposition[0], $res); |
| 203 | 203 | $filename = $res[1]; |
| 204 | 204 | |
| 205 | - $filePath = $torrentsDir . '/' . $filename; |
|
| 205 | + $filePath = $torrentsDir.'/'.$filename; |
|
| 206 | 206 | file_put_contents($filePath, $torrentBody); |
| 207 | 207 | |
| 208 | 208 | return $filePath; |
@@ -229,8 +229,8 @@ discard block |
||
| 229 | 229 | private static function getMovieTorrentUrl($movieId, $hash = '') |
| 230 | 230 | { |
| 231 | 231 | return 'https://weburg.net/ajax/download/movie?' |
| 232 | - . ($hash ? 'hash=' . $hash . '&' : '') |
|
| 233 | - . 'obj_id=' . $movieId; |
|
| 232 | + . ($hash ? 'hash='.$hash.'&' : '') |
|
| 233 | + . 'obj_id='.$movieId; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | private static function getMovieInfo($body) |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | ]; |
| 247 | 247 | |
| 248 | 248 | foreach ($checks as $name => $regexp) { |
| 249 | - preg_match('/' . $regexp . '/mis', $body, $res); |
|
| 249 | + preg_match('/'.$regexp.'/mis', $body, $res); |
|
| 250 | 250 | $info[$name] = count($res) ? $res[1] : null; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | ); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $this->dryRun($input, $output, function () use ( |
|
| 91 | + $this->dryRun($input, $output, function() use ( |
|
| 92 | 92 | $input, |
| 93 | 93 | $output, |
| 94 | 94 | $weburgClient, |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $output->writeln("\nNot found any for query $query"); |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $downloadedLogfile = $downloadDir . '/' . $movieId; |
|
| 173 | + $downloadedLogfile = $downloadDir.'/'.$movieId; |
|
| 174 | 174 | |
| 175 | 175 | $isDownloaded = file_exists($downloadedLogfile); |
| 176 | 176 | if ($isDownloaded) { |
@@ -180,17 +180,17 @@ discard block |
||
| 180 | 180 | $movieInfo = $weburgClient->getMovieInfoById($movieId); |
| 181 | 181 | foreach (array_keys($movieInfo) as $infoField) { |
| 182 | 182 | if (!isset($movieInfo[$infoField])) { |
| 183 | - $logger->warning('Cannot find ' . $infoField . ' in movie ' . $movieId); |
|
| 183 | + $logger->warning('Cannot find '.$infoField.' in movie '.$movieId); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $movieUrls = $weburgClient->getMovieTorrentUrlsById($movieId); |
| 188 | 188 | $torrentsUrls = array_merge($torrentsUrls, $movieUrls); |
| 189 | - $logger->info('Download movie ' . $movieId . ': ' . $movieInfo['title']); |
|
| 189 | + $logger->info('Download movie '.$movieId.': '.$movieInfo['title']); |
|
| 190 | 190 | |
| 191 | 191 | file_put_contents( |
| 192 | 192 | $downloadedLogfile, |
| 193 | - date('Y-m-d H:i:s') . "\n" . implode("\n", $torrentsUrls) |
|
| 193 | + date('Y-m-d H:i:s')."\n".implode("\n", $torrentsUrls) |
|
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | 196 | return $torrentsUrls; |
@@ -211,10 +211,10 @@ discard block |
||
| 211 | 211 | $progress->start(); |
| 212 | 212 | |
| 213 | 213 | foreach ($moviesIds as $movieId) { |
| 214 | - $progress->setMessage('Check movie ' . $movieId . '...'); |
|
| 214 | + $progress->setMessage('Check movie '.$movieId.'...'); |
|
| 215 | 215 | $progress->advance(); |
| 216 | 216 | |
| 217 | - $downloadedLogfile = $downloadDir . '/' . $movieId; |
|
| 217 | + $downloadedLogfile = $downloadDir.'/'.$movieId; |
|
| 218 | 218 | |
| 219 | 219 | $isDownloaded = file_exists($downloadedLogfile); |
| 220 | 220 | if ($isDownloaded) { |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $movieInfo = $weburgClient->getMovieInfoById($movieId); |
| 225 | 225 | foreach (array_keys($movieInfo) as $infoField) { |
| 226 | 226 | if (!isset($movieInfo[$infoField])) { |
| 227 | - $logger->warning('Cannot find ' . $infoField . ' in movie ' . $movieId); |
|
| 227 | + $logger->warning('Cannot find '.$infoField.' in movie '.$movieId); |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
@@ -237,15 +237,15 @@ discard block |
||
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | 239 | if ($isTorrentPopular) { |
| 240 | - $progress->setMessage('Download movie ' . $movieId . '...'); |
|
| 240 | + $progress->setMessage('Download movie '.$movieId.'...'); |
|
| 241 | 241 | |
| 242 | 242 | $movieUrls = $weburgClient->getMovieTorrentUrlsById($movieId); |
| 243 | 243 | $torrentsUrls = array_merge($torrentsUrls, $movieUrls); |
| 244 | - $logger->info('Download movie ' . $movieId . ': ' . $movieInfo['title']); |
|
| 244 | + $logger->info('Download movie '.$movieId.': '.$movieInfo['title']); |
|
| 245 | 245 | |
| 246 | 246 | file_put_contents( |
| 247 | 247 | $downloadedLogfile, |
| 248 | - date('Y-m-d H:i:s') . "\n" . implode("\n", $torrentsUrls) |
|
| 248 | + date('Y-m-d H:i:s')."\n".implode("\n", $torrentsUrls) |
|
| 249 | 249 | ); |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } else { |
| 286 | 286 | $seriesId = $seriesTitle = $seriesItem; |
| 287 | 287 | } |
| 288 | - $progress->setMessage('Check series ' . $seriesTitle . '...'); |
|
| 288 | + $progress->setMessage('Check series '.$seriesTitle.'...'); |
|
| 289 | 289 | $progress->advance(); |
| 290 | 290 | |
| 291 | 291 | $movieInfo = $weburgClient->getMovieInfoById($seriesId); |
@@ -312,18 +312,18 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | $movieId = $weburgClient->cleanMovieId($movieId); |
| 314 | 314 | if (!$movieId) { |
| 315 | - throw new \RuntimeException($movieId . ' seems not weburg movie ID or URL'); |
|
| 315 | + throw new \RuntimeException($movieId.' seems not weburg movie ID or URL'); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | $movieInfo = $weburgClient->getMovieInfoById($movieId); |
| 319 | - $logger->info('Search series ' . $movieId); |
|
| 319 | + $logger->info('Search series '.$movieId); |
|
| 320 | 320 | if (!empty($movieInfo['hashes'])) { |
| 321 | 321 | $seriesUrls = $weburgClient->getSeriesTorrents($movieId, $movieInfo['hashes'], $daysMax, $allowedMisses); |
| 322 | 322 | $torrentsUrls = array_merge($torrentsUrls, $seriesUrls); |
| 323 | 323 | |
| 324 | 324 | if (count($seriesUrls)) { |
| 325 | - $logger->info('Download series ' . $movieId . ': ' |
|
| 326 | - . $movieInfo['title'] . ' (' . count($seriesUrls) . ')'); |
|
| 325 | + $logger->info('Download series '.$movieId.': ' |
|
| 326 | + . $movieInfo['title'].' ('.count($seriesUrls).')'); |
|
| 327 | 327 | } |
| 328 | 328 | } else { |
| 329 | 329 | $torrentsUrls = array_merge($torrentsUrls, $weburgClient->getMovieTorrentUrlsById($movieId)); |
@@ -349,10 +349,10 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | if (!file_exists($torrentsDir)) { |
| 352 | - throw new \RuntimeException('Destination directory not exists: ' . $torrentsDir); |
|
| 352 | + throw new \RuntimeException('Destination directory not exists: '.$torrentsDir); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - $downloadDir = $torrentsDir . '/downloaded'; |
|
| 355 | + $downloadDir = $torrentsDir.'/downloaded'; |
|
| 356 | 356 | if (!file_exists($downloadDir)) { |
| 357 | 357 | mkdir($downloadDir, 0777); |
| 358 | 358 | } |
@@ -368,24 +368,24 @@ discard block |
||
| 368 | 368 | $whitelist = $config->get('download-filename-whitelist'); |
| 369 | 369 | $blacklist = $config->get('download-filename-blacklist'); |
| 370 | 370 | |
| 371 | - $torrentFiles = array_filter($torrentFiles, function ($torrentFile) use ($whitelist, $blacklist, $logger) { |
|
| 371 | + $torrentFiles = array_filter($torrentFiles, function($torrentFile) use ($whitelist, $blacklist, $logger) { |
|
| 372 | 372 | if (!empty($whitelist)) { |
| 373 | 373 | $matched = false; |
| 374 | 374 | foreach ($whitelist as $white) { |
| 375 | - if (preg_match('/' . $white . '/i', $torrentFile)) { |
|
| 376 | - $logger->info($torrentFile . ' matched whitelist: ' . $white); |
|
| 375 | + if (preg_match('/'.$white.'/i', $torrentFile)) { |
|
| 376 | + $logger->info($torrentFile.' matched whitelist: '.$white); |
|
| 377 | 377 | $matched = true; |
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | if (!$matched) { |
| 381 | - $logger->info($torrentFile . ' not matched any whitelist: ' . implode(', ', $whitelist)); |
|
| 381 | + $logger->info($torrentFile.' not matched any whitelist: '.implode(', ', $whitelist)); |
|
| 382 | 382 | return false; |
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | if (!empty($blacklist)) { |
| 386 | 386 | foreach ($blacklist as $black) { |
| 387 | - if (preg_match('/' . $black . '/i', $torrentFile)) { |
|
| 388 | - $logger->info($torrentFile . ' matched blacklist: ' . $black); |
|
| 387 | + if (preg_match('/'.$black.'/i', $torrentFile)) { |
|
| 388 | + $logger->info($torrentFile.' matched blacklist: '.$black); |
|
| 389 | 389 | return false; |
| 390 | 390 | } |
| 391 | 391 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | ); |
| 421 | 421 | |
| 422 | 422 | $addInput = new ArrayInput($arguments); |
| 423 | - $output->writeln("\nAdd " . count($torrentFiles) . " torrents to " . $host); |
|
| 423 | + $output->writeln("\nAdd ".count($torrentFiles)." torrents to ".$host); |
|
| 424 | 424 | $command->run($addInput, $output); |
| 425 | 425 | } |
| 426 | 426 | } |