ScmbBridge.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. class ScmbBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "Astalaseven";
  5. $this->name = "Se Coucher Moins Bête Bridge";
  6. $this->uri = "http://secouchermoinsbete.fr/";
  7. $this->description = "Returns the newest anecdotes.";
  8. }
  9. public function collectData(array $param){
  10. $html = '';
  11. $html = $this->getSimpleHTMLDOM('http://secouchermoinsbete.fr/') or $this->returnServerError('Could not request Se Coucher Moins Bete.');
  12. foreach($html->find('article') as $article) {
  13. $item = array();
  14. $item['uri'] = 'http://secouchermoinsbete.fr'.$article->find('p.summary a',0)->href;
  15. $item['title'] = $article->find('header h1 a',0)->innertext;
  16. $article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content
  17. $content = $article->find('p.summary a',0)->innertext;
  18. $content =substr($content,0,strlen($content)-17); // remove superfluous spaces at the end
  19. // get publication date
  20. $str_date = $article->find('time',0)->datetime;
  21. list($date, $time) = explode(' ', $str_date);
  22. list($y, $m, $d) = explode('-', $date);
  23. list($h, $i) = explode(':', $time);
  24. $timestamp = mktime($h,$i,0,$m,$d,$y);
  25. $item['timestamp'] = $timestamp;
  26. $item['content'] = $content;
  27. $this->items[] = $item;
  28. }
  29. }
  30. public function getCacheDuration(){
  31. return 21600; // 6 hours
  32. }
  33. }