mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-27 20:12:11 +03:00
3c0d13c1bb
instead of BridgeAbstract::file_get_html Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
|
|
<?php
|
|
class EliteDangerousGalnetBridge extends BridgeAbstract
|
|
{
|
|
public function loadMetadatas()
|
|
{
|
|
$this->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-08-17';
|
|
}
|
|
|
|
public function collectData(array $param)
|
|
{
|
|
$html = $this->getSimpleHTMLDOM('https://community.elitedangerous.com/galnet') or $this->returnServerError('Error while downloading the website content');
|
|
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 getCacheDuration()
|
|
{
|
|
return 3600 * 2; // 2 hours
|
|
}
|
|
}
|