2015-05-18 13:01:13 +03:00
|
|
|
<?php
|
2016-09-10 20:11:09 +03:00
|
|
|
class CpasbienBridge extends BridgeAbstract {
|
2016-07-08 20:06:35 +03:00
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const MAINTAINER = "lagaisse";
|
|
|
|
const NAME = "Cpasbien Bridge";
|
|
|
|
const URI = "http://www.cpasbien.io";
|
|
|
|
const DESCRIPTION = "Returns latest torrents from a request query";
|
2015-12-06 17:55:47 +03:00
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 22:03:26 +03:00
|
|
|
'q'=>array(
|
2016-08-22 02:25:56 +03:00
|
|
|
'name'=>'Search',
|
|
|
|
'required'=>true,
|
|
|
|
'title'=>'Type your search'
|
2016-08-27 22:03:26 +03:00
|
|
|
)
|
|
|
|
));
|
2015-12-06 17:55:47 +03:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2016-08-28 14:17:28 +03:00
|
|
|
$request = str_replace(" ","-",trim($this->getInput('q')));
|
2016-08-30 12:23:55 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM(self::URI.'/recherche/'.urlencode($request).'.html')
|
2016-08-28 14:17:28 +03:00
|
|
|
or $this->returnServerError('No results for this query.');
|
2015-05-18 13:01:13 +03:00
|
|
|
|
|
|
|
foreach ($html->find('#gauche',0)->find('div') as $episode) {
|
2016-08-28 14:17:28 +03:00
|
|
|
if ($episode->getAttribute('class')=='ligne0' ||
|
|
|
|
$episode->getAttribute('class')=='ligne1')
|
2015-05-18 13:01:13 +03:00
|
|
|
{
|
2016-09-10 20:11:09 +03:00
|
|
|
$htmlepisode=$this->getSimpleHTMLDOMCached($episode->find('a', 0)->getAttribute('href'));
|
2015-05-18 13:01:13 +03:00
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item = array();
|
|
|
|
$item['author'] = $episode->find('a', 0)->text();
|
|
|
|
$item['title'] = $episode->find('a', 0)->text();
|
2015-05-20 22:47:58 +03:00
|
|
|
$textefiche=$htmlepisode->find('#textefiche', 0)->find('p',1);
|
|
|
|
if (isset($textefiche)) {
|
2016-08-22 19:55:59 +03:00
|
|
|
$item['content'] = $textefiche->text();
|
2016-08-25 18:11:49 +03:00
|
|
|
} else {
|
2016-08-25 01:12:33 +03:00
|
|
|
$p=$htmlepisode->find('#textefiche',0)->find('p');
|
|
|
|
if(!empty($p)){
|
|
|
|
$item['content'] = $htmlepisode->find('#textefiche', 0)->find('p',0)->text();
|
|
|
|
}
|
2015-05-18 13:01:13 +03:00
|
|
|
}
|
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item['id'] = $episode->find('a', 0)->getAttribute('href');
|
2016-08-30 12:23:55 +03:00
|
|
|
$item['uri'] = self::URI . $htmlepisode->find('#telecharger',0)->getAttribute('href');
|
2015-05-18 13:01:13 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getName(){
|
2016-08-30 12:23:55 +03:00
|
|
|
return $this->getInput('q').' : '.self::NAME;
|
2015-05-18 13:01:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 60*60*24; // 24 hours
|
|
|
|
}
|
|
|
|
}
|