/**
  * Nimmt alle verfügbaren Subtitles der Staffel und speichert sie nach Format gruppiert in Unterverzeichnissen
  * nach der Episodennummer im verzeichnis $root
  */
 public function downloadSubs(array $subs, Dir $root)
 {
     $this->Logger->writeln('downloade Subs');
     foreach ($subs as $episodeNum => $languages) {
         $episodeDir = $root->clone_()->append($episodeNum . '/');
         $episodeDir->make(Dir::ASSERT_EXISTS | Dir::PARENT);
         foreach ($languages as $lang => $formats) {
             foreach ($formats as $format => $attachment) {
                 $srt = new File($episodeDir, $format . '.' . $lang . '.srt');
                 if (!$srt->exists()) {
                     $req = new URLRequest('http://www.subcentral.de/' . $attachment, $this->cookieJar);
                     $archiveContents = $req->init()->process();
                     $res = $req->getResponse();
                     try {
                         $type = $res->getContentType() === 'application/x-rar-compressed' || File::factory($res->getAttachmentFilename())->getExtension() == 'rar' ? 'rar' : 'zip';
                     } catch (\Exception $e) {
                         $type = 'rar';
                     }
                     $destination = new File($episodeDir, $format . '.' . $lang . '.' . $type);
                     $destination->writeContents($archiveContents);
                     $destination = $this->tryUnpack($destination);
                     $this->logger->writeln('Schreibe Datei: ' . $destination);
                 } else {
                     $this->logger->writeln('Sub (srt) existiert schon. Überspringe Download.');
                 }
             }
         }
     }
 }
Example #2
0
    system('cd ' . $command->getProject()->getSrc() . ' &&php ' . \Psc\PSC::getRoot()->getFile('composer.phar') . ' update');
});
$createCommand('test-configuration', array(), function ($input, $output, $command) {
    $cfgTest = new ConfigurationTester();
    $cfgTest->INI('mbstring.internal_encoding', 'UTF-8');
    $cfgTest->INI('post_max_size', '30M', '>=');
    $cfgTest->INI('upload_max_filesize', '30M', '>=');
    $cfgTest->INI('memory_limit', '200M', '>=');
    $cfgTest->INI('suhosin.memory_limit', '200M', '>=');
    $cfgTest->INI('display_errors', TRUE);
    // curl needs to be installed
    // mb_string needs to be installed
    $output->writeln((string) $cfgTest);
});
$createCommand('compile:jqx-widget-specification', array($arg('html-table-file', 'Die Datei in der das HTMl für table.documentation-table ist'), $arg('widgetName', 'Der Name des Widgets ohne jq davor')), function ($input, $output, $command) {
    $argFile = File::factory($input->getArgument('html-table-file'));
    $widgetName = ucfirst($input->getArgument('widgetName'));
    $html = $argFile->getContents();
    $scraper = new \Psc\XML\Scraper();
    $table = $scraper->table($html, 'table.documentation-table')->useHeader(function ($th) {
        return trim(mb_strtolower($th->text()));
    })->tdConverter(function ($td) {
        return trim($td->text());
    })->rowFilter(function ($row, $headerFound) {
        return !$headerFound || $row->find('td.documentation-option-type-click')->length > 0;
    })->scrape();
    $class = new \Psc\Code\Generate\ClassBuilder(new \Psc\Code\Generate\GClass(sprintf('Psc\\UI\\jqx\\%sSpecification', $widgetName)));
    $class->setParentClass(new \Psc\Code\Generate\GClass('Psc\\UI\\jqx\\Widget'));
    $properties = array();
    $undefined = '__spec__undefined';
    foreach ($table->rows as $row) {
Example #3
0
 public function validateFile($path, $flags = self::MUST_EXIST)
 {
     $errorDetail = NULL;
     if (!empty($path)) {
         $file = File::factory($path);
         // workaround file
         if (self::RESOLVE_RELATIVE && !Dir::isAbsolutePath((string) $file->getDirectory()) && !$file->isRelative()) {
             $file->setDirectory(new Dir('.' . DIRECTORY_SEPARATOR . $file->getDirectory()));
         }
         $file->resolvePath();
         if (!($flags & self::MUST_EXIST) || $file->exists()) {
             return $file;
         } else {
             $errorDetail = ' It must exist!';
         }
     }
     throw $this->exitException(sprintf("File from path: '%s' cannot be found.%s", $path, $errorDetail));
 }