2015-05-18 12:01:13 +02:00
|
|
|
<?php
|
2015-05-20 21:47:58 +02:00
|
|
|
class CpasbienBridge extends HttpCachingBridgeAbstract{
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2015-12-06 15:55:47 +01:00
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = "lagaisse";
|
|
|
|
$this->name = "Cpasbien Bridge";
|
2016-01-26 18:39:05 +01:00
|
|
|
$this->uri = "http://www.cpasbien.io";
|
|
|
|
$this->description = "Returns latest torrents from a request query";
|
2015-12-06 15:55:47 +01:00
|
|
|
|
2016-08-22 01:25:56 +02:00
|
|
|
$this->parameters[] = array(
|
|
|
|
'q'=>array(
|
|
|
|
'name'=>'Search',
|
|
|
|
'required'=>true,
|
|
|
|
'title'=>'Type your search'
|
|
|
|
)
|
|
|
|
);
|
2015-12-06 15:55:47 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData(){
|
|
|
|
$param=$this->parameters[$this->queriedContext];
|
2015-05-18 12:01:13 +02:00
|
|
|
$html = '';
|
2016-08-25 01:24:53 +02:00
|
|
|
if (isset($param['q']['value'])) { /* keyword search mode */
|
2016-08-25 17:11:49 +02:00
|
|
|
$request = str_replace(" ","-",trim($param['q']['value']));
|
|
|
|
$html = $this->getSimpleHTMLDOM($this->uri.'/recherche/'.urlencode($request).'.html') or $this->returnServerError('No results for this query.');
|
|
|
|
} else {
|
2016-08-17 14:45:08 +02:00
|
|
|
$this->returnClientError('You must specify a keyword (?q=...).');
|
2015-05-18 12:01:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($html->find('#gauche',0)->find('div') as $episode) {
|
|
|
|
if ($episode->getAttribute('class')=='ligne0' || $episode->getAttribute('class')=='ligne1')
|
|
|
|
{
|
2016-07-08 19:06:35 +02:00
|
|
|
|
2016-08-25 00:11:24 +02:00
|
|
|
$htmlepisode=str_get_html($this->get_cached($episode->find('a', 0)->getAttribute('href')));
|
2015-05-18 12:01:13 +02:00
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
|
|
|
$item['author'] = $episode->find('a', 0)->text();
|
|
|
|
$item['title'] = $episode->find('a', 0)->text();
|
|
|
|
$item['timestamp'] = $this->get_cached_time($episode->find('a', 0)->getAttribute('href'));
|
2015-05-20 21:47:58 +02:00
|
|
|
$textefiche=$htmlepisode->find('#textefiche', 0)->find('p',1);
|
|
|
|
if (isset($textefiche)) {
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['content'] = $textefiche->text();
|
2016-08-25 17:11:49 +02:00
|
|
|
} else {
|
2016-08-25 00:12:33 +02:00
|
|
|
$p=$htmlepisode->find('#textefiche',0)->find('p');
|
|
|
|
if(!empty($p)){
|
|
|
|
$item['content'] = $htmlepisode->find('#textefiche', 0)->find('p',0)->text();
|
|
|
|
}
|
2015-05-18 12:01:13 +02:00
|
|
|
}
|
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item['id'] = $episode->find('a', 0)->getAttribute('href');
|
|
|
|
$item['uri'] = $this->uri . $htmlepisode->find('#telecharger',0)->getAttribute('href');
|
2015-05-18 12:01:13 +02:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getName(){
|
2016-08-25 17:11:49 +02:00
|
|
|
return $this->parameters[$this->queriedContext]['q']['value']
|
|
|
|
.' : '.$this->name;
|
2015-05-18 12:01:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 60*60*24; // 24 hours
|
|
|
|
}
|
|
|
|
}
|