74 lines
3.0 KiB
PHP
74 lines
3.0 KiB
PHP
<?php
|
|
class BlueArchiveNewsBridge extends BridgeAbstract {
|
|
const MAINTAINER = 'Akamaru';
|
|
const NAME = 'Blue Archive News';
|
|
const URI = 'https://forum.nexon.com/bluearchive-en/';
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
|
const DESCRIPTION = 'Get the latest Announcements, Updates, and Events from Blue Archive (EN) Forum.';
|
|
|
|
public function getIcon() {
|
|
return 'https://img.ponywave.de/images/2025/07/18/Shiroko_Icon.png';
|
|
}
|
|
|
|
const PARAMETERS = [
|
|
[
|
|
'category' => [
|
|
'name' => 'Category',
|
|
'type' => 'list',
|
|
'values' => [
|
|
'All' => 'all',
|
|
'Announcements' => '3028',
|
|
'Updates' => '3217',
|
|
'Events' => '3218',
|
|
],
|
|
'defaultValue' => '3028',
|
|
],
|
|
],
|
|
];
|
|
|
|
public function collectData() {
|
|
$category = $this->getInput('category');
|
|
|
|
if ($category === 'all') {
|
|
// Verwende eine einzige API-URL für alle Kategorien
|
|
$jsonUrl = "https://forum.nexon.com/api/v1/community/314/threads?alias=bluearchive-en&paginationType=PAGING&pageSize=10&pageNo=1&blockSize=5&hideType=WEB";
|
|
$json = getContents($jsonUrl);
|
|
if (!$json) return;
|
|
$data = json_decode($json, true);
|
|
if (!isset($data['threads'])) return;
|
|
$threads = $data['threads'];
|
|
} else {
|
|
// Verwende die spezifische Board-URL für einzelne Kategorien
|
|
$jsonUrl = "https://forum.nexon.com/api/v1/board/{$category}/threads?alias=bluearchive-en&pageNo=1&paginationType=PAGING&pageSize=10&blockSize=5&hideType=WEB";
|
|
$json = getContents($jsonUrl);
|
|
if (!$json) return;
|
|
$data = json_decode($json, true);
|
|
if (!isset($data['threads'])) return;
|
|
$threads = $data['threads'];
|
|
}
|
|
|
|
foreach ($threads as $thread) {
|
|
$item = array();
|
|
$item['title'] = html_entity_decode($thread['title']);
|
|
$item['uri'] = 'https://forum.nexon.com/bluearchive-en/board_view?board=' . $thread['boardId'] . '&thread=' . $thread['threadId'];
|
|
$item['author'] = $thread['user']['nickname'] ?? '';
|
|
$item['timestamp'] = $thread['createDate'];
|
|
$item['uid'] = $thread['threadId'];
|
|
$item['enclosures'] = array();
|
|
// Fetch thread content
|
|
$threadApiUrl = 'https://forum.nexon.com/api/v1/thread/' . $thread['threadId'] . '?alias=bluearchive-en';
|
|
$threadJson = @getContents($threadApiUrl);
|
|
if ($threadJson) {
|
|
$threadData = json_decode($threadJson, true);
|
|
if (isset($threadData['content']) && !empty($threadData['content'])) {
|
|
$item['content'] = $threadData['content'];
|
|
} else {
|
|
$item['content'] = '';
|
|
}
|
|
} else {
|
|
$item['content'] = '';
|
|
}
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
}
|