@@ -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 | } |