Neue Bridge für Indiegala Freebies
This commit is contained in:
56
IndiegalaFreebiesBridge.php
Normal file
56
IndiegalaFreebiesBridge.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user