forked from blallo/rss-bridge
f1fb95b257
- returnError, returnServerError, returnClientError ,debugMessage are moved to lib/error.php - getContents, getSimpleHTMLDOM, getSimpleHTMLDOMCached are moved to lib/contents.php Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
class DilbertBridge extends BridgeAbstract {
|
|
|
|
const MAINTAINER = 'kranack';
|
|
const NAME = 'Dilbert Daily Strip';
|
|
const URI = 'http://dilbert.com';
|
|
const DESCRIPTION = 'The Unofficial Dilbert Daily Comic Strip';
|
|
|
|
public function collectData(){
|
|
|
|
$html = getSimpleHTMLDOM($this->getURI()) or 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
|
|
}
|
|
}
|
|
?>
|