[RainbowSixSiegeBridge] Fix bridge (#1587)
This commit is contained in:
parent
78298385d0
commit
9e74cc64ed
1 changed files with 3 additions and 27 deletions
|
@ -12,8 +12,8 @@ class RainbowSixSiegeBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$dlUrl = 'https://www.ubisoft.com/api/updates/items?categoriesFilter=all';
|
$dlUrl = 'https://www.ubisoft.com/api/updates/items?locale=en-us&categoriesFilter=all';
|
||||||
$dlUrl = $dlUrl . '&limit=6&mediaFilter=all&skip=0&startIndex=undefined&locale=en-us';
|
$dlUrl = $dlUrl . '&limit=6&mediaFilter=news&skip=0&startIndex=undefined&tags=BR-rainbow-six%20GA-siege';
|
||||||
$jsonString = getContents($dlUrl) or returnServerError('Error while downloading the website content');
|
$jsonString = getContents($dlUrl) or returnServerError('Error while downloading the website content');
|
||||||
|
|
||||||
$json = json_decode($jsonString, true);
|
$json = json_decode($jsonString, true);
|
||||||
|
@ -29,38 +29,14 @@ class RainbowSixSiegeBridge extends BridgeAbstract {
|
||||||
$thumbnail = '<img src="' . $jsonItem['thumbnail']['url'] . '" alt="Thumbnail">';
|
$thumbnail = '<img src="' . $jsonItem['thumbnail']['url'] . '" alt="Thumbnail">';
|
||||||
$content = $thumbnail . '<br />' . $jsonItem['content'];
|
$content = $thumbnail . '<br />' . $jsonItem['content'];
|
||||||
|
|
||||||
// Markdown parsing from https://gist.github.com/jbroadway/2836900
|
|
||||||
|
|
||||||
// Line breaks
|
// Line breaks
|
||||||
$content = preg_replace("/\r\n|\r|\n/", '<br/>', $content);
|
$content = preg_replace("/\r\n|\r|\n/", '<br/>', $content);
|
||||||
|
|
||||||
// Links
|
|
||||||
$regex = '/\[([^\[]+)\]\(([^\)]+)\)/';
|
|
||||||
$replacement = '<a href=\'\2\'>\1</a>';
|
|
||||||
$content = preg_replace($regex, $replacement, $content);
|
|
||||||
|
|
||||||
// Bold text
|
|
||||||
$regex = '/(\*\*|__)(.*?)\1/';
|
|
||||||
$replacement = '<strong>\2</strong>';
|
|
||||||
$content = preg_replace($regex, $replacement, $content);
|
|
||||||
|
|
||||||
// Lists
|
|
||||||
$regex = '/\n\s*[\*|\-](.*)/';
|
|
||||||
$content = preg_replace_callback($regex, function($regs) {
|
|
||||||
$item = $regs[1];
|
|
||||||
return sprintf ('<ul><li>%s</li></ul>', trim ($item));
|
|
||||||
}, $content);
|
|
||||||
|
|
||||||
// Italic text
|
|
||||||
$regex = '/(\*\*|\*)(.*?)\1/';
|
|
||||||
$replacement = '<i>\2</i>';
|
|
||||||
$content = preg_replace($regex, $replacement, $content);
|
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = $uri;
|
$item['uri'] = $uri;
|
||||||
$item['id'] = $jsonItem['id'];
|
$item['id'] = $jsonItem['id'];
|
||||||
$item['title'] = $jsonItem['title'];
|
$item['title'] = $jsonItem['title'];
|
||||||
$item['content'] = $content;
|
$item['content'] = markdownToHtml($content);
|
||||||
$item['timestamp'] = strtotime($jsonItem['date']);
|
$item['timestamp'] = strtotime($jsonItem['date']);
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
|
Loading…
Reference in a new issue