mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-12-12 12:57:56 +03:00
3d231a417f
Bridges should generally utilize the API functions instead of killing the script. Find more information on the Wiki. - returnServerError https://github.com/RSS-Bridge/rss-bridge/wiki/The-returnServerError-function - returnClientError https://github.com/RSS-Bridge/rss-bridge/wiki/The-returnClientError-function - returnError https://github.com/RSS-Bridge/rss-bridge/wiki/The-returnError-function
65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?php
|
|
class GOGBridge extends BridgeAbstract {
|
|
|
|
const NAME = 'GOGBridge';
|
|
const MAINTAINER = 'teromene';
|
|
const URI = 'https://gog.com';
|
|
const DESCRIPTION = 'Returns the latest releases from GOG.com';
|
|
|
|
public function collectData() {
|
|
|
|
$values = getContents('https://www.gog.com/games/ajax/filtered?limit=25&sort=new')
|
|
or returnServerError('Unable to get the news pages from GOG !');
|
|
$decodedValues = json_decode($values);
|
|
|
|
$limit = 0;
|
|
foreach($decodedValues->products as $game) {
|
|
|
|
$item = array();
|
|
$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;
|
|
|
|
foreach($game->gallery as $image) {
|
|
$item['enclosures'][] = $image . '.jpg';
|
|
}
|
|
|
|
$this->items[] = $item;
|
|
$limit += 1;
|
|
|
|
if($limit == 10) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private function buildGameContentPage($game) {
|
|
|
|
$gameDescriptionText = getContents('https://api.gog.com/products/' . $game->id . '?expand=description')
|
|
or returnServerError('Unable to get game description from GOG !');
|
|
|
|
$gameDescriptionValue = json_decode($gameDescriptionText);
|
|
|
|
$content = 'Genres: ';
|
|
$content .= implode(', ', $game->genres);
|
|
|
|
$content .= '<br />Supported Platforms: ';
|
|
if($game->worksOn->Windows) {
|
|
$content .= 'Windows ';
|
|
}
|
|
if($game->worksOn->Mac) {
|
|
$content .= 'Mac ';
|
|
}
|
|
if($game->worksOn->Linux) {
|
|
$content .= 'Linux ';
|
|
}
|
|
|
|
$content .= '<br />' . $gameDescriptionValue->description->full;
|
|
|
|
return $content;
|
|
|
|
}
|
|
}
|