1
0
Files
Bridges/IndiegalaFreebiesBridge.php
2025-09-26 13:33:37 +02:00

56 lines
2.0 KiB
PHP

<?php
class IndiegalaFreebiesBridge extends BridgeAbstract {
const MAINTAINER = 'Akamaru';
const NAME = 'Indiegala Freebies';
const URI = 'https://freebies.indiegala.com/';
const CACHE_TIMEOUT = 21600; // 6h
const DESCRIPTION = 'Get the latest free PC games from Indiegala Freebies.';
public function getIcon() {
return 'https://freebies.indiegala.com/favicon.ico';
}
public function collectData() {
$html = getSimpleHTMLDOM(self::URI);
if (!$html) return;
$products = $html->find('.row.products-row .products-col');
foreach ($products as $product) {
$item = array();
$titleElement = $product->find('.product-title', 0);
$linkElement = $product->find('.fit-click', 0);
$imageElement = $product->find('.product-img img', 0);
if (!$titleElement || !$linkElement) continue;
$title = trim($titleElement->plaintext);
$link = $linkElement->href;
if (strpos($link, 'http') !== 0) {
$link = 'https://freebies.indiegala.com' . $link;
}
$item['title'] = $title;
$item['uri'] = $link;
$item['uid'] = md5($link);
if ($imageElement) {
$imageSrc = $imageElement->getAttribute('data-img-src');
if ($imageSrc) {
$item['enclosures'] = array($imageSrc);
$item['content'] = '<img src="' . $imageSrc . '" alt="' . htmlspecialchars($title) . '"><br><br>';
} else {
$item['content'] = '';
}
} else {
$item['content'] = '';
}
$item['content'] .= 'New free PC game available on Indiegala: <strong>' . htmlspecialchars($title) . '</strong>';
$this->items[] = $item;
}
}
}