mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-23 01:55:27 +03:00
[Dilbert] Update field retrieval
This commit is contained in:
parent
a04d7ba8eb
commit
8a00c9d407
1 changed files with 14 additions and 15 deletions
|
@ -3,44 +3,43 @@ 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";
|
||||
$this->update = "14/02/2016";
|
||||
$this->maintainer = 'kranack';
|
||||
$this->name = $this->getName();
|
||||
$this->uri = $this->getURI();
|
||||
$this->description = $this->getDescription();
|
||||
$this->update = "14/05/2016";
|
||||
|
||||
}
|
||||
|
||||
public function collectData(array $param) {
|
||||
|
||||
$html = file_get_html('http://dilbert.com/') or $this->returnError('Could not request Dilbert.', 500);
|
||||
$html = file_get_html($this->getURI()) or $this->returnError('Could not request Dilbert: '.$this->getURI(), 500);
|
||||
|
||||
foreach ($html->find('section.comic-item') as $element) {
|
||||
|
||||
$img = $element->find('img', 0);
|
||||
$link = $element->find('a', 0);
|
||||
$comic = $img->src;
|
||||
$title = $img->alt;
|
||||
$url = $element->find('a', 0)->href;
|
||||
$author = trim(substr($title, strpos($title, ' - Dilbert by ') + 14));
|
||||
$title = trim(substr($title, 0, strpos($title, ' - ')));
|
||||
$title = $link->alt;
|
||||
$url = $link->href;
|
||||
$date = substr($url, 25);
|
||||
if (empty($title))
|
||||
$title = "Dilbert Comic Strip on ".$date;
|
||||
$title = 'Dilbert Comic Strip on '.$date;
|
||||
$date = strtotime($date);
|
||||
|
||||
$item = new \Item();
|
||||
$item->uri = $url;
|
||||
$item->thumbnailUri = $comic;
|
||||
$item->title = $title;
|
||||
$item->author = $author;
|
||||
$item->author = 'Scott Adams';
|
||||
$item->timestamp = $date;
|
||||
$item->content = '<img src="'.$comic.'" alt="'.$title.'" />';
|
||||
$item->content = '<img src="'.$comic.'" alt="'.$img->alt.'" />';
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return 'Dilbert Bridge';
|
||||
return 'Dilbert Daily Strip';
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
|
@ -48,7 +47,7 @@ class DilbertBridge extends BridgeAbstract {
|
|||
}
|
||||
|
||||
public function getDescription() {
|
||||
return 'Dilbert Daily Strip Bridge';
|
||||
return 'The Unofficial Dilbert Daily Comic Strip';
|
||||
}
|
||||
|
||||
public function getCacheDuration() {
|
||||
|
|
Loading…
Reference in a new issue