public function assignPageContent(\phpQueryObject $_) { $this->setSynopsis(trim($_['p[itemprop=description]']->text())); if ($duration = $_['[itemprop=duration]']->attr('datetime')) { $this->setLength(new \DateInterval($duration)); } $this->setRating((double) $_['[itemprop=ratingValue]']->text()); $this->setTitle(trim($_['h1 [itemprop=name]']->text())); $this->setVotes((int) preg_replace('/[^\\d]+/', '', $_['[itemprop=ratingCount]']->text())); $this->setPosterUri($_['img[itemprop=image]']->attr('src')); $this->setDatePublished(\DateTime::createFromFormat('Y-m-d', $_['.infobar [itemprop="datePublished"]']->attr('content'))); $g = []; foreach ($_['.infobar [itemprop=genre]'] as $genre) { $g[] = pq($genre)->text(); } $this->setGenres($g); foreach ($_['#title-overview-widget [itemtype="http://schema.org/Person"][itemprop!=actors]'] as $x) { $x = pq($x); foreach ($x['a[itemprop=url]'] as $p) { $p = pq($p); $person = new Person(); $person->setId(preg_replace('@^.*(nm\\d+).*@', '$1', $p->attr('href'))); $person->setName($p->text()); if (!isset($this->_people[$x->attr('itemprop')])) { $this->_people[$x->attr('itemprop')] = []; } $this->_people[$x->attr('itemprop')][$person->getId()] = $person; } } // Casting if (!isset($this->_people['actors'])) { $this->_people['actors'] = []; } foreach ($_['table.cast_list tr:has([itemprop=name])'] as $p) { $p = pq($p); $actor = new Actor(); $actor->setId(preg_replace('@^.*(nm\\d+).*@', '$1', $p['[itemprop=url]']->attr('href'))); $actor->setName($p['[itemprop=name]']->text()); $actor->setCharacter($p['a[href^=/character]']->text()); $this->_people['actors'][$actor->getId()] = $actor; } }