mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[PresidenciaPTBridge]: Support multiple sections (#2082)
This commit is contained in:
parent
63ebf5ceec
commit
e79a02ac2e
@ -2,8 +2,32 @@
|
|||||||
class PresidenciaPTBridge extends BridgeAbstract {
|
class PresidenciaPTBridge extends BridgeAbstract {
|
||||||
const NAME = 'Presidência da República Portuguesa';
|
const NAME = 'Presidência da República Portuguesa';
|
||||||
const URI = 'https://www.presidencia.pt';
|
const URI = 'https://www.presidencia.pt';
|
||||||
const DESCRIPTION = 'Presidência da República Portuguesa | Mensagens';
|
const DESCRIPTION = 'Presidência da República Portuguesa';
|
||||||
const MAINTAINER = 'somini';
|
const MAINTAINER = 'somini';
|
||||||
|
const PARAMETERS = array(
|
||||||
|
'Section' => array(
|
||||||
|
'/atualidade/noticias' => array(
|
||||||
|
'name' => 'Notícias',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'defaultValue' => 'checked',
|
||||||
|
),
|
||||||
|
'/atualidade/mensagens' => array(
|
||||||
|
'name' => 'Mensagens',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'defaultValue' => 'checked',
|
||||||
|
),
|
||||||
|
'/atualidade/atividade-legislativa' => array(
|
||||||
|
'name' => 'Atividade Legislativa',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'defaultValue' => 'checked',
|
||||||
|
),
|
||||||
|
'/atualidade/notas-informativas' => array(
|
||||||
|
'name' => 'Notas Informativas',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'defaultValue' => 'checked',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const PT_MONTH_NAMES = array(
|
const PT_MONTH_NAMES = array(
|
||||||
'janeiro',
|
'janeiro',
|
||||||
@ -19,27 +43,35 @@ class PresidenciaPTBridge extends BridgeAbstract {
|
|||||||
'novembro',
|
'novembro',
|
||||||
'dezembro');
|
'dezembro');
|
||||||
|
|
||||||
|
public function getIcon(){
|
||||||
|
return 'https://www.presidencia.pt/Theme/favicon/apple-touch-icon.png';
|
||||||
|
}
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
$html = getSimpleHTMLDOM($this->getURI() . '/atualidade/mensagens')
|
foreach(array_keys($this->getParameters()['Section']) as $k) {
|
||||||
or returnServerError('Could not load content');
|
Debug::log('Key: ' . var_export($k, true));
|
||||||
|
if($this->getInput($k)) {
|
||||||
|
$html = getSimpleHTMLDOMCached($this->getURI() . $k);
|
||||||
|
|
||||||
foreach($html->find('#atualidade-list article.card-block') as $element) {
|
foreach($html->find('#atualidade-list article.card-block') as $element) {
|
||||||
$item = array();
|
$item = array();
|
||||||
|
|
||||||
$link = $element->find('a', 0);
|
$link = $element->find('a', 0);
|
||||||
$etitle = $link->find('h2', 0);
|
$etitle = $element->find('.content-box h2', 0);
|
||||||
$edts = $element->find('p', 1);
|
$edts = $element->find('p', 1);
|
||||||
$edt = html_entity_decode($edts->innertext, ENT_HTML5);
|
$edt = html_entity_decode($edts->innertext, ENT_HTML5);
|
||||||
|
|
||||||
$item['title'] = $etitle->innertext;
|
$item['title'] = strip_tags($etitle->innertext);
|
||||||
$item['uri'] = self::URI . $link->href;
|
$item['uri'] = self::URI . $link->href;
|
||||||
$item['description'] = $element;
|
$item['description'] = $element;
|
||||||
$item['timestamp'] = str_ireplace(
|
$item['timestamp'] = str_ireplace(
|
||||||
array_map(function($name) { return ' de ' . $name . ' de '; }, self::PT_MONTH_NAMES),
|
array_map(function($name) { return ' de ' . $name . ' de '; }, self::PT_MONTH_NAMES),
|
||||||
array_map(function($num) { return sprintf('-%02d-', $num); }, range(1, sizeof(self::PT_MONTH_NAMES))),
|
array_map(function($num) { return sprintf('-%02d-', $num); }, range(1, sizeof(self::PT_MONTH_NAMES))),
|
||||||
$edt);
|
$edt);
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user