mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-24 02:16:08 +03:00
Add WorldbankBridge and OglafBridge (#3862)
* Add WorldbankBridge and OglafBridge * Update OglafBridge.php Remove redundant parent call to parseItem and rename formal argument to improve code clarity. * Update WorldbankBridge.php fix lint
This commit is contained in:
parent
c8178e1fc4
commit
5ab1924c4f
2 changed files with 87 additions and 0 deletions
35
bridges/OglafBridge.php
Normal file
35
bridges/OglafBridge.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
class OglafBridge extends FeedExpander
|
||||
{
|
||||
const NAME = 'Oglaf';
|
||||
const URI = 'https://www.oglaf.com/';
|
||||
const DESCRIPTION = 'Fetch the entire comic image';
|
||||
const MAINTAINER = 'tillcash';
|
||||
const PARAMETERS = [
|
||||
[
|
||||
'limit' => [
|
||||
'name' => 'limit (max 20)',
|
||||
'type' => 'number',
|
||||
'defaultValue' => 10,
|
||||
'required' => true,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$url = self::URI . 'feeds/rss/';
|
||||
$limit = min(20, $this->getInput('limit'));
|
||||
$this->collectExpandableDatas($url, $limit);
|
||||
}
|
||||
|
||||
protected function parseItem($item)
|
||||
{
|
||||
$html = getSimpleHTMLDOMCached($item['uri']);
|
||||
$comicImage = $html->find('img[id="strip"]', 0);
|
||||
$item['content'] = $comicImage;
|
||||
|
||||
return $item;
|
||||
}
|
||||
}
|
52
bridges/WorldbankBridge.php
Normal file
52
bridges/WorldbankBridge.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
class WorldbankBridge extends BridgeAbstract
|
||||
{
|
||||
const NAME = 'World Bank Group';
|
||||
const URI = 'https://www.worldbank.org/en/news/all';
|
||||
const DESCRIPTION = 'Return articles from The World Bank Group All News';
|
||||
const MAINTAINER = 'tillcash';
|
||||
const PARAMETERS = [
|
||||
[
|
||||
'lang' => [
|
||||
'name' => 'Language',
|
||||
'type' => 'list',
|
||||
'defaultValue' => 'English',
|
||||
'values' => [
|
||||
'English' => 'English',
|
||||
'French' => 'French',
|
||||
]
|
||||
],
|
||||
'limit' => [
|
||||
'name' => 'limit (max 100)',
|
||||
'type' => 'number',
|
||||
'defaultValue' => 5,
|
||||
'required' => true,
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$apiUrl = 'https://search.worldbank.org/api/v2/news?format=json&rows='
|
||||
. min(100, $this->getInput('limit'))
|
||||
. '&lang_exact=' . $this->getInput('lang');
|
||||
|
||||
$jsonData = json_decode(getContents($apiUrl));
|
||||
|
||||
// Remove unnecessary data from the original object
|
||||
if (isset($jsonData->documents->facets)) {
|
||||
unset($jsonData->documents->facets);
|
||||
}
|
||||
|
||||
foreach ($jsonData->documents as $element) {
|
||||
$this->items[] = [
|
||||
'uid' => $element->id,
|
||||
'timestamp' => $element->lnchdt,
|
||||
'title' => $element->title->{'cdata!'},
|
||||
'uri' => $element->url,
|
||||
'content' => $element->descr->{'cdata!'},
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue