/** * @param ReplayInterface $replay * @param string $pathFolder * @param int $fileId * @param bool $saveFile * * @return string */ public function getBinary(ReplayInterface $replay, $pathFolder, $fileId, $saveFile = false) { $path = $pathFolder . '/' . $fileId; if (!is_file($path)) { return false; } $decodedKey = base64_decode($replay->getEncryptionKey()); $decodedKey = $this->decrypt($replay->getGameId(), $decodedKey); $keyframeBinary = file_get_contents($path); $decodedKeyframeBinary = gzdecode($this->decrypt($decodedKey, $keyframeBinary)); // File should saved only in development environment. // If parsing is needed, you have to do it in the ReplayDownloader::onReplayFileDecrypted() method if ($saveFile) { file_put_contents($pathFolder . '.decoded/' . $fileId, $decodedKeyframeBinary); } return $decodedKeyframeBinary; }
/** * @param ReplayInterface $replay * * @return array */ public function downloadMetas(ReplayInterface $replay, OutputInterface $output = null) { $hasOutput = null != $output; if ($hasOutput) { $output->write("Retrieve metas...\t\t\t"); } $gameId = $replay->getGameId(); $metas = $this->client->getMetas($replay->getRegion(), $gameId); // Update replay object $metas = json_decode($metas, true); $metas['encryptionKey'] = $replay->getEncryptionKey(); $replay->setMetas($metas); if ($hasOutput) { $output->writeln('<info>OK</info>'); } return $metas; }