mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-26 11:26:31 +03:00
[EpicgamesBridge] Add pinned posts to list (#1736)
This commit is contained in:
parent
cf606a3a6b
commit
d299adb827
1 changed files with 25 additions and 5 deletions
|
@ -48,13 +48,22 @@ class EpicgamesBridge extends BridgeAbstract {
|
||||||
));
|
));
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
// Example: https://store-content.ak.epicgames.com/api/ru/content/blog?limit=25
|
|
||||||
$api = 'https://store-content.ak.epicgames.com/api/';
|
$api = 'https://store-content.ak.epicgames.com/api/';
|
||||||
$url = $api . $this->getInput('language') . '/content/blog?limit=' . $this->getInput('postcount');
|
|
||||||
|
|
||||||
$data = getContents($url)
|
// Get sticky posts first
|
||||||
or returnServerError('Unable to get the news pages from epicgames.com!');
|
// Example: https://store-content.ak.epicgames.com/api/ru/content/blog/sticky?locale=ru
|
||||||
$decodedData = json_decode($data);
|
$urlSticky = $api . $this->getInput('language') . '/content/blog/sticky';
|
||||||
|
// Then get posts
|
||||||
|
// Example: https://store-content.ak.epicgames.com/api/ru/content/blog?limit=25
|
||||||
|
$urlBlog = $api . $this->getInput('language') . '/content/blog?limit=' . $this->getInput('postcount');
|
||||||
|
|
||||||
|
$dataSticky = getContents($urlSticky)
|
||||||
|
or returnServerError('Unable to get the sticky posts from epicgames.com!');
|
||||||
|
$dataBlog = getContents($urlBlog)
|
||||||
|
or returnServerError('Unable to get the news posts from epicgames.com!');
|
||||||
|
|
||||||
|
// Merge data
|
||||||
|
$decodedData = array_merge(json_decode($dataSticky), json_decode($dataBlog));
|
||||||
|
|
||||||
foreach($decodedData as $key => $value) {
|
foreach($decodedData as $key => $value) {
|
||||||
$item = array();
|
$item = array();
|
||||||
|
@ -76,5 +85,16 @@ class EpicgamesBridge extends BridgeAbstract {
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort data
|
||||||
|
usort($this->items, function ($item1, $item2) {
|
||||||
|
if ($item2['timestamp'] == $item1['timestamp']) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ($item2['timestamp'] < $item1['timestamp']) ? -1 : 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Limit data
|
||||||
|
$this->items = array_slice($this->items, 0, $this->getInput('postcount'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue