From 485a0dc2794d949f265b3efd0d6c444d9d116249 Mon Sep 17 00:00:00 2001 From: corenting Date: Wed, 27 Aug 2014 17:37:38 +0200 Subject: [PATCH 1/2] Add bridge for Project M --- bridges/ProjectMGameBridge.php | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 bridges/ProjectMGameBridge.php diff --git a/bridges/ProjectMGameBridge.php b/bridges/ProjectMGameBridge.php new file mode 100644 index 00000000..abc2b9c4 --- /dev/null +++ b/bridges/ProjectMGameBridge.php @@ -0,0 +1,47 @@ +returnError('Error while downloading the Project M homepage', 404); + + foreach($html->find('article') as $article) { + $item = new \Item(); + $item->uri = 'http://projectmgame.com/en/'.$article->find('section div.info_block a',0)->href; + $item->title = $article->find('h1 p',0)->innertext; + + $p_list = $article->find('section p'); + $content = ''; + foreach($p_list as $p) + { + $content .= $p->innertext; + } + $item->content = $content; + + // get publication date + $str_date = $article->find('section div.info_block a',0)->innertext; + $timestamp = strtotime($str_date); + $item->timestamp = $timestamp; + + $this->items[] = $item; + } + } + + public function getName(){ + return 'Project M Game Bridge'; + } + + public function getURI(){ + return 'http://projectmgame.com/en/'; + } + + public function getCacheDuration(){ + return 10800; + } +} From 9b86dfdb399098f3355ef66713ed6d61710c0f53 Mon Sep 17 00:00:00 2001 From: corenting Date: Wed, 27 Aug 2014 18:23:43 +0200 Subject: [PATCH 2/2] Minor things --- bridges/ProjectMGameBridge.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/bridges/ProjectMGameBridge.php b/bridges/ProjectMGameBridge.php index abc2b9c4..e8dc05cc 100644 --- a/bridges/ProjectMGameBridge.php +++ b/bridges/ProjectMGameBridge.php @@ -7,6 +7,7 @@ * @maintainer corenting */ class ProjectMGameBridge extends BridgeAbstract{ + public function collectData(array $param){ $html = ''; $html = file_get_html('http://projectmgame.com/en/') or $this->returnError('Error while downloading the Project M homepage', 404); @@ -18,17 +19,12 @@ class ProjectMGameBridge extends BridgeAbstract{ $p_list = $article->find('section p'); $content = ''; - foreach($p_list as $p) - { - $content .= $p->innertext; - } + foreach($p_list as $p) $content .= $p->innertext; $item->content = $content; // get publication date $str_date = $article->find('section div.info_block a',0)->innertext; - $timestamp = strtotime($str_date); - $item->timestamp = $timestamp; - + $item->timestamp = strtotime($str_date); $this->items[] = $item; } } @@ -42,6 +38,6 @@ class ProjectMGameBridge extends BridgeAbstract{ } public function getCacheDuration(){ - return 10800; + return 10800; //3 hours } }