Neu: Funstock Evercade Bridge
This commit is contained in:
115
FunstockEvercadeBridge.php
Normal file
115
FunstockEvercadeBridge.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
class FunstockEvercadeBridge extends BridgeAbstract
|
||||
{
|
||||
const MAINTAINER = 'Akamaru';
|
||||
const NAME = 'Funstock Evercade';
|
||||
const URI = 'https://funstock.eu/collections/evercade';
|
||||
const CACHE_TIMEOUT = 3600; // 1h
|
||||
const DESCRIPTION = 'New Evercade products from Funstock (consoles, cartridges, accessories)';
|
||||
|
||||
const PARAMETERS = [
|
||||
[
|
||||
'limit' => [
|
||||
'name' => 'Number of products',
|
||||
'type' => 'number',
|
||||
'defaultValue' => 20,
|
||||
'required' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
public function getIcon()
|
||||
{
|
||||
return 'https://www.google.com/s2/favicons?domain=funstock.eu&sz=32';
|
||||
}
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$limit = $this->getInput('limit') ?: 20;
|
||||
$apiUrl = 'https://funstock.eu/collections/evercade/products.json?sort_by=created-descending&limit=' . $limit;
|
||||
|
||||
$json = getContents($apiUrl);
|
||||
if (!$json) {
|
||||
returnServerError('Could not fetch data from Funstock');
|
||||
}
|
||||
|
||||
$data = json_decode($json, true);
|
||||
if (!$data || !isset($data['products'])) {
|
||||
returnServerError('Invalid JSON response from Funstock');
|
||||
}
|
||||
|
||||
foreach ($data['products'] as $product) {
|
||||
$item = [];
|
||||
|
||||
$item['title'] = $product['title'];
|
||||
$item['uri'] = 'https://funstock.eu/products/' . $product['handle'];
|
||||
$item['uid'] = (string) $product['id'];
|
||||
|
||||
// Timestamp (creation date)
|
||||
if (isset($product['created_at'])) {
|
||||
$item['timestamp'] = strtotime($product['created_at']);
|
||||
}
|
||||
|
||||
// Author/Vendor
|
||||
if (isset($product['vendor']) && !empty($product['vendor'])) {
|
||||
$item['author'] = $product['vendor'];
|
||||
}
|
||||
|
||||
// Categories/Tags
|
||||
if (isset($product['tags']) && is_array($product['tags'])) {
|
||||
$item['categories'] = $product['tags'];
|
||||
}
|
||||
|
||||
// Price from first variant
|
||||
$price = '';
|
||||
if (isset($product['variants'][0]['price'])) {
|
||||
$price = $product['variants'][0]['price'] . ' EUR';
|
||||
}
|
||||
|
||||
// Product type
|
||||
$productType = $product['product_type'] ?? '';
|
||||
|
||||
// Build content
|
||||
$content = '';
|
||||
|
||||
// Product image
|
||||
if (isset($product['images'][0]['src'])) {
|
||||
$imageUrl = $product['images'][0]['src'];
|
||||
$content .= '<div style="text-align: center;"><img src="' . htmlspecialchars($imageUrl) . '" alt="' . htmlspecialchars($product['title']) . '" style="max-width: 400px;"></div><br>';
|
||||
$item['enclosures'][] = $imageUrl;
|
||||
}
|
||||
|
||||
// Price and type
|
||||
if ($price || $productType) {
|
||||
$content .= '<p>';
|
||||
if ($price) {
|
||||
$content .= '<strong>Price:</strong> ' . htmlspecialchars($price);
|
||||
}
|
||||
if ($price && $productType) {
|
||||
$content .= ' | ';
|
||||
}
|
||||
if ($productType) {
|
||||
$content .= '<strong>Type:</strong> ' . htmlspecialchars($productType);
|
||||
}
|
||||
$content .= '</p>';
|
||||
}
|
||||
|
||||
// Description (clean HTML)
|
||||
if (isset($product['body_html']) && !empty($product['body_html'])) {
|
||||
$description = $product['body_html'];
|
||||
|
||||
// Remove empty paragraphs
|
||||
$description = preg_replace('/<p>\s*( |\s)*<\/p>/', '', $description);
|
||||
|
||||
$content .= '<hr>' . $description;
|
||||
}
|
||||
|
||||
$item['content'] = $content;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,11 @@ Diese Sammlung enthält verschiedene Bridge-Implementierungen für RSS-Bridge, u
|
||||
### [Florida TV Bridge](https://bridge.ponywave.de/#bridge-FloridaTVBridge) (Von Akamaru)
|
||||
- **Beschreibung**: Neueste News von FloridaTV Entertainment.
|
||||
|
||||
### [Funstock Evercade Bridge](https://bridge.ponywave.de/#bridge-FunstockEvercadeBridge) (Von Akamaru)
|
||||
- **Beschreibung**: Zeigt neue Evercade-Produkte von Funstock (Konsolen, Cartridges, Zubehör)
|
||||
- **Parameter**:
|
||||
- **Number of products**: Anzahl der Produkte (Standard: 20)
|
||||
|
||||
### [Foodwatch Bridge](https://bridge.ponywave.de/#bridge-FoodwatchBridge) (Von Akamaru)
|
||||
- **Beschreibung**: Zeigt die neuesten Nachrichten von Foodwatch.org
|
||||
|
||||
|
||||
Reference in New Issue
Block a user