CpasbienBridge.php 2.0 KB

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