@@ -292,11 +292,11 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | // Pass the binary extractors to ArchiveInfo. |
| 294 | 294 | $clients = []; |
| 295 | - if (! empty(Settings::settingValue('apps..unrarpath'))) { |
|
| 295 | + if (!empty(Settings::settingValue('apps..unrarpath'))) { |
|
| 296 | 296 | $this->_unrarPath = Settings::settingValue('apps..unrarpath'); |
| 297 | 297 | $clients += [ArchiveInfo::TYPE_RAR => $this->_unrarPath]; |
| 298 | 298 | } |
| 299 | - if (! empty(Settings::settingValue('apps..zippath'))) { |
|
| 299 | + if (!empty(Settings::settingValue('apps..zippath'))) { |
|
| 300 | 300 | $this->_7zipPath = Settings::settingValue('apps..zippath'); |
| 301 | 301 | $clients += [ArchiveInfo::TYPE_SZIP => $this->_7zipPath]; |
| 302 | 302 | $clients += [ArchiveInfo::TYPE_ZIP => $this->_7zipPath]; |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | $this->_archiveInfo->setExternalClients($clients); |
| 305 | 305 | |
| 306 | 306 | $this->_killString = '"'; |
| 307 | - if (! empty(Settings::settingValue('apps..timeoutpath')) && (int) Settings::settingValue('..timeoutseconds') > 0) { |
|
| 307 | + if (!empty(Settings::settingValue('apps..timeoutpath')) && (int) Settings::settingValue('..timeoutseconds') > 0) { |
|
| 308 | 308 | $this->_killString = ( |
| 309 | 309 | '"'.Settings::settingValue('apps..timeoutpath'). |
| 310 | 310 | '" --foreground --signal=KILL '. |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | $this->_addPAR2Files = (int) Settings::settingValue('..addpar2') !== 0; |
| 346 | 346 | |
| 347 | - if (! Settings::settingValue('apps..ffmpegpath')) { |
|
| 347 | + if (!Settings::settingValue('apps..ffmpegpath')) { |
|
| 348 | 348 | $this->_processAudioSample = $this->_processThumbnails = $this->_processVideo = false; |
| 349 | 349 | } else { |
| 350 | 350 | $this->_processAudioSample = (int) Settings::settingValue('..saveaudiopreview') !== 0; |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $this->_processJPGSample = (int) Settings::settingValue('..processjpg') !== 0; |
| 356 | 356 | $this->_processMediaInfo = Settings::settingValue('apps..mediainfopath') !== ''; |
| 357 | 357 | $this->_processAudioInfo = $this->_processMediaInfo; |
| 358 | - $this->_processPasswords = ! empty(Settings::settingValue('..checkpasswordedrar')) && ! empty(Settings::settingValue('apps..unrarpath')); |
|
| 358 | + $this->_processPasswords = !empty(Settings::settingValue('..checkpasswordedrar')) && !empty(Settings::settingValue('apps..unrarpath')); |
|
| 359 | 359 | |
| 360 | 360 | $this->_audioSavePath = storage_path('covers/audiosample/'); |
| 361 | 361 | |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | $this->_mainTmpPath = config('nntmux.tmp_unrar_path'); |
| 413 | 413 | |
| 414 | 414 | // Check if it ends with a dir separator. |
| 415 | - if (! Str::endsWith($this->_mainTmpPath, '/') && ! Str::endsWith($this->_mainTmpPath, '\\')) { |
|
| 415 | + if (!Str::endsWith($this->_mainTmpPath, '/') && !Str::endsWith($this->_mainTmpPath, '\\')) { |
|
| 416 | 416 | $this->_mainTmpPath .= '/'; |
| 417 | 417 | } |
| 418 | 418 | |
@@ -423,13 +423,13 @@ discard block |
||
| 423 | 423 | $this->_mainTmpPath .= $guidChar.'/'; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | - if (! File::isDirectory($this->_mainTmpPath)) { |
|
| 427 | - if (! File::makeDirectory($this->_mainTmpPath, 0777, true, true) && ! File::isDirectory($this->_mainTmpPath)) { |
|
| 426 | + if (!File::isDirectory($this->_mainTmpPath)) { |
|
| 427 | + if (!File::makeDirectory($this->_mainTmpPath, 0777, true, true) && !File::isDirectory($this->_mainTmpPath)) { |
|
| 428 | 428 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $this->_mainTmpPath)); |
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - if (! File::isDirectory($this->_mainTmpPath)) { |
|
| 432 | + if (!File::isDirectory($this->_mainTmpPath)) { |
|
| 433 | 433 | throw new \RuntimeException('Could not create the tmpunrar folder ('.$this->_mainTmpPath.')'); |
| 434 | 434 | } |
| 435 | 435 | |
@@ -467,10 +467,10 @@ discard block |
||
| 467 | 467 | if ($this->_minSize > 0) { |
| 468 | 468 | $releasesQuery->where('releases.size', '>', (int) $this->_minSize * 1048576); |
| 469 | 469 | } |
| 470 | - if (! empty($groupID)) { |
|
| 470 | + if (!empty($groupID)) { |
|
| 471 | 471 | $releasesQuery->where('releases.groups_id', $groupID); |
| 472 | 472 | } |
| 473 | - if (! empty($guidChar)) { |
|
| 473 | + if (!empty($guidChar)) { |
|
| 474 | 474 | $releasesQuery->where('releases.leftguid', $guidChar); |
| 475 | 475 | } |
| 476 | 476 | $releasesQuery->select(['releases.id', 'releases.id as releases_id', 'releases.guid', 'releases.name', 'releases.size', 'releases.groups_id', 'releases.nfostatus', 'releases.fromname', 'releases.completion', 'releases.categories_id', 'releases.searchname', 'releases.predb_id', 'categories.disablepreview']) |
@@ -524,12 +524,12 @@ discard block |
||
| 524 | 524 | cli_set_process_title($this->_showCLIReleaseID.$this->_release->id); |
| 525 | 525 | |
| 526 | 526 | // Create folder to store temporary files. |
| 527 | - if (! $this->_createTempFolder()) { |
|
| 527 | + if (!$this->_createTempFolder()) { |
|
| 528 | 528 | continue; |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | // Get NZB contents. |
| 532 | - if (! $this->_getNZBContents()) { |
|
| 532 | + if (!$this->_getNZBContents()) { |
|
| 533 | 533 | continue; |
| 534 | 534 | } |
| 535 | 535 | |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | $this->_processMessageIDDownloads(); |
| 552 | 552 | |
| 553 | 553 | // Process compressed (RAR/ZIP) files inside the NZB. |
| 554 | - if (! $bookFlood && $this->_NZBHasCompressedFile) { |
|
| 554 | + if (!$bookFlood && $this->_NZBHasCompressedFile) { |
|
| 555 | 555 | // Download the RARs/ZIPs, extract the files inside them and insert the file info into the DB. |
| 556 | 556 | $this->_processNZBCompressedFiles(); |
| 557 | 557 | |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | $this->_processNZBCompressedFiles(true); |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - if (! $this->_releaseHasPassword) { |
|
| 563 | + if (!$this->_releaseHasPassword) { |
|
| 564 | 564 | // Process the extracted files to get video/audio samples/etc. |
| 565 | 565 | $this->_processExtractedFiles(); |
| 566 | 566 | } |
@@ -604,10 +604,10 @@ discard block |
||
| 604 | 604 | { |
| 605 | 605 | // Per release defaults. |
| 606 | 606 | $this->tmpPath = $this->_mainTmpPath.$this->_release->guid.'/'; |
| 607 | - if (! File::isDirectory($this->tmpPath)) { |
|
| 608 | - if (! File::makeDirectory($this->tmpPath, 0777, true, false) && ! File::isDirectory($this->tmpPath)) { |
|
| 607 | + if (!File::isDirectory($this->tmpPath)) { |
|
| 608 | + if (!File::makeDirectory($this->tmpPath, 0777, true, false) && !File::isDirectory($this->tmpPath)) { |
|
| 609 | 609 | // We will try to create the main temp folder again, just in case there was a file lock or filesystem issue. |
| 610 | - if (! File::makeDirectory($this->tmpPath, 0777, true, false) && ! File::isDirectory($this->tmpPath)) { |
|
| 610 | + if (!File::makeDirectory($this->tmpPath, 0777, true, false) && !File::isDirectory($this->tmpPath)) { |
|
| 611 | 611 | $this->_echo('Unable to create directory: '.$this->tmpPath, 'warning'); |
| 612 | 612 | |
| 613 | 613 | return false; |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | $nzbPath = $this->_nzb->NZBPath($this->_release->guid); |
| 630 | 630 | if ($nzbPath !== false) { |
| 631 | 631 | $nzbContents = Utility::unzipGzipFile($nzbPath); |
| 632 | - if (! $nzbContents) { |
|
| 632 | + if (!$nzbContents) { |
|
| 633 | 633 | if ($this->_echoCLI) { |
| 634 | 634 | $this->_echo('NZB is empty or broken for GUID: '.$this->_release->guid, 'warning'); |
| 635 | 635 | } |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | // Check if it's a rar/zip. |
| 693 | - if (! $this->_NZBHasCompressedFile && |
|
| 693 | + if (!$this->_NZBHasCompressedFile && |
|
| 694 | 694 | preg_match( |
| 695 | 695 | '/\.(part\d+|[r|z]\d+|rar|0+|0*10?|zipr\d{2,3}|zipx?)(\s*\.rar)*($|[ ")\]-])|"[a-f0-9]{32}\.[1-9]\d{1,2}".*\(\d+\/\d{2,}\)$/i', |
| 696 | 696 | $this->_currentNZBFile['title'] |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | // Look for a video sample, make sure it's not an image. |
| 703 | - if ($this->_processThumbnails && empty($this->_sampleMessageIDs) && isset($this->_currentNZBFile['segments']) && stripos($this->_currentNZBFile['title'], 'sample') !== false && ! preg_match('/\.jpe?g$/i', $this->_currentNZBFile['title']) |
|
| 703 | + if ($this->_processThumbnails && empty($this->_sampleMessageIDs) && isset($this->_currentNZBFile['segments']) && stripos($this->_currentNZBFile['title'], 'sample') !== false && !preg_match('/\.jpe?g$/i', $this->_currentNZBFile['title']) |
|
| 704 | 704 | ) { |
| 705 | 705 | // Get the amount of segments for this file. |
| 706 | 706 | $segCount = (\count($this->_currentNZBFile['segments']) - 1); |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | // Look for a JPG picture, make sure it's not a CD cover. |
| 717 | - if ($this->_processJPGSample && empty($this->_JPGMessageIDs) && isset($this->_currentNZBFile['segments']) && ! preg_match('/flac|lossless|mp3|music|inner-sanctum|sound/i', $this->_releaseGroupName) && preg_match('/\.jpe?g[. ")\]]/i', $this->_currentNZBFile['title']) |
|
| 717 | + if ($this->_processJPGSample && empty($this->_JPGMessageIDs) && isset($this->_currentNZBFile['segments']) && !preg_match('/flac|lossless|mp3|music|inner-sanctum|sound/i', $this->_releaseGroupName) && preg_match('/\.jpe?g[. ")\]]/i', $this->_currentNZBFile['title']) |
|
| 718 | 718 | ) { |
| 719 | 719 | // Get the amount of segments for this file. |
| 720 | 720 | $segCount = (\count($this->_currentNZBFile['segments']) - 1); |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | $this->_reverse = $reverse; |
| 767 | 767 | |
| 768 | 768 | if ($this->_reverse) { |
| 769 | - if (! krsort($this->_nzbContents)) { |
|
| 769 | + if (!krsort($this->_nzbContents)) { |
|
| 770 | 770 | return; |
| 771 | 771 | } |
| 772 | 772 | } else { |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | // Probably not a rar/zip. |
| 793 | - if (! preg_match( |
|
| 793 | + if (!preg_match( |
|
| 794 | 794 | '/\.(part\d+|[r|z]\d+|rar|0+|0*10?|zipr\d{2,3}|zipx?)(\s*\.rar)*($|[ ")\]-])|"[a-f0-9]{32}\.[1-9]\d{1,2}".*\(\d+\/\d{2,}\)$/i', |
| 795 | 795 | $nzbFile['title'] |
| 796 | 796 | ) |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | break; |
| 807 | 807 | } |
| 808 | 808 | $segment = (string) $nzbFile['segments'][$i]; |
| 809 | - if (! $this->_reverse) { |
|
| 809 | + if (!$this->_reverse) { |
|
| 810 | 810 | $this->_triedCompressedMids[] = $segment; |
| 811 | 811 | } elseif (\in_array($segment, $this->_triedCompressedMids, false)) { |
| 812 | 812 | // We already downloaded this file. |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | { |
| 859 | 859 | $this->_compressedFilesChecked++; |
| 860 | 860 | // Give the data to archive info, so it can check if it's a rar. |
| 861 | - if (! $this->_archiveInfo->setData($compressedData, true)) { |
|
| 861 | + if (!$this->_archiveInfo->setData($compressedData, true)) { |
|
| 862 | 862 | if (config('app.debug') === true) { |
| 863 | 863 | $this->_debug('Data is probably not RAR or ZIP.'); |
| 864 | 864 | } |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | // Check if the compressed file is encrypted. |
| 891 | - if (! empty($this->_archiveInfo->isEncrypted) || (isset($dataSummary['is_encrypted']) && (int) $dataSummary['is_encrypted'] !== 0)) { |
|
| 891 | + if (!empty($this->_archiveInfo->isEncrypted) || (isset($dataSummary['is_encrypted']) && (int) $dataSummary['is_encrypted'] !== 0)) { |
|
| 892 | 892 | if (config('app.debug') === true) { |
| 893 | 893 | $this->_debug('ArchiveInfo: Compressed file has a password.'); |
| 894 | 894 | } |
@@ -900,13 +900,13 @@ discard block |
||
| 900 | 900 | |
| 901 | 901 | if ($this->_reverse) { |
| 902 | 902 | $fileData = $dataSummary['file_list'] ?? []; |
| 903 | - if (! empty($fileData)) { |
|
| 903 | + if (!empty($fileData)) { |
|
| 904 | 904 | $rarFileName = Arr::pluck($fileData, 'name'); |
| 905 | 905 | if (preg_match(NameFixer::PREDB_REGEX, $rarFileName[0], $hit)) { |
| 906 | 906 | $preCheck = Predb::whereTitle($hit[0])->first(); |
| 907 | 907 | $this->_release->preid = $preCheck !== null ? $preCheck->value('id') : 0; |
| 908 | 908 | (new NameFixer())->updateRelease($this->_release, $preCheck->title ?? ucwords($hit[0], '.'), 'RarInfo FileName Match', true, 'Filenames, ', true, true, $this->_release->preid); |
| 909 | - } elseif (! empty($dataSummary['archives']) && ! empty($dataSummary['archives'][$rarFileName[0]]['file_list'])) { |
|
| 909 | + } elseif (!empty($dataSummary['archives']) && !empty($dataSummary['archives'][$rarFileName[0]]['file_list'])) { |
|
| 910 | 910 | $archiveData = $dataSummary['archives'][$rarFileName[0]]['file_list']; |
| 911 | 911 | $archiveFileName = Arr::pluck($archiveData, 'name'); |
| 912 | 912 | if (preg_match(NameFixer::PREDB_REGEX, $archiveFileName[0], $match2)) { |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | $this->_echo('r', 'primaryOver'); |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - if (! $this->_extractUsingRarInfo && $this->_unrarPath !== false) { |
|
| 927 | + if (!$this->_extractUsingRarInfo && $this->_unrarPath !== false) { |
|
| 928 | 928 | $fileName = $this->tmpPath.uniqid('', true).'.rar'; |
| 929 | 929 | File::put($fileName, $compressedData); |
| 930 | 930 | runCmd($this->_killString.$this->_unrarPath.'" e -ai -ep -c- -id -inul -kb -or -p- -r -y "'.$fileName.'" "'.$this->tmpPath.'unrar/"'); |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | $this->_echo('7z', 'primaryOver'); |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - if (! $this->_extractUsingRarInfo && ! empty($this->_7zipPath)) { |
|
| 939 | + if (!$this->_extractUsingRarInfo && !empty($this->_7zipPath)) { |
|
| 940 | 940 | $fileName = $this->tmpPath.uniqid('', true).'.7z'; |
| 941 | 941 | File::put($fileName, $compressedData); |
| 942 | 942 | // Pass the -p flag to the 7zip command to make sure it doesn't get stuck in password prompt |
@@ -949,7 +949,7 @@ discard block |
||
| 949 | 949 | $this->_echo('z', 'primaryOver'); |
| 950 | 950 | } |
| 951 | 951 | |
| 952 | - if (! $this->_extractUsingRarInfo && ! empty($this->_7zipPath)) { |
|
| 952 | + if (!$this->_extractUsingRarInfo && !empty($this->_7zipPath)) { |
|
| 953 | 953 | $fileName = $this->tmpPath.uniqid('', true).'.zip'; |
| 954 | 954 | File::put($fileName, $compressedData); |
| 955 | 955 | // Pass the -p flag to the 7zip command to make sure it doesn't get stuck in password prompt |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | { |
| 975 | 975 | // Get a list of files inside the Compressed file. |
| 976 | 976 | $files = $this->_archiveInfo->getArchiveFileList(); |
| 977 | - if (! \is_array($files) || \count($files) === 0) { |
|
| 977 | + if (!\is_array($files) || \count($files) === 0) { |
|
| 978 | 978 | return false; |
| 979 | 979 | } |
| 980 | 980 | |
@@ -1044,8 +1044,8 @@ discard block |
||
| 1044 | 1044 | protected function _addFileInfo(&$file): void |
| 1045 | 1045 | { |
| 1046 | 1046 | // Don't add rar/zip files to the DB. |
| 1047 | - if (! isset($file['error']) && isset($file['source']) && |
|
| 1048 | - ! preg_match($this->_supportFileRegex.'|part\d+|[r|z]\d{1,3}|zipr\d{2,3}|\d{2,3}|zipx|zip|rar)(\s*\.rar)?$/i', $file['name']) |
|
| 1047 | + if (!isset($file['error']) && isset($file['source']) && |
|
| 1048 | + !preg_match($this->_supportFileRegex.'|part\d+|[r|z]\d{1,3}|zipr\d{2,3}|\d{2,3}|zipx|zip|rar)(\s*\.rar)?$/i', $file['name']) |
|
| 1049 | 1049 | ) { |
| 1050 | 1050 | // Cache the amount of files we find in the RAR or ZIP, return this to say we did find RAR or ZIP content. |
| 1051 | 1051 | // This is so we don't download more RAR or ZIP files for no reason. |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | */ |
| 1057 | 1057 | if ($this->_addedFileInfo < 11 && ReleaseFile::query()->where(['releases_id' => $this->_release->id, 'name' => $file['name'], 'size' => $file['size']])->first() === null) { |
| 1058 | 1058 | $addReleaseFiles = ReleaseFile::addReleaseFiles($this->_release->id, $file['name'], $file['size'], $file['date'], $file['pass'], '', $file['crc32'] ?? ''); |
| 1059 | - if (! empty($addReleaseFiles)) { |
|
| 1059 | + if (!empty($addReleaseFiles)) { |
|
| 1060 | 1060 | $this->_addedFileInfo++; |
| 1061 | 1061 | |
| 1062 | 1062 | if ($this->_echoCLI) { |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | $this->_releaseHasPassword = true; |
| 1072 | 1072 | $this->_passwordStatus = Releases::PASSWD_RAR; |
| 1073 | 1073 | } //Run a PreDB filename check on insert to try and match the release |
| 1074 | - elseif ($file['name'] !== '' && ! str_starts_with($file['name'], '.')) { |
|
| 1074 | + elseif ($file['name'] !== '' && !str_starts_with($file['name'], '.')) { |
|
| 1075 | 1075 | $this->_release['filename'] = $file['name']; |
| 1076 | 1076 | $this->_release['releases_id'] = $this->_release->id; |
| 1077 | 1077 | $this->_nameFixer->matchPreDbFiles($this->_release, 1, 1, true); |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | 1119 | // If we found no compressed files, break out. |
| 1120 | - if (! $foundCompressedFile) { |
|
| 1120 | + if (!$foundCompressedFile) { |
|
| 1121 | 1121 | break; |
| 1122 | 1122 | } |
| 1123 | 1123 | |
@@ -1139,39 +1139,39 @@ discard block |
||
| 1139 | 1139 | |
| 1140 | 1140 | if (File::isFile($file)) { |
| 1141 | 1141 | // Process PAR2 files. |
| 1142 | - if (! $this->_foundPAR2Info && preg_match('/\.par2$/', $file)) { |
|
| 1142 | + if (!$this->_foundPAR2Info && preg_match('/\.par2$/', $file)) { |
|
| 1143 | 1143 | $this->_siftPAR2Info($file); |
| 1144 | 1144 | } // Process NFO files. |
| 1145 | 1145 | elseif ($this->_releaseHasNoNFO && preg_match('/(\.(nfo|inf|ofn)|info\.txt)$/i', $file)) { |
| 1146 | 1146 | $this->_processNfoFile($file); |
| 1147 | 1147 | } // Process audio files. |
| 1148 | - elseif ((! $this->_foundAudioInfo || ! $this->_foundAudioSample) && preg_match('/(.*)'.$this->_audioFileRegex.'$/i', $file, $fileType)) { |
|
| 1148 | + elseif ((!$this->_foundAudioInfo || !$this->_foundAudioSample) && preg_match('/(.*)'.$this->_audioFileRegex.'$/i', $file, $fileType)) { |
|
| 1149 | 1149 | // Try to get audio sample/audio media info. |
| 1150 | 1150 | File::move($file, $this->tmpPath.'audiofile.'.$fileType[2]); |
| 1151 | 1151 | $this->_getAudioInfo($this->tmpPath.'audiofile.'.$fileType[2], $fileType[2]); |
| 1152 | 1152 | File::delete($this->tmpPath.'audiofile.'.$fileType[2]); |
| 1153 | 1153 | } // Process JPG files. |
| 1154 | - elseif (! $this->_foundJPGSample && preg_match('/\.jpe?g$/i', $file)) { |
|
| 1154 | + elseif (!$this->_foundJPGSample && preg_match('/\.jpe?g$/i', $file)) { |
|
| 1155 | 1155 | $this->_getJPGSample($file); |
| 1156 | 1156 | File::delete($file); |
| 1157 | 1157 | } // Video sample // video clip // video media info. |
| 1158 | - elseif ((! $this->_foundSample || ! $this->_foundVideo || ! $this->_foundMediaInfo) && preg_match('/(.*)'.$this->_videoFileRegex.'$/i', $file)) { |
|
| 1158 | + elseif ((!$this->_foundSample || !$this->_foundVideo || !$this->_foundMediaInfo) && preg_match('/(.*)'.$this->_videoFileRegex.'$/i', $file)) { |
|
| 1159 | 1159 | $this->_processVideoFile($file); |
| 1160 | 1160 | } // Check file's magic info. |
| 1161 | 1161 | else { |
| 1162 | 1162 | $output = Utility::fileInfo($file); |
| 1163 | - if (! empty($output)) { |
|
| 1163 | + if (!empty($output)) { |
|
| 1164 | 1164 | switch (true) { |
| 1165 | - case ! $this->_foundJPGSample && preg_match('/^JPE?G/i', $output): |
|
| 1165 | + case !$this->_foundJPGSample && preg_match('/^JPE?G/i', $output): |
|
| 1166 | 1166 | $this->_getJPGSample($file); |
| 1167 | 1167 | File::delete($file); |
| 1168 | 1168 | break; |
| 1169 | 1169 | |
| 1170 | - case (! $this->_foundMediaInfo || ! $this->_foundSample || ! $this->_foundVideo) && preg_match('/Matroska data|MPEG v4|MPEG sequence, v2|\WAVI\W/i', $output): |
|
| 1170 | + case (!$this->_foundMediaInfo || !$this->_foundSample || !$this->_foundVideo) && preg_match('/Matroska data|MPEG v4|MPEG sequence, v2|\WAVI\W/i', $output): |
|
| 1171 | 1171 | $this->_processVideoFile($file); |
| 1172 | 1172 | break; |
| 1173 | 1173 | |
| 1174 | - case (! $this->_foundAudioSample || ! $this->_foundAudioInfo) && preg_match('/^FLAC|layer III|Vorbis audio/i', $output, $fileType): |
|
| 1174 | + case (!$this->_foundAudioSample || !$this->_foundAudioInfo) && preg_match('/^FLAC|layer III|Vorbis audio/i', $output, $fileType): |
|
| 1175 | 1175 | switch ($fileType[0]) { |
| 1176 | 1176 | case 'FLAC': |
| 1177 | 1177 | $fileType = 'FLAC'; |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | File::delete($this->tmpPath.'audiofile.'.$fileType); |
| 1189 | 1189 | break; |
| 1190 | 1190 | |
| 1191 | - case ! $this->_foundPAR2Info && stripos($output, 'Parity') === 0: |
|
| 1191 | + case !$this->_foundPAR2Info && stripos($output, 'Parity') === 0: |
|
| 1192 | 1192 | $this->_siftPAR2Info($file); |
| 1193 | 1193 | break; |
| 1194 | 1194 | } |
@@ -1224,8 +1224,8 @@ discard block |
||
| 1224 | 1224 | protected function _processSampleMessageIDs(): void |
| 1225 | 1225 | { |
| 1226 | 1226 | // Download and process sample image. |
| 1227 | - if (! $this->_foundSample || ! $this->_foundVideo) { |
|
| 1228 | - if (! empty($this->_sampleMessageIDs)) { |
|
| 1227 | + if (!$this->_foundSample || !$this->_foundVideo) { |
|
| 1228 | + if (!empty($this->_sampleMessageIDs)) { |
|
| 1229 | 1229 | // Download it from usenet. |
| 1230 | 1230 | $sampleBinary = $this->_nntp->getMessages($this->_releaseGroupName, $this->_sampleMessageIDs, $this->_alternateNNTP); |
| 1231 | 1231 | if ($this->_nntp::isError($sampleBinary)) { |
@@ -1244,12 +1244,12 @@ discard block |
||
| 1244 | 1244 | File::put($fileLocation, $sampleBinary); |
| 1245 | 1245 | |
| 1246 | 1246 | // Try to get a sample picture. |
| 1247 | - if (! $this->_foundSample) { |
|
| 1247 | + if (!$this->_foundSample) { |
|
| 1248 | 1248 | $this->_foundSample = $this->_getSample($fileLocation); |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | 1251 | // Try to get a sample video. |
| 1252 | - if (! $this->_foundVideo) { |
|
| 1252 | + if (!$this->_foundVideo) { |
|
| 1253 | 1253 | $this->_foundVideo = $this->_getVideo($fileLocation); |
| 1254 | 1254 | } |
| 1255 | 1255 | } |
@@ -1270,8 +1270,8 @@ discard block |
||
| 1270 | 1270 | protected function _processMediaInfoMessageIDs(): void |
| 1271 | 1271 | { |
| 1272 | 1272 | // Download and process mediainfo. Also try to get a sample if we didn't get one yet. |
| 1273 | - if (! $this->_foundMediaInfo || ! $this->_foundSample || ! $this->_foundVideo) { |
|
| 1274 | - if (! empty($this->_MediaInfoMessageIDs)) { |
|
| 1273 | + if (!$this->_foundMediaInfo || !$this->_foundSample || !$this->_foundVideo) { |
|
| 1274 | + if (!empty($this->_MediaInfoMessageIDs)) { |
|
| 1275 | 1275 | // Try to download it from usenet. |
| 1276 | 1276 | $mediaBinary = $this->_nntp->getMessages($this->_releaseGroupName, $this->_MediaInfoMessageIDs, $this->_alternateNNTP); |
| 1277 | 1277 | if ($this->_nntp::isError($mediaBinary)) { |
@@ -1291,17 +1291,17 @@ discard block |
||
| 1291 | 1291 | File::put($fileLocation, $mediaBinary); |
| 1292 | 1292 | |
| 1293 | 1293 | // Try to get media info. |
| 1294 | - if (! $this->_foundMediaInfo) { |
|
| 1294 | + if (!$this->_foundMediaInfo) { |
|
| 1295 | 1295 | $this->_foundMediaInfo = $this->_getMediaInfo($fileLocation); |
| 1296 | 1296 | } |
| 1297 | 1297 | |
| 1298 | 1298 | // Try to get a sample picture. |
| 1299 | - if (! $this->_foundSample) { |
|
| 1299 | + if (!$this->_foundSample) { |
|
| 1300 | 1300 | $this->_foundSample = $this->_getSample($fileLocation); |
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | // Try to get a sample video. |
| 1304 | - if (! $this->_foundVideo) { |
|
| 1304 | + if (!$this->_foundVideo) { |
|
| 1305 | 1305 | $this->_foundVideo = $this->_getVideo($fileLocation); |
| 1306 | 1306 | } |
| 1307 | 1307 | } |
@@ -1322,8 +1322,8 @@ discard block |
||
| 1322 | 1322 | protected function _processAudioInfoMessageIDs(): void |
| 1323 | 1323 | { |
| 1324 | 1324 | // Download audio file, use media info to try to get the artist / album. |
| 1325 | - if (! $this->_foundAudioInfo || ! $this->_foundAudioSample) { |
|
| 1326 | - if (! empty($this->_AudioInfoMessageIDs)) { |
|
| 1325 | + if (!$this->_foundAudioInfo || !$this->_foundAudioSample) { |
|
| 1326 | + if (!empty($this->_AudioInfoMessageIDs)) { |
|
| 1327 | 1327 | // Try to download it from usenet. |
| 1328 | 1328 | $audioBinary = $this->_nntp->getMessages($this->_releaseGroupName, $this->_AudioInfoMessageIDs, $this->_alternateNNTP); |
| 1329 | 1329 | if ($this->_nntp::isError($audioBinary)) { |
@@ -1358,7 +1358,7 @@ discard block |
||
| 1358 | 1358 | protected function _processJPGMessageIDs(): void |
| 1359 | 1359 | { |
| 1360 | 1360 | // Download JPG file. |
| 1361 | - if (! $this->_foundJPGSample && ! empty($this->_JPGMessageIDs)) { |
|
| 1361 | + if (!$this->_foundJPGSample && !empty($this->_JPGMessageIDs)) { |
|
| 1362 | 1362 | // Try to download it. |
| 1363 | 1363 | $jpgBinary = $this->_nntp->getMessages($this->_releaseGroupName, $this->_JPGMessageIDs, $this->_alternateNNTP); |
| 1364 | 1364 | if ($this->_nntp::isError($jpgBinary)) { |
@@ -1427,12 +1427,12 @@ discard block |
||
| 1427 | 1427 | $this->_passwordStatus = max([$this->_passwordStatus]); |
| 1428 | 1428 | |
| 1429 | 1429 | // Set the release to no password if password processing is off. |
| 1430 | - if (! $this->_processPasswords) { |
|
| 1430 | + if (!$this->_processPasswords) { |
|
| 1431 | 1431 | $this->_releaseHasPassword = false; |
| 1432 | 1432 | } |
| 1433 | 1433 | |
| 1434 | 1434 | // If we failed to get anything from the RAR/ZIPs update the release with what we have, if the rar/zip has no password. |
| 1435 | - if (! $this->_releaseHasPassword && $this->_NZBHasCompressedFile && $releaseFilesCount === 0) { |
|
| 1435 | + if (!$this->_releaseHasPassword && $this->_NZBHasCompressedFile && $releaseFilesCount === 0) { |
|
| 1436 | 1436 | $release = Release::query()->where('id', $this->_release->id); |
| 1437 | 1437 | $release->update( |
| 1438 | 1438 | $updateRows |
@@ -1489,19 +1489,19 @@ discard block |
||
| 1489 | 1489 | $retVal = $audVal = false; |
| 1490 | 1490 | |
| 1491 | 1491 | // Check if audio sample fetching is on. |
| 1492 | - if (! $this->_processAudioSample) { |
|
| 1492 | + if (!$this->_processAudioSample) { |
|
| 1493 | 1493 | $audVal = true; |
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | 1496 | // Check if media info fetching is on. |
| 1497 | - if (! $this->_processAudioInfo) { |
|
| 1497 | + if (!$this->_processAudioInfo) { |
|
| 1498 | 1498 | $retVal = true; |
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | 1501 | $rQuery = Release::query()->where('proc_pp', '=', 0)->where('id', $this->_release->id)->select(['searchname', 'fromname', 'categories_id'])->first(); |
| 1502 | 1502 | |
| 1503 | 1503 | $musicParent = (string) Category::MUSIC_ROOT; |
| 1504 | - if ($rQuery === null || ! preg_match( |
|
| 1504 | + if ($rQuery === null || !preg_match( |
|
| 1505 | 1505 | sprintf( |
| 1506 | 1506 | '/%d\d{3}|%d|%d|%d/', |
| 1507 | 1507 | $musicParent[0], |
@@ -1517,7 +1517,7 @@ discard block |
||
| 1517 | 1517 | |
| 1518 | 1518 | if (File::isFile($fileLocation)) { |
| 1519 | 1519 | // Check if media info is enabled. |
| 1520 | - if (! $retVal) { |
|
| 1520 | + if (!$retVal) { |
|
| 1521 | 1521 | // Get the media info for the file. |
| 1522 | 1522 | try { |
| 1523 | 1523 | $xmlArray = $this->mediaInfo->getInfo($fileLocation, false); |
@@ -1530,7 +1530,7 @@ discard block |
||
| 1530 | 1530 | $ext = strtoupper($fileExtension); |
| 1531 | 1531 | |
| 1532 | 1532 | // Form a new search name. |
| 1533 | - if (! empty($track->get('recorded_date')) && preg_match('/(?:19|20)\d\d/', $track->get('recorded_date')->getFullname(), $Year)) { |
|
| 1533 | + if (!empty($track->get('recorded_date')) && preg_match('/(?:19|20)\d\d/', $track->get('recorded_date')->getFullname(), $Year)) { |
|
| 1534 | 1534 | $newName = $track->get('performer')->getFullName().' - '.$track->get('album')->getFullName().' ('.$Year[0].') '.$ext; |
| 1535 | 1535 | } else { |
| 1536 | 1536 | $newName = $track->get('performer')->getFullName().' - '.$track->get('album')->getFullName().' '.$ext; |
@@ -1592,7 +1592,7 @@ discard block |
||
| 1592 | 1592 | } |
| 1593 | 1593 | |
| 1594 | 1594 | // Check if creating audio samples is enabled. |
| 1595 | - if (! $audVal) { |
|
| 1595 | + if (!$audVal) { |
|
| 1596 | 1596 | // File name to store audio file. |
| 1597 | 1597 | $audioFileName = ($this->_release->guid.'.ogg'); |
| 1598 | 1598 | |
@@ -1616,7 +1616,7 @@ discard block |
||
| 1616 | 1616 | // Try to move the temp audio file. |
| 1617 | 1617 | $renamed = File::move($this->tmpPath.$audioFileName, $this->_audioSavePath.$audioFileName); |
| 1618 | 1618 | |
| 1619 | - if (! $renamed) { |
|
| 1619 | + if (!$renamed) { |
|
| 1620 | 1620 | // Try to copy it if it fails. |
| 1621 | 1621 | $copied = File::copy($this->tmpPath.$audioFileName, $this->_audioSavePath.$audioFileName); |
| 1622 | 1622 | |
@@ -1624,7 +1624,7 @@ discard block |
||
| 1624 | 1624 | File::delete($this->tmpPath.$audioFileName); |
| 1625 | 1625 | |
| 1626 | 1626 | // If it didn't copy continue. |
| 1627 | - if (! $copied) { |
|
| 1627 | + if (!$copied) { |
|
| 1628 | 1628 | return false; |
| 1629 | 1629 | } |
| 1630 | 1630 | } |
@@ -1676,7 +1676,7 @@ discard block |
||
| 1676 | 1676 | $time = $this->ffprobe->format($videoLocation)->get('duration'); |
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | - if (empty($time) || ! preg_match('/time=(\d{1,2}:\d{1,2}:)?(\d{1,2})\.(\d{1,2})\s*bitrate=/i', $time, $numbers)) { |
|
| 1679 | + if (empty($time) || !preg_match('/time=(\d{1,2}:\d{1,2}:)?(\d{1,2})\.(\d{1,2})\s*bitrate=/i', $time, $numbers)) { |
|
| 1680 | 1680 | return ''; |
| 1681 | 1681 | } |
| 1682 | 1682 | |
@@ -1697,7 +1697,7 @@ discard block |
||
| 1697 | 1697 | */ |
| 1698 | 1698 | protected function _getSample(string $fileLocation): bool |
| 1699 | 1699 | { |
| 1700 | - if (! $this->_processThumbnails) { |
|
| 1700 | + if (!$this->_processThumbnails) { |
|
| 1701 | 1701 | return false; |
| 1702 | 1702 | } |
| 1703 | 1703 | |
@@ -1762,7 +1762,7 @@ discard block |
||
| 1762 | 1762 | */ |
| 1763 | 1763 | protected function _getVideo(string $fileLocation): bool |
| 1764 | 1764 | { |
| 1765 | - if (! $this->_processVideo) { |
|
| 1765 | + if (!$this->_processVideo) { |
|
| 1766 | 1766 | return false; |
| 1767 | 1767 | } |
| 1768 | 1768 | |
@@ -1817,7 +1817,7 @@ discard block |
||
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | 1819 | // If longer than 60 or we could not get the video length, run the old way. |
| 1820 | - if (! $newMethod && $this->ffprobe->isValid($fileLocation)) { |
|
| 1820 | + if (!$newMethod && $this->ffprobe->isValid($fileLocation)) { |
|
| 1821 | 1821 | try { |
| 1822 | 1822 | $video = $this->ffmpeg->open($fileLocation); |
| 1823 | 1823 | $videoSample = $video->clip(TimeCode::fromSeconds(0), TimeCode::fromSeconds($this->_ffMPEGDuration)); |
@@ -1840,14 +1840,14 @@ discard block |
||
| 1840 | 1840 | |
| 1841 | 1841 | // Try to move the file to the new path. |
| 1842 | 1842 | // If we couldn't rename it, try to copy it. |
| 1843 | - if (! @File::move($fileName, $newFile)) { |
|
| 1843 | + if (!@File::move($fileName, $newFile)) { |
|
| 1844 | 1844 | $copied = @File::copy($fileName, $newFile); |
| 1845 | 1845 | |
| 1846 | 1846 | // Delete the old file. |
| 1847 | 1847 | File::delete($fileName); |
| 1848 | 1848 | |
| 1849 | 1849 | // If it didn't copy, continue. |
| 1850 | - if (! $copied) { |
|
| 1850 | + if (!$copied) { |
|
| 1851 | 1851 | return false; |
| 1852 | 1852 | } |
| 1853 | 1853 | } |
@@ -1873,7 +1873,7 @@ discard block |
||
| 1873 | 1873 | */ |
| 1874 | 1874 | protected function _getMediaInfo($fileLocation): bool |
| 1875 | 1875 | { |
| 1876 | - if (! $this->_processMediaInfo) { |
|
| 1876 | + if (!$this->_processMediaInfo) { |
|
| 1877 | 1877 | return false; |
| 1878 | 1878 | } |
| 1879 | 1879 | |
@@ -1948,7 +1948,7 @@ discard block |
||
| 1948 | 1948 | $filesAdded = 0; |
| 1949 | 1949 | |
| 1950 | 1950 | foreach ($this->_par2Info->getFileList() as $file) { |
| 1951 | - if (! isset($file['name'])) { |
|
| 1951 | + if (!isset($file['name'])) { |
|
| 1952 | 1952 | continue; |
| 1953 | 1953 | } |
| 1954 | 1954 | |
@@ -1971,7 +1971,7 @@ discard block |
||
| 1971 | 1971 | } |
| 1972 | 1972 | |
| 1973 | 1973 | // Try to get a new name. |
| 1974 | - if (! $foundName) { |
|
| 1974 | + if (!$foundName) { |
|
| 1975 | 1975 | $this->_release->textstring = $file['name']; |
| 1976 | 1976 | $this->_release->releases_id = $this->_release->id; |
| 1977 | 1977 | if ($this->_nameFixer->checkName($this->_release, $this->_echoCLI, 'PAR2, ', 1, 1)) { |
@@ -2001,7 +2001,7 @@ discard block |
||
| 2001 | 2001 | protected function _processVideoFile($fileLocation): void |
| 2002 | 2002 | { |
| 2003 | 2003 | // Try to get a sample with it. |
| 2004 | - if (! $this->_foundSample) { |
|
| 2004 | + if (!$this->_foundSample) { |
|
| 2005 | 2005 | $this->_foundSample = $this->_getSample($fileLocation); |
| 2006 | 2006 | } |
| 2007 | 2007 | |
@@ -2009,12 +2009,12 @@ discard block |
||
| 2009 | 2009 | * Don't get it here if _sampleMessageIDs is empty |
| 2010 | 2010 | * or has 1 message-id (Saves downloading another part). |
| 2011 | 2011 | */ |
| 2012 | - if (! $this->_foundVideo && \count($this->_sampleMessageIDs) < 2) { |
|
| 2012 | + if (!$this->_foundVideo && \count($this->_sampleMessageIDs) < 2) { |
|
| 2013 | 2013 | $this->_foundVideo = $this->_getVideo($fileLocation); |
| 2014 | 2014 | } |
| 2015 | 2015 | |
| 2016 | 2016 | // Try to get media info with it. |
| 2017 | - if (! $this->_foundMediaInfo) { |
|
| 2017 | + if (!$this->_foundMediaInfo) { |
|
| 2018 | 2018 | $this->_foundMediaInfo = $this->_getMediaInfo($fileLocation); |
| 2019 | 2019 | } |
| 2020 | 2020 | } |
@@ -2036,24 +2036,24 @@ discard block |
||
| 2036 | 2036 | $bf = true; |
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | - if (! $af && preg_match('/\.rar($|[ ")\]-])/i', $a)) { |
|
| 2039 | + if (!$af && preg_match('/\.rar($|[ ")\]-])/i', $a)) { |
|
| 2040 | 2040 | $a = preg_replace('/\.rar(?:$|[ ")\]-])/i', '.*rar', $a); |
| 2041 | 2041 | $af = true; |
| 2042 | 2042 | } |
| 2043 | - if (! $bf && preg_match('/\.rar($|[ ")\]-])/i', $b)) { |
|
| 2043 | + if (!$bf && preg_match('/\.rar($|[ ")\]-])/i', $b)) { |
|
| 2044 | 2044 | $b = preg_replace('/\.rar(?:$|[ ")\]-])/i', '.*rar', $b); |
| 2045 | 2045 | $bf = true; |
| 2046 | 2046 | } |
| 2047 | 2047 | |
| 2048 | - if (! $af && ! $bf) { |
|
| 2048 | + if (!$af && !$bf) { |
|
| 2049 | 2049 | return strnatcasecmp($a, $b); |
| 2050 | 2050 | } |
| 2051 | 2051 | |
| 2052 | - if (! $bf) { |
|
| 2052 | + if (!$bf) { |
|
| 2053 | 2053 | return -1; |
| 2054 | 2054 | } |
| 2055 | 2055 | |
| 2056 | - if (! $af) { |
|
| 2056 | + if (!$af) { |
|
| 2057 | 2057 | return 1; |
| 2058 | 2058 | } |
| 2059 | 2059 | |
@@ -2078,12 +2078,12 @@ discard block |
||
| 2078 | 2078 | protected function _resetReleaseStatus(): void |
| 2079 | 2079 | { |
| 2080 | 2080 | // Only process for samples, previews and images if not disabled. |
| 2081 | - $this->_foundVideo = ! $this->_processVideo; |
|
| 2082 | - $this->_foundMediaInfo = ! $this->_processMediaInfo; |
|
| 2083 | - $this->_foundAudioInfo = ! $this->_processAudioInfo; |
|
| 2084 | - $this->_foundAudioSample = ! $this->_processAudioSample; |
|
| 2085 | - $this->_foundJPGSample = ! $this->_processJPGSample; |
|
| 2086 | - $this->_foundSample = ! $this->_processThumbnails; |
|
| 2081 | + $this->_foundVideo = !$this->_processVideo; |
|
| 2082 | + $this->_foundMediaInfo = !$this->_processMediaInfo; |
|
| 2083 | + $this->_foundAudioInfo = !$this->_processAudioInfo; |
|
| 2084 | + $this->_foundAudioSample = !$this->_processAudioSample; |
|
| 2085 | + $this->_foundJPGSample = !$this->_processJPGSample; |
|
| 2086 | + $this->_foundSample = !$this->_processThumbnails; |
|
| 2087 | 2087 | $this->_foundPAR2Info = false; |
| 2088 | 2088 | |
| 2089 | 2089 | $this->_passwordStatus = Releases::PASSWD_NONE; |