111 lines
4.7 KiB
PHP
111 lines
4.7 KiB
PHP
<?php
|
|
class FuturamaHitAndRunBridge extends BridgeAbstract {
|
|
const NAME = 'Futurama: Hit & Run Mod Releases';
|
|
const URI = 'https://modbakery.donutteam.com/projects/downloads/48/183';
|
|
const DESCRIPTION = 'Returns the latest releases for the Futurama: Hit & Run total conversion mod';
|
|
const MAINTAINER = 'Akamaru';
|
|
const CACHE_TIMEOUT = 3600; // 1 hour
|
|
|
|
public function getIcon() {
|
|
return 'https://nyc3.digitaloceanspaces.com/donut-team/files/2025/10/18/19-46-33/15c954b6-e49f-417c-8fc6-4090186b3aa7/icon.webp';
|
|
}
|
|
|
|
public function collectData() {
|
|
$html = getSimpleHTMLDOM(self::URI);
|
|
if (!$html) return;
|
|
|
|
// Find all version blocks
|
|
$versionBlocks = $html->find('div.component-block h3.component-header');
|
|
|
|
foreach ($versionBlocks as $versionHeader) {
|
|
// Get version number from header
|
|
$versionText = trim($versionHeader->find('div.text', 0)->plaintext ?? '');
|
|
if (empty($versionText)) continue;
|
|
|
|
// Skip branch names - only process actual version numbers (e.g., 0.1.0, 1.2.3)
|
|
// Version numbers typically contain dots or start with numbers
|
|
if (!preg_match('/^\d+\./', $versionText)) continue;
|
|
|
|
// Get the parent block containing all version information
|
|
$versionBlock = $versionHeader->parent();
|
|
if (!$versionBlock) continue;
|
|
|
|
$item = [];
|
|
$item['title'] = 'Futurama: Hit & Run - Version ' . $versionText;
|
|
$item['uid'] = 'futurama-har-' . $versionText;
|
|
|
|
// Find version ID from badges
|
|
$badges = $versionBlock->find('div.component-badge');
|
|
foreach ($badges as $badge) {
|
|
$badgeText = $badge->plaintext;
|
|
if (strpos($badgeText, 'ID ') !== false) {
|
|
preg_match('/ID (\d+)/', $badgeText, $matches);
|
|
if (isset($matches[1])) {
|
|
$item['uid'] = 'futurama-har-id-' . $matches[1];
|
|
}
|
|
}
|
|
|
|
// Get published date
|
|
if (strpos($badgeText, 'Published') !== false) {
|
|
$timeElement = $badge->find('time.component-human-time', 0);
|
|
if ($timeElement && $timeElement->datetime) {
|
|
$item['timestamp'] = strtotime($timeElement->datetime);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Use the project downloads page as article link
|
|
$item['uri'] = self::URI;
|
|
|
|
// Find download link for content
|
|
$downloadLink = null;
|
|
$downloadBtn = $versionBlock->find('a.component-button', 0);
|
|
if ($downloadBtn && $downloadBtn->href) {
|
|
$downloadLink = 'https://modbakery.donutteam.com' . $downloadBtn->href;
|
|
}
|
|
|
|
// Build content
|
|
$content = '';
|
|
|
|
// Add banner
|
|
$content .= '<div style="text-align: center;">';
|
|
$content .= '<img src="https://nyc3.digitaloceanspaces.com/donut-team/files/2025/10/18/19-46-32/399a6671-8cf9-4aa0-b3d5-6cd8656f8a09/banner.webp" alt="Futurama: Hit & Run Banner" style="max-width: 100%;">';
|
|
$content .= '</div><br>';
|
|
|
|
$content .= '<h2>Version ' . htmlspecialchars($versionText) . '</h2>';
|
|
|
|
// Add changelog if available
|
|
$changelogDetails = $versionBlock->find('details.component-details', 0);
|
|
if ($changelogDetails) {
|
|
$changelogContent = $changelogDetails->find('p.component-paragraph', 0);
|
|
if ($changelogContent) {
|
|
$content .= '<h3>Changelog:</h3>';
|
|
$content .= '<p>' . $changelogContent->innertext . '</p>';
|
|
}
|
|
}
|
|
|
|
// Add download button
|
|
if ($downloadLink) {
|
|
$content .= '<br><p><strong><a href="' . htmlspecialchars($downloadLink) . '">Download Version ' . htmlspecialchars($versionText) . '</a></strong></p>';
|
|
}
|
|
|
|
// Add project info
|
|
$content .= '<br><hr>';
|
|
$content .= '<p><em>Futurama: Hit & Run is a total conversion mod for The Simpsons: Hit & Run aiming to replicate the gameplay of Hit & Run in the world of Futurama.</em></p>';
|
|
$content .= '<p><strong>Developer:</strong> Slurm Team</p>';
|
|
|
|
$item['content'] = $content;
|
|
$item['author'] = 'Slurm Team';
|
|
|
|
// Add banner as enclosure
|
|
$item['enclosures'][] = 'https://nyc3.digitaloceanspaces.com/donut-team/files/2025/10/18/19-46-32/399a6671-8cf9-4aa0-b3d5-6cd8656f8a09/banner.webp';
|
|
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
|
|
public function getName() {
|
|
return 'Futurama: Hit & Run - Mod Releases';
|
|
}
|
|
}
|