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