Ejemplo n.º 1
0
 /**
  * @return list($threadLink, $threadId);
  */
 public function findThread($boardId, Season $season)
 {
     $this->logger->writeln('Suche Thread für ' . $season . ' in board: ' . $boardId);
     $this->req = new URLRequest('http://www.subcentral.de/index.php?page=Board&boardID=' . $boardId, $this->cookieJar);
     $html = $this->req->init()->process();
     /* wir holen uns den richtigen Thread aus den "wichtigen Themen" */
     $dom = xml::doc($html);
     $res = xml::query($dom, '#stickiesStatus table td.columnTopic div.topic p');
     $stickies = array();
     // das sind nicht alle wegen break!
     foreach ($res as $topicP) {
         $topicP = xml::doc($topicP);
         $topicA = A::first(xml::query($topicP, 'a'));
         $title = (string) $topicA->nodeValue;
         $stickies[] = $title;
         $prefix = xml::query($topicP, 'span.prefix strong');
         if (count($prefix) == 1 && $prefix[0]->nodeValue == '[Subs]' && Preg::match($title, '/(Staffel\\s*' . $season->getNum() . '|S0*' . $season->getNum() . ')/i') > 0) {
             $link = $topicA->getAttribute('href');
             $threadId = (int) Preg::qmatch($link, '/threadId=([0-9]+)/');
             break;
         }
     }
     if (!isset($link)) {
         $pe = new SubcentralException('Pfad nicht gefunden: "#stickiesStatus table td.columnTopic div.topic p a" in ' . $this->req->getURL() . ' ' . Code::varInfo($stickies));
         $e = new SubcentralException('Thread für Staffel: ' . $season->getNum() . ' für Serie: ' . $season->getTvShow()->getTitle() . ' nicht gefunden', 0, $pe);
         $this->logger->writeln($e->getMessage());
         $this->logger->writeln($pe->getMessage());
         throw $e;
     }
     $link = 'http://www.subcentral.de/' . $link;
     return array($link, $threadId);
 }
 public function testGrab()
 {
     $sc = new Subcentral();
     // @TODO solve dependency injection für request (mit requestbundle so wie beim serienjunkies grabber)
     $html = $sc->login('technoplayer', 'logf22x3');
     $tvShow = new TvShow();
     $tvShow->setTitle('How I Met Your Mother');
     $boardId = $sc->findBoard($tvShow);
     $season = new Season();
     $season->setNum(7);
     $season->setTvShow($tvShow);
     list($threadLink, $threadId) = $sc->findThread($boardId, $season);
     $subs = $sc->getSubs($threadLink);
     $dir = PSC::get(PSC::PATH_FILES)->append('subs/' . $tvShow->getTitle() . '/' . $season->getNum() . '/');
     $dir->make(Dir::PARENT | Dir::ASSERT_EXISTS);
     $sc->downloadSubs($subs, $dir);
 }
Ejemplo n.º 3
0
 /**
  * @return Episode
  */
 public static function createFromJSON(stdClass $jsonObject)
 {
     $episode = new static();
     $episode->setJSONFields($jsonObject);
     $episode->setSeason(Season::createFromJSON($jsonObject->season));
     foreach ($jsonObject->links as $jsonLink) {
         $episode->getLinks()->add(Link::createFromJSON($jsonLink));
     }
     return $episode;
 }
 /**
  * @param SerienLoader\Entities\Season $season
  */
 public function setSeason(Season $season)
 {
     $this->season = $season;
     $season->addEpisode($this);
     return $this;
 }