ProjectMGameBridge.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * 2014-08-27
  4. * @name Project M Game Bridge
  5. * @homepage http://projectmgame.com/en/
  6. * @description Returns the newest articles.
  7. * @maintainer corenting
  8. */
  9. class ProjectMGameBridge extends BridgeAbstract{
  10. public function collectData(array $param){
  11. $html = '';
  12. $html = file_get_html('http://projectmgame.com/en/') or $this->returnError('Error while downloading the Project M homepage', 404);
  13. foreach($html->find('article') as $article) {
  14. $item = new \Item();
  15. $item->uri = 'http://projectmgame.com/en/'.$article->find('section div.info_block a',0)->href;
  16. $item->title = $article->find('h1 p',0)->innertext;
  17. $p_list = $article->find('section p');
  18. $content = '';
  19. foreach($p_list as $p) $content .= $p->innertext;
  20. $item->content = $content;
  21. // get publication date
  22. $str_date = $article->find('section div.info_block a',0)->innertext;
  23. $item->timestamp = strtotime($str_date);
  24. $this->items[] = $item;
  25. }
  26. }
  27. public function getName(){
  28. return 'Project M Game Bridge';
  29. }
  30. public function getURI(){
  31. return 'http://projectmgame.com/en/';
  32. }
  33. public function getCacheDuration(){
  34. return 10800; //3 hours
  35. }
  36. }