CpasbienBridge.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. class CpasbienBridge extends BridgeAbstract {
  3. const MAINTAINER = "lagaisse";
  4. const NAME = "Cpasbien Bridge";
  5. const URI = "http://www.cpasbien.io";
  6. const CACHE_TIMEOUT = 86400; // 24h
  7. const DESCRIPTION = "Returns latest torrents from a request query";
  8. const PARAMETERS = array( array(
  9. 'q'=>array(
  10. 'name'=>'Search',
  11. 'required'=>true,
  12. 'title'=>'Type your search'
  13. )
  14. ));
  15. public function collectData(){
  16. $request = str_replace(" ","-",trim($this->getInput('q')));
  17. $html = getSimpleHTMLDOM(self::URI.'/recherche/'.urlencode($request).'.html')
  18. or returnServerError('No results for this query.');
  19. foreach ($html->find('#gauche',0)->find('div') as $episode) {
  20. if ($episode->getAttribute('class')=='ligne0' ||
  21. $episode->getAttribute('class')=='ligne1')
  22. {
  23. $htmlepisode=getSimpleHTMLDOMCached($episode->find('a', 0)->getAttribute('href'));
  24. $item = array();
  25. $item['author'] = $episode->find('a', 0)->text();
  26. $item['title'] = $episode->find('a', 0)->text();
  27. $textefiche=$htmlepisode->find('#textefiche', 0)->find('p',1);
  28. if (isset($textefiche)) {
  29. $item['content'] = $textefiche->text();
  30. } else {
  31. $p=$htmlepisode->find('#textefiche',0)->find('p');
  32. if(!empty($p)){
  33. $item['content'] = $htmlepisode->find('#textefiche', 0)->find('p',0)->text();
  34. }
  35. }
  36. $item['id'] = $episode->find('a', 0)->getAttribute('href');
  37. $item['uri'] = self::URI . $htmlepisode->find('#telecharger',0)->getAttribute('href');
  38. $this->items[] = $item;
  39. }
  40. }
  41. }
  42. public function getName(){
  43. return $this->getInput('q').' : '.self::NAME;
  44. }
  45. }