From fe45c2a2a2e76b835da710ab7bfa775b595943e0 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Fri, 15 Dec 2017 13:05:23 +0700 Subject: [PATCH] steam and gamejolt fixes --- Source/Gamejolt.php | 26 ++++++++++++++------------ Source/Steam.php | 3 +-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/Gamejolt.php b/Source/Gamejolt.php index 2ee614a..94e9b10 100644 --- a/Source/Gamejolt.php +++ b/Source/Gamejolt.php @@ -8,19 +8,21 @@ class Gamejolt extends Source { protected function parse_tag($url) { $data = json_decode($this->get_text($url)); $games = $data->payload->games; - foreach ($games as $gameData) { - $descUrl = 'https://gamejolt.com/site-api/web/discover/games/overview/'.$gameData->id; - $descData = json_decode($this->get_text($descUrl)); - $game = new Game; - $game->title = $gameData->title; - $game->author = $gameData->developer->display_name; - $game->date = $gameData->published_on / 1000; - $game->description = $descData->payload->metaDescription; - $game->url = 'https://gamejolt.com/games/'.$gameData->slug.'/'.$gameData->id; - if ($game->date < $this->period) { - continue; + if (count($games) > 0) { + foreach ($games as $gameData) { + $descUrl = 'https://gamejolt.com/site-api/web/discover/games/overview/'.$gameData->id; + $descData = json_decode($this->get_text($descUrl)); + $game = new Game; + $game->title = $gameData->title; + $game->author = $gameData->developer->display_name; + $game->date = $gameData->published_on / 1000; + $game->description = $descData->payload->metaDescription; + $game->url = 'https://gamejolt.com/games/'.$gameData->slug.'/'.$gameData->id; + if ($game->date < $this->period) { + continue; + } + $this->output .= $game->print(); } - $this->output .= $game->print(); } } protected function parse() { diff --git a/Source/Steam.php b/Source/Steam.php index 1ae5cc7..034ed2a 100644 --- a/Source/Steam.php +++ b/Source/Steam.php @@ -27,13 +27,12 @@ class Steam extends Source { foreach ($games as $gameLink) { $url = $gameLink->getAttribute('href'); $url = substr($url,0,strpos($url, '?')); // remove query string - game = new Game; + $game = new Game; $game->url = $url; try { $text = $this->get_text($url); $this->dom = new Dom; $this->dom->loadStr($text, []); - var_dump($text); unset($text); $name = $this->dom->find('div.apphub_AppName'); $description = $this->dom->find('meta[property=og:description]');