rss-bridge/bridges/GOGBridge.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.8 KiB
PHP
Raw Normal View History

2018-09-09 19:32:36 +03:00
<?php
class GOGBridge extends BridgeAbstract
{
2018-09-09 19:32:36 +03:00
const NAME = 'GOGBridge';
const MAINTAINER = 'teromene';
const URI = 'https://gog.com';
const DESCRIPTION = 'Returns the latest releases from GOG.com';
2018-09-09 19:32:36 +03:00
public function collectData()
{
$values = getContents('https://www.gog.com/games/ajax/filtered?limit=25&sort=new');
2018-09-09 19:32:36 +03:00
$decodedValues = json_decode($values);
2018-09-09 19:32:36 +03:00
$limit = 0;
foreach ($decodedValues->products as $game) {
$item = [];
$item['author'] = $game->developer . ' / ' . $game->publisher;
$item['title'] = $game->title;
$item['id'] = $game->id;
$item['uri'] = self::URI . $game->url;
$item['content'] = $this->buildGameContentPage($game);
$item['timestamp'] = $game->globalReleaseDate;
2018-09-09 19:32:36 +03:00
foreach ($game->gallery as $image) {
$item['enclosures'][] = $image . '.jpg';
}
2018-09-09 19:32:36 +03:00
$this->items[] = $item;
$limit += 1;
2018-09-09 19:32:36 +03:00
if ($limit == 10) {
break;
}
}
}
2018-09-09 19:32:36 +03:00
private function buildGameContentPage($game)
{
$gameDescriptionText = getContents('https://api.gog.com/products/' . $game->id . '?expand=description');
2018-09-09 19:32:36 +03:00
$gameDescriptionValue = json_decode($gameDescriptionText);
2018-09-09 19:32:36 +03:00
$content = 'Genres: ';
$content .= implode(', ', $game->genres);
2018-09-09 19:32:36 +03:00
$content .= '<br />Supported Platforms: ';
if ($game->worksOn->Windows) {
$content .= 'Windows ';
}
if ($game->worksOn->Mac) {
$content .= 'Mac ';
}
if ($game->worksOn->Linux) {
$content .= 'Linux ';
}
2018-09-09 19:32:36 +03:00
$content .= '<br />' . $gameDescriptionValue->description->full;
2018-09-09 19:32:36 +03:00
return $content;
}
}