120 lines
4.1 KiB
PHP
120 lines
4.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
class WarnerBrosDiscoveryBridge extends BridgeAbstract
|
|
{
|
|
const MAINTAINER = 'Akamaru';
|
|
const NAME = 'Warner Bros. Discovery Deutschland Presse';
|
|
const URI = 'https://www.wbd-deutschland.de';
|
|
const CACHE_TIMEOUT = 21600; // 6 hours
|
|
const DESCRIPTION = 'Pressemitteilungen von Warner Bros. Discovery Deutschland';
|
|
|
|
public function getIcon()
|
|
{
|
|
return 'https://www.google.com/s2/favicons?domain=www.wbd-deutschland.de&sz=32';
|
|
}
|
|
|
|
public function collectData()
|
|
{
|
|
// Retrieve webpage
|
|
$pageUrl = self::URI . '/post/list/type/all/tab';
|
|
$html = getSimpleHTMLDOM($pageUrl)
|
|
or returnServerError('Could not request webpage: ' . $pageUrl);
|
|
|
|
// Process press releases
|
|
foreach ($html->find('div.base-list-item') as $element) {
|
|
if (count($this->items) >= 15) {
|
|
break;
|
|
}
|
|
|
|
// Extract title and URI
|
|
$titleElement = $element->find('h2 a', 0);
|
|
if (!$titleElement) {
|
|
continue;
|
|
}
|
|
|
|
$item_title = trim(strip_tags($titleElement->innertext));
|
|
$item_uri = $titleElement->href;
|
|
|
|
// Convert relative URL to absolute
|
|
if (strpos($item_uri, 'http') !== 0) {
|
|
$item_uri = self::URI . $item_uri;
|
|
}
|
|
|
|
// Extract date (format: DD/MM/YYYY)
|
|
$dateElement = $element->find('span.padding-right-10.text-muted', 0);
|
|
$item_date = '';
|
|
$item_timestamp = null;
|
|
if ($dateElement) {
|
|
$dateText = trim(strip_tags($dateElement->innertext));
|
|
// Remove "- Letzte Aktualisierung ..." if present
|
|
$dateText = preg_replace('/\s*-\s*Letzte Aktualisierung.*/', '', $dateText);
|
|
$dateText = trim($dateText);
|
|
|
|
// Convert DD/MM/YYYY to timestamp
|
|
$dateParts = explode('/', $dateText);
|
|
if (count($dateParts) === 3) {
|
|
// Convert to MM/DD/YYYY for strtotime
|
|
$item_timestamp = strtotime($dateParts[1] . '/' . $dateParts[0] . '/' . $dateParts[2]);
|
|
$item_date = $dateText;
|
|
}
|
|
}
|
|
|
|
// Extract description
|
|
$item_description = '';
|
|
$descElement = $element->find('p.truncate-text', 0);
|
|
if ($descElement) {
|
|
$item_description = trim(strip_tags($descElement->innertext));
|
|
}
|
|
|
|
// Extract media (image or video)
|
|
$item_image = '';
|
|
|
|
$mediaSection = $element->find('div.media-section', 0);
|
|
if ($mediaSection) {
|
|
// Check for image
|
|
$imageElement = $mediaSection->find('img', 0);
|
|
if ($imageElement && isset($imageElement->src)) {
|
|
$item_image = $imageElement->src;
|
|
}
|
|
}
|
|
|
|
// Build content HTML
|
|
$content = '';
|
|
|
|
// Add image if available
|
|
if (!$item_video && $item_image) {
|
|
$content .= '<img src="' . $item_image . '" alt="' . htmlspecialchars($item_title) . '"><br><br>';
|
|
}
|
|
|
|
// Add description
|
|
if ($item_description) {
|
|
$content .= '<p>' . htmlspecialchars($item_description) . '</p>';
|
|
}
|
|
|
|
// Create item
|
|
if (!empty($item_title)) {
|
|
$item = array();
|
|
$item['uri'] = $item_uri;
|
|
$item['title'] = $item_title;
|
|
$item['content'] = $content;
|
|
$item['author'] = 'Warner Bros. Discovery Deutschland';
|
|
|
|
if ($item_timestamp) {
|
|
$item['timestamp'] = $item_timestamp;
|
|
}
|
|
|
|
// Set enclosures for image
|
|
if ($item_image) {
|
|
$item['enclosures'] = array($item_image);
|
|
}
|
|
|
|
// Create unique ID
|
|
$item['uid'] = $item_title . ' - ' . $item_date;
|
|
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
}
|
|
}
|