rss-bridge/bridges/SpottschauBridge.php

43 lines
1.2 KiB
PHP
Raw Normal View History

2021-07-20 11:16:43 +03:00
<?php
class SpottschauBridge extends BridgeAbstract
{
const NAME = 'Härringers Spottschau Bridge';
const URI = 'https://spottschau.com/';
const DESCRIPTION = 'Der Fußball-Comic';
const MAINTAINER = 'sal0max';
const PARAMETERS = [];
2021-07-20 11:16:43 +03:00
const CACHE_TIMEOUT = 3600; // 1 hour
2021-07-20 11:16:43 +03:00
public function collectData()
{
$html = getSimpleHTMLDOM(self::URI);
2021-07-20 11:16:43 +03:00
$item = [];
$item['uri'] = urljoin(self::URI, $html->find('div.strip>a', 0)->attr['href']);
$item['title'] = $html->find('div.text>h2', 0)->innertext;
2021-07-20 11:16:43 +03:00
$date = preg_replace('/.*, /', '', $item['title']);
$date = preg_replace('/\\d\\d\\.\\//', '', $date);
try {
$item['timestamp'] = DateTime::createFromFormat('d.m.y', $date)
->setTimezone(new DateTimeZone('Europe/Berlin'))
->setTime(0, 0)
->getTimestamp();
} catch (Throwable $ignored) {
$item['timestamp'] = null;
}
2021-07-20 11:16:43 +03:00
$image = $html->find('div.strip>a>img', 0);
$imageUrl = urljoin(self::URI, $image->attr['src']);
$imageAlt = $image->attr['alt'];
$item['content'] = <<<EOD
2021-07-20 11:16:43 +03:00
<img src="{$imageUrl}" alt="{$imageAlt}"/>
<br/>
EOD;
$this->items[] = $item;
}
2021-07-20 11:16:43 +03:00
}