From 421c47d9eda45d3b955bb1d0e3f104176a4ff600 Mon Sep 17 00:00:00 2001 From: corenting Date: Wed, 6 Apr 2016 15:13:09 +0100 Subject: [PATCH] Added bridge for Elite: Dangerous Galnet --- bridges/EliteDangerousGalnetBridge.php | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 bridges/EliteDangerousGalnetBridge.php diff --git a/bridges/EliteDangerousGalnetBridge.php b/bridges/EliteDangerousGalnetBridge.php new file mode 100644 index 00000000..72748b9c --- /dev/null +++ b/bridges/EliteDangerousGalnetBridge.php @@ -0,0 +1,53 @@ + +maintainer = "corenting"; + $this->name = "Elite: Dangerous Galnet"; + $this->uri = "https://community.elitedangerous.com/galnet"; + $this->description = "Returns the latest page of news from Galnet"; + $this->update = "2016-04-06"; + } + + public function collectData(array $param) + { + $html = file_get_html('https://community.elitedangerous.com/galnet') or $this->returnError('Error while downloading the website content', 404); + foreach($html->find('div.article') as $element) { + $item = new Item(); + + $uri = $element->find('h3 a', 0)->href; + $uri = 'https://community.elitedangerous.com' . $uri; + $item->uri = $uri; + + $title = $element->find('h3 a', 0)->plaintext; + $item->title = substr($title, 1); //remove the space between icon and title + + $content = $element->find('p', -1)->innertext; + $item->content = $content; + + $date = $element->find('p.small', 0)->innertext; + $article_year = substr($date, -4) - 1286; //Convert E:D date to actual date + $date = substr($date, 0, -4) . $article_year; + $item->timestamp = strtotime($date); + + $this->items[] = $item; + } + } + + public function getName() + { + return 'Elite: Dangerous Galnet'; + } + + public function getURI() + { + return 'https://community.elitedangerous.com/galnet'; + } + + public function getCacheDuration() + { + return 3600 * 2; // 2 hours + } +} \ No newline at end of file