public function tryUnpack(File $archiveFile) { try { // wir suchen das srt im archive if ($archiveFile->getExtension() === 'rar') { // vll geht hier sogar zip? $archive = new \Psc\System\SimpleRarArchive($archiveFile); $files = $archive->listFiles(); $srt = NULL; $this->logger->writeln('Files im Archiv: ' . implode("\n", $files)); foreach ($files as $file) { if (\Psc\String::endsWith($file, '.srt')) { $srt = $file; break; } } if ($srt === NULL) { throw new Exception('Keine .srt Datei im Archiv: ' . $archiveFile . ' gefunden'); } $destination = clone $archiveFile; $destination->setExtension('srt'); $archive->extractFile($srt, $destination); if ($destination->exists()) { $archiveFile->delete(); return $destination; // alles supi } } } catch (\Exception $e) { $this->logger->writeln('Fehler beim Versuch zu entpacken: ' . $e->getMessage()); } return $archiveFile; }