2018-06-15 22:05:31 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class SuperSmashBlogBridge extends BridgeAbstract
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2018-06-15 22:05:31 +03:00
|
|
|
const MAINTAINER = 'corenting';
|
|
|
|
const NAME = 'Super Smash Blog';
|
|
|
|
const URI = 'https://www.smashbros.com/en_US/blog/index.html';
|
|
|
|
const CACHE_TIMEOUT = 7200; // 2h
|
|
|
|
const DESCRIPTION = 'Latest articles from the Super Smash Blog blog';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-06-15 22:05:31 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2018-06-30 00:55:33 +03:00
|
|
|
$dlUrl = 'https://www.smashbros.com/data/bs/en_US/json/en_US.json';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-01-02 12:36:09 +03:00
|
|
|
$jsonString = getContents($dlUrl);
|
2018-06-15 22:05:31 +03:00
|
|
|
$json = json_decode($jsonString, true);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-06-15 22:05:31 +03:00
|
|
|
foreach ($json as $article) {
|
|
|
|
// Build content
|
|
|
|
$picture = $article['acf']['image1']['url'];
|
|
|
|
if (strlen($picture) != 0) {
|
|
|
|
$picture = str_get_html('<img src="https://www.smashbros.com/' . substr($picture, 8) . '"/>');
|
|
|
|
} else {
|
|
|
|
$picture = '';
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-06-15 22:05:31 +03:00
|
|
|
$video = $article['acf']['link_url'];
|
|
|
|
if (strlen($video) != 0) {
|
2018-11-05 14:55:58 +03:00
|
|
|
$video = str_get_html('<a href="' . $video . '">Youtube video</a>');
|
2018-06-15 22:05:31 +03:00
|
|
|
} else {
|
|
|
|
$video = '';
|
|
|
|
}
|
|
|
|
$text = str_get_html($article['acf']['editor']);
|
|
|
|
$content = $picture . $video . $text;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-06-15 22:05:31 +03:00
|
|
|
// Build final item
|
|
|
|
$item = [];
|
|
|
|
$item['title'] = $article['title']['rendered'];
|
|
|
|
$item['timestamp'] = strtotime($article['date']);
|
|
|
|
$item['content'] = $content;
|
|
|
|
$item['uri'] = self::URI . '?post=' . $article['id'];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-06-15 22:05:31 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|