ProjectMGameBridge.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. class ProjectMGameBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "corenting";
  5. $this->name = "Project M Game Bridge";
  6. $this->uri = "http://projectmgame.com/en/";
  7. $this->description = "Returns the newest articles.";
  8. $this->update = "2014-08-27";
  9. }
  10. public function collectData(array $param){
  11. $html = '';
  12. $html = $this->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. }