Steam WIP, see issue #13
This commit is contained in:
parent
5ec159d507
commit
bfb5143d1f
46
Source/Steam.php
Normal file
46
Source/Steam.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
namespace Source;
|
||||
|
||||
use \Game;
|
||||
|
||||
class Steam extends Source {
|
||||
public $title = "Steam";
|
||||
protected function parse_tag($tag) {
|
||||
$url = 'http://store.steampowered.com/search/';
|
||||
$url .= '?'.http_build_query([
|
||||
'sort_by' => 'Released_DESC',
|
||||
'term' => $tag,
|
||||
'displayterm' => $tag,
|
||||
'category1' => 998, // only games
|
||||
]);
|
||||
$text = $this->get_text($url);
|
||||
try {
|
||||
$this->dom->loadStr($text, []);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
echo $e->getTraceAsString();
|
||||
return "";
|
||||
}
|
||||
unset($text);
|
||||
$games = $this->dom->find('#search_result_container a.search_result_row');
|
||||
foreach ($games as $gameLink) {
|
||||
$url = $gameLink->getAttribute('href');
|
||||
$text = $this->get_text($url);
|
||||
$game = new Game;
|
||||
/*
|
||||
$game->title = $gameData->title;
|
||||
$game->author = $gameData->developer->display_name;
|
||||
$game->date = $gameData->published_on;
|
||||
$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();
|
||||
}
|
||||
}
|
||||
protected function parse() {
|
||||
$this->parse_tag("text-based");
|
||||
}
|
||||
}
|
2
run.php
2
run.php
|
@ -35,6 +35,7 @@ if ($parsers === 'all' || in_array('all', $parsers)) {
|
|||
'dashingdon',
|
||||
'itch',
|
||||
'gamejolt',
|
||||
'steam',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -62,6 +63,7 @@ check ('IFDB', 'ifdb');
|
|||
//check ('Dashingdon', 'dashingdon');
|
||||
check ('Itch', 'itch');
|
||||
check ('Gamejolt', 'gamejolt');
|
||||
check ('Steam', 'steam');
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
echo '</pre></code></body></html>';
|
||||
|
|
Reference in a new issue