2017-03-20 23:32:31 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-03-20 23:32:31 +03:00
|
|
|
class RainbowSixSiegeBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'corenting';
|
2020-01-31 16:51:59 +03:00
|
|
|
const NAME = 'Rainbow Six Siege News';
|
|
|
|
const URI = 'https://www.ubisoft.com/en-us/game/rainbow-six/siege/news-updates';
|
2017-03-20 23:32:31 +03:00
|
|
|
const CACHE_TIMEOUT = 7200; // 2h
|
2020-01-31 16:51:59 +03:00
|
|
|
const DESCRIPTION = 'Latest news about Rainbow Six Siege';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-02-27 21:33:46 +03:00
|
|
|
// API key to call Ubisoft API, extracted from the React frontend
|
2023-08-15 17:16:06 +03:00
|
|
|
const NIMBUS_API_KEY = '3b5a8be6dde511ec9d640242ac120002';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-10-26 19:07:34 +03:00
|
|
|
public function getIcon()
|
|
|
|
{
|
2022-02-27 21:33:46 +03:00
|
|
|
return 'https://static-dm.akamaized.net/siege/prod/favicon.ico';
|
2018-10-26 19:07:34 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-03-20 23:32:31 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2022-02-27 21:33:46 +03:00
|
|
|
$dlUrl = 'https://nimbus.ubisoft.com/api/v1/items?categoriesFilter=all';
|
|
|
|
$dlUrl = $dlUrl . '&limit=6&mediaFilter=all&skip=0&startIndex=0&tags=BR-rainbow-six%20GA-siege';
|
|
|
|
$dlUrl = $dlUrl . '&locale=en-us&fallbackLocale=en-us&environment=master';
|
|
|
|
$jsonString = getContents($dlUrl, [
|
2024-07-31 18:30:06 +03:00
|
|
|
'Authorization: ' . self::NIMBUS_API_KEY,
|
2022-02-27 21:33:46 +03:00
|
|
|
]);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-07-14 23:05:51 +03:00
|
|
|
$json = json_decode($jsonString, true);
|
|
|
|
$json = $json['items'];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-03-20 23:32:31 +03:00
|
|
|
// Start at index 2 to remove highlighted articles
|
2017-07-29 20:28:00 +03:00
|
|
|
for ($i = 0; $i < count($json); $i++) {
|
2020-01-31 16:51:59 +03:00
|
|
|
$jsonItem = $json[$i];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2023-08-15 17:16:06 +03:00
|
|
|
$uri = 'https://www.ubisoft.com/en-us/game/rainbow-six/siege/news-updates';
|
2020-01-31 16:51:59 +03:00
|
|
|
$uri = $uri . $jsonItem['button']['buttonUrl'];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2023-08-15 17:16:06 +03:00
|
|
|
$thumbnail = '<img src="' . $jsonItem['thumbnail']['url'] . '" alt="Thumbnail" />';
|
2020-10-09 21:29:02 +03:00
|
|
|
$content = $thumbnail . '<br />' . markdownToHtml($jsonItem['content']);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-01-31 16:51:59 +03:00
|
|
|
$item = [];
|
2023-08-15 17:16:06 +03:00
|
|
|
|
|
|
|
// The date string includes (Coordinated Universal Time) at the end
|
|
|
|
// so remove it to use strtotime
|
|
|
|
$date_str = str_replace('(Coordinated Universal Time)', '', $jsonItem['date']);
|
|
|
|
$item['timestamp'] = strtotime($date_str);
|
|
|
|
|
2017-03-20 23:32:31 +03:00
|
|
|
$item['uri'] = $uri;
|
2020-01-31 16:51:59 +03:00
|
|
|
$item['id'] = $jsonItem['id'];
|
|
|
|
$item['title'] = $jsonItem['title'];
|
2020-10-09 21:29:02 +03:00
|
|
|
$item['content'] = $content;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-03-20 23:32:31 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|