Archived
1
0
Fork 0
This repository has been archived on 2020-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
news-script/Source/Gamejolt.php

33 lines
1.2 KiB
PHP

<?php
namespace Source;
use \Game;
class Gamejolt extends Source {
public $title = "GameJolt";
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;
}
$this->output .= $game->print();
}
}
protected function parse() {
$this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/twine");
$this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/renpy");
$this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/text");
$this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/ascii");
}
}