2015-04-28 19:28:49 +02:00
|
|
|
<?php
|
2016-09-05 18:43:56 +02:00
|
|
|
class CADBridge extends FeedExpander {
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = "nyutag";
|
|
|
|
const NAME = "CAD Bridge";
|
|
|
|
const URI = "http://www.cad-comic.com/";
|
2016-09-25 17:04:28 +02:00
|
|
|
const CACHE_TIMEOUT = 7200; //2h
|
2016-08-30 11:23:55 +02:00
|
|
|
const DESCRIPTION = "Returns the newest articles.";
|
2015-11-03 23:28:44 +01:00
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
public function collectData(){
|
2016-09-05 20:26:45 +02:00
|
|
|
$this->collectExpandableDatas('http://cdn2.cad-comic.com/rss.xml', 10);
|
2016-09-05 18:43:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function parseItem($newsItem){
|
2016-09-12 10:42:27 +02:00
|
|
|
$item = parent::parseItem($newsItem);
|
2016-09-05 18:43:56 +02:00
|
|
|
$item['content'] = $this->CADExtractContent($item['uri']);
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
2016-08-06 16:00:56 +02:00
|
|
|
private function CADExtractContent($url) {
|
2016-09-25 23:22:33 +02:00
|
|
|
$html3 = getSimpleHTMLDOMCached($url);
|
2016-08-02 14:07:40 +02:00
|
|
|
|
|
|
|
// The request might fail due to missing https support or wrong URL
|
|
|
|
if($html3 == false)
|
|
|
|
return 'Daily comic not released yet';
|
|
|
|
|
2015-05-06 09:53:21 +02:00
|
|
|
$htmlpart = explode("/", $url);
|
2016-08-02 14:13:22 +02:00
|
|
|
|
|
|
|
switch ($htmlpart[3]){
|
|
|
|
case 'cad':
|
|
|
|
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2);
|
|
|
|
break;
|
|
|
|
case 'sillies':
|
|
|
|
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/sillies-\S*gif/", $html3, $url2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 'Daily comic not released yet';
|
|
|
|
}
|
2015-04-28 19:28:49 +02:00
|
|
|
$img = implode ($url2[0]);
|
2015-05-06 09:53:21 +02:00
|
|
|
$html3->clear();
|
|
|
|
unset ($html3);
|
|
|
|
if ($img == '')
|
2016-08-02 14:07:40 +02:00
|
|
|
return 'Daily comic not released yet';
|
2015-05-06 09:53:21 +02:00
|
|
|
return '<img src="'.$img.'"/>';
|
2016-08-02 13:37:18 +02:00
|
|
|
}
|
2015-04-28 19:28:49 +02:00
|
|
|
}
|
2016-07-08 19:06:35 +02:00
|
|
|
?>
|