mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-27 03:50:42 +03:00
117031bf0f
This way, any BridgeAbstract method can now have access to these values, no only collectData Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
class DilbertBridge extends BridgeAbstract {
|
|
|
|
public function loadMetadatas() {
|
|
|
|
$this->maintainer = 'kranack';
|
|
$this->name = 'Dilbert Daily Strip';
|
|
$this->uri = 'http://dilbert.com';
|
|
$this->description = 'The Unofficial Dilbert Daily Comic Strip';
|
|
|
|
}
|
|
|
|
public function collectData(){
|
|
|
|
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request Dilbert: '.$this->getURI());
|
|
|
|
foreach ($html->find('section.comic-item') as $element) {
|
|
|
|
$img = $element->find('img', 0);
|
|
$link = $element->find('a', 0);
|
|
$comic = $img->src;
|
|
$title = $link->alt;
|
|
$url = $link->href;
|
|
$date = substr($url, 25);
|
|
if (empty($title))
|
|
$title = 'Dilbert Comic Strip on '.$date;
|
|
$date = strtotime($date);
|
|
|
|
$item = array();
|
|
$item['uri'] = $url;
|
|
$item['title'] = $title;
|
|
$item['author'] = 'Scott Adams';
|
|
$item['timestamp'] = $date;
|
|
$item['content'] = '<img src="'.$comic.'" alt="'.$img->alt.'" />';
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
|
|
public function getCacheDuration() {
|
|
return 21600; // 6 hours
|
|
}
|
|
}
|
|
?>
|