Skip to content

Commit

Permalink
[SpottschauBridge] New bridge (#2193)
Browse files Browse the repository at this point in the history
  • Loading branch information
sal0max authored Jul 20, 2021
1 parent 3448943 commit e14f647
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions bridges/SpottschauBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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 = array();

const CACHE_TIMEOUT = 3600; // 1 hour

public function collectData() {
$html = getSimpleHTMLDOM(self::URI);

$item = array();
$item['uri'] = urljoin(self::URI, $html->find('div.strip>a', 0)->attr['href']);
$item['title'] = $html->find('div.text>h2', 0)->innertext;

$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;
}

$image = $html->find('div.strip>a>img', 0);
$imageUrl = urljoin(self::URI, $image->attr['src']);
$imageAlt = $image->attr['alt'];

$item['content'] = <<<EOD
<img src="{$imageUrl}" alt="{$imageAlt}"/>
<br/>
EOD;
$this->items[] = $item;
}
}

0 comments on commit e14f647

Please sign in to comment.