1
0
Files
Bridges/WinaeroTweakerBridge.php
2025-12-09 13:50:39 +01:00

81 lines
2.6 KiB
PHP

<?php
declare(strict_types=1);
class WinaeroTweakerBridge extends BridgeAbstract
{
const MAINTAINER = 'Akamaru';
const NAME = 'Winaero Tweaker Updates';
const URI = 'https://winaero.com/category/winaero-apps/winaero-tweaker/';
const CACHE_TIMEOUT = 21600; // 6 hours
const DESCRIPTION = 'Returns updates for Winaero Tweaker application';
public function getIcon()
{
return 'https://www.google.com/s2/favicons?domain=winaero.com&sz=32';
}
public function collectData()
{
$html = getSimpleHTMLDOM(self::URI)
or returnServerError('Could not fetch Winaero Tweaker category page');
// Find all article elements
$articles = $html->find('article');
$itemCount = 0;
$maxItems = 10; // Limit to first page (approximately 10 items)
foreach ($articles as $article) {
if ($itemCount >= $maxItems) {
break;
}
$item = [];
// Extract title and link from header
$header = $article->find('.entry-header', 0);
if ($header) {
$titleLink = $header->find('h2 a', 0);
if ($titleLink) {
$item['title'] = trim($titleLink->plaintext);
$item['uri'] = $titleLink->href;
$item['uid'] = $titleLink->href;
}
}
// Extract content from entry-content div
$contentDiv = $article->find('.entry-content', 0);
if ($contentDiv) {
// Get the full HTML content including images
$item['content'] = $contentDiv->innertext;
}
// Extract date and author from footer
$footer = $article->find('.entry-footer', 0);
if ($footer) {
// Extract date from time element
$timeElement = $footer->find('time.entry-date', 0);
if ($timeElement && $timeElement->datetime) {
$timestamp = strtotime($timeElement->datetime);
if ($timestamp !== false) {
$item['timestamp'] = $timestamp;
}
}
// Extract author
$authorLink = $footer->find('.author a', 0);
if ($authorLink) {
$item['author'] = trim($authorLink->plaintext);
}
}
// Only add item if we have at least title and content
if (!empty($item['title']) && !empty($item['content'])) {
$this->items[] = $item;
$itemCount++;
}
}
}
}