1
0
Files
Bridges/EvercadePatchNotesBridge.php
2025-12-02 14:21:43 +01:00

67 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
class EvercadePatchNotesBridge extends BridgeAbstract
{
const MAINTAINER = 'Akamaru';
const NAME = 'Evercade Patch Notes';
const URI = 'https://evercade.co.uk';
const CACHE_TIMEOUT = 86400; // 24 hours
const DESCRIPTION = 'Returns patch notes and version updates for Evercade consoles';
public function getIcon()
{
return 'https://www.google.com/s2/favicons?domain=evercade.co.uk&sz=32';
}
public function collectData()
{
$html = getSimpleHTMLDOM(self::URI . '/support-vs/vs-patch-notes/')
or returnServerError('Could not fetch Evercade patch notes page');
// Find all H3 version headings
$versionHeadings = $html->find('h3');
foreach ($versionHeadings as $heading) {
$headingText = $heading->plaintext;
// Extract version number using regex (e.g., "4.1.5" from "Version 4.1.5")
if (preg_match('/Version\s+(\d+\.\d+(?:\.\d+)?)/i', $headingText, $matches)) {
$versionNumber = $matches[1];
$item = [];
$item['title'] = 'Evercade Update v' . $versionNumber;
$item['uri'] = self::URI . '/support-vs/vs-patch-notes/';
$item['uid'] = 'evercade-patch-' . $versionNumber;
$item['author'] = 'Blaze';
// Collect content between this H3 and the next H3
$content = $this->extractVersionContent($heading);
$item['content'] = $content;
// No timestamp available on page - RSS-Bridge will use current time
$this->items[] = $item;
}
}
}
private function extractVersionContent($heading): string
{
$content = '';
$currentElement = $heading->next_sibling();
// Collect all content until next H3 or end
while ($currentElement && $currentElement->tag !== 'h3') {
// Get the outer HTML of the element to preserve formatting
if (isset($currentElement->outertext)) {
$content .= $currentElement->outertext;
}
$currentElement = $currentElement->next_sibling();
}
return $content;
}
}