Gamejolt.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. Microblog bot for game release notifications
  4. Copyright (C) 2017 Alexander Yakovlev
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. namespace Source;
  17. use \Game;
  18. class Gamejolt extends Source {
  19. public $title = "GameJolt";
  20. protected function parse_tag($url) {
  21. $data = json_decode($this->get_text($url));
  22. $games = $data->payload->games;
  23. foreach ($games as $gameData) {
  24. $descUrl = 'https://gamejolt.com/site-api/web/discover/games/overview/'.$gameData->id;
  25. $descData = json_decode($this->get_text($descUrl));
  26. $game = new Game;
  27. $game->title = $gameData->title;
  28. $game->author = $gameData->developer->display_name;
  29. $game->date = $gameData->published_on / 1000;
  30. $game->description = $descData->payload->metaDescription;
  31. $game->url = 'https://gamejolt.com/games/'.$gameData->slug.'/'.$gameData->id;
  32. if ($game->date < $this->period) {
  33. continue;
  34. }
  35. $this->games[] = $game;
  36. }
  37. }
  38. protected function parse() {
  39. $this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/twine");
  40. $this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/renpy");
  41. $this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/text");
  42. $this->parse_tag("https://gamejolt.com/site-api/web/library/games/tag/ascii");
  43. }
  44. }