1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-10-22 12:06:09 +02:00
Files
php-rss-bridge/bridges/MinecraftBridge.php
Florian 2906bc91a4 [MinecraftBridge] Add article categories (#4714)
* [MinecraftBridge] Add article categories

* Fix for inline control structure
2025-09-08 16:33:12 +02:00

58 lines
1.8 KiB
PHP

<?php
class MinecraftBridge extends BridgeAbstract
{
const NAME = 'Minecraft';
const URI = 'https://www.minecraft.net';
const DESCRIPTION = 'Catch up on the latest Minecraft articles';
const MAINTAINER = 'tillcash';
const PARAMETERS = [
[
'category' => [
'type' => 'list',
'name' => 'Category',
'values' => [
'All' => 'all',
'Deep Dives' => 'Deep Dives',
'News' => 'News',
'Marketplace' => 'Marketplace',
'Merch' => 'Merch',
],
'title' => 'Choose article category',
'defaultValue' => 'all',
]
]
];
public function getIcon()
{
return 'https://www.minecraft.net/etc.clientlibs/minecraftnet/clientlibs/clientlib-site/resources/favicon.ico';
}
public function collectData()
{
$json = getContents(
'https://www.minecraft.net/content/minecraftnet/language-masters/en-us/_jcr_content.articles.page-1.json'
);
$articles = json_decode($json);
if ($articles === null) {
throwServerException('Failed to decode JSON content.');
}
foreach ($articles->article_grid as $article) {
if ($article->primary_category !== $this->getInput('category') && $this->getInput('category') !== 'all') {
continue;
}
$this->items[] = [
'title' => $article->default_tile->title,
'uid' => $article->article_url,
'uri' => self::URI . $article->article_url,
'content' => $article->default_tile->sub_header,
'categories' => [$article->primary_category],
];
}
}
}