diff --git a/Source/Questbook.php b/Source/Questbook.php index 2f883f9..f6b1115 100644 --- a/Source/Questbook.php +++ b/Source/Questbook.php @@ -64,19 +64,31 @@ class Questbook extends Source { public function page($url) { $game = new Game; $game->url = $url; - $game->title = $this->dom->filter('h2 a b')->first()->text(); + $title = $this->dom->filter('h2 a b'); + if ($title->count() > 0) { + $title = $title->first()->text(); + $game->title = $title; + } $game->platform = 'Книга-игра'; - $game->description = $this->dom->filter('div.col-md-8.col-sm-12 > div > div')->reduce(function($node) { + $description = $this->dom->filter('div.col-md-8.col-sm-12 > div > div')->reduce(function($node) { if ($node->attr('style') === 'padding:5px;margin:2px;text-align:justify') return true; return false; - })->text(); + }); + if ($description->count() > 0) { + $description = $description->text(); + $game->description = $description; + } $game->description = trim($game->description); - $game->author = $this->dom->filter('div.col-md-8.col-sm-12 em span')->reduce(function($node) { + $author = $this->dom->filter('div.col-md-8.col-sm-12 em span')->reduce(function($node) { if ($node->attr('itemprop') === 'author') return true; return false; - })->text(); + }); + if ($author->count() > 0) { + $author = $author->text(); + $game->author = $author; + } return $game; } } diff --git a/Wikipage.php b/Wikipage.php index 2d8f6d1..13f7c18 100644 --- a/Wikipage.php +++ b/Wikipage.php @@ -77,6 +77,11 @@ class Wikipage { $pagetitle = strtr($this->game->title, [ '|' => '-' ]); + if (empty($pagetitle)) { + echo 'ERROR: Page has no title.'; + var_dump($this->game); + die(); + } $exists = $this->exists($pagetitle); if (!$config['DRY_RUN'] && !$exists) { if (!empty($this->game->image)) {