mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-12-03 17:10:57 +03:00
f3f33cabed
* [EliteDangerousGalnetBridge] Add support for others website languages * [EliteDangerousGalnetBridge] Fix post title
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
class EliteDangerousGalnetBridge extends BridgeAbstract {
|
|
|
|
const MAINTAINER = 'corenting';
|
|
const NAME = 'Elite: Dangerous Galnet';
|
|
const URI = 'https://community.elitedangerous.com/galnet/';
|
|
const CACHE_TIMEOUT = 7200; // 2h
|
|
const DESCRIPTION = 'Returns the latest page of news from Galnet';
|
|
const PARAMETERS = array(
|
|
array(
|
|
'language' => array(
|
|
'name' => 'Language',
|
|
'type' => 'list',
|
|
'values' => array(
|
|
'English' => 'en',
|
|
'French' => 'fr',
|
|
'German' => 'de'
|
|
),
|
|
'defaultValue' => 'en'
|
|
)
|
|
)
|
|
);
|
|
|
|
public function collectData(){
|
|
$language = $this->getInput('language');
|
|
$url = 'https://community.elitedangerous.com/';
|
|
$url = $url . $language . '/galnet';
|
|
$html = getSimpleHTMLDOM($url)
|
|
or returnServerError('Error while downloading the website content');
|
|
|
|
foreach($html->find('div.article') as $element) {
|
|
$item = array();
|
|
|
|
$uri = $element->find('h3 a', 0)->href;
|
|
$uri = 'https://community.elitedangerous.com/' . $language . $uri;
|
|
$item['uri'] = $uri;
|
|
|
|
$item['title'] = $element->find('h3 a', 0)->plaintext;
|
|
|
|
$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;
|
|
}
|
|
}
|
|
}
|