public function testFileParsing()
 {
     $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
     $xml .= '<packages package_ETA="~" package_linksinprogress="0" package_linkstotal="2" package_loaded="0 B" package_name="2.Broke.Girls.S01E09.de.en.XViD-4SJ" package_percent="0,00" package_size="0 B" package_speed="0 B" package_todo="0 B">';
     $xml .= '<file file_downloaded="0 B" file_hoster="uploaded.to" file_name="d6cno5nf" file_package="2.Broke.Girls.S01E09.de.en.XViD-4SJ" file_percent="0,00" file_size="0 B" file_speed="0" file_status="File not found"/>';
     $xml .= '<file file_downloaded="0 B" file_hoster="uploaded.to" file_name="kla6pdp2" file_package="2.Broke.Girls.S01E09.de.en.XViD-4SJ" file_percent="0,00" file_size="0 B" file_speed="0" file_status="File not found"/>';
     $xml .= '</packages>';
     $res = xml::query(xml::doc($xml), 'packages');
     $package = JDownloaderPackage::parse(current($res));
     $this->assertChainable($package);
     $this->assertCount(2, $files = $package->getFiles());
     $this->assertContainsOnlyInstancesOf('SerienLoader\\JDownloaderFile', $files);
     list($file1, $file2) = $files;
     $this->assertEquals('d6cno5nf', $file1->getName());
     $this->assertTrue($file1->isNotFound());
     $this->assertEquals('kla6pdp2', $file2->getName());
     $this->assertTrue($file2->isNotFound());
     $this->assertTrue($package->hasMissingFiles());
 }
 protected function waitForChecked(array $links)
 {
     $timeout = 20;
     $x = 5;
     sleep(5);
     do {
         $xmls = $this->send('/get/grabber/list');
         $doc = xml::doc($xmls);
         /*
           wir überprüfen hier nur ob das "unchecked" paket hier verschwindet, denn wir können nicht herausfinden
           wie der link in der XML Liste lautet, den wir hinzugefügt haben - denn dieser wird umgemodelt von JDownloader
         */
         $cnt = count(xml::query($doc, 'jdownloader packages[package_name="Unchecked"]'));
         if ($x >= $timeout) {
             throw new JDownloaderException('Timeout von ' . $timeout . ' Sekunden für link-checking hit.');
         }
         $x++;
         sleep(1);
     } while ($cnt > 0);
 }
Пример #3
0
 public function getBoardIds()
 {
     $this->logger->writeln('Lade BoardIds');
     $cache = new \Psc\Data\FileCache();
     $ser = $cache->load('boardIds', $loaded);
     if (!$loaded) {
         $this->logger->writeln('BoardIds nicht im Cache, mache URL Request');
         $this->req = new URLRequest('http://www.subcentral.de/index.php?s=' . $this->sessionId, $this->cookieJar);
         $html = $this->req->init()->process();
         $boardIds = array();
         $dom = xml::doc($html);
         foreach (xml::query($dom, '#search select[name=boardID] option') as $option) {
             $title = $option->nodeValue;
             $boardIds[mb_strtolower($title)] = (int) $option->getAttribute('value');
         }
         $this->logger->writeln(count($boardIds) . ' BoardIds gefunden. Speichere im Cache');
         $ser = serialize($boardIds);
         $cache->store('boardIds', $ser);
     } else {
         $boardIds = unserialize($ser);
         $this->logger->writeln(count($boardIds) . ' BoardIds im Cache gefunden');
     }
     return $boardIds;
 }
Пример #4
0
 public function testUTF8DocumentSnipped()
 {
     $dom = Helper::docPart('<span>Game Templates für Testprodukt</span>');
     $q = Helper::query($dom, 'span');
     $this->assertEquals('Game Templates für Testprodukt', $q[0]->nodeValue);
 }