forked from RSS-Bridge/rss-bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DRKBlutspendeBridge] add new bridge
- Loading branch information
1 parent
dd165ea
commit 0b526bf
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
class DRKBlutspendeBridge extends FeedExpander | ||
{ | ||
const MAINTAINER = 'User123698745'; | ||
const NAME = 'DRK-Blutspende'; | ||
const URI = 'https://www.drk-blutspende.de'; | ||
const CACHE_TIMEOUT = 60 * 60 * 1; // 1 hour | ||
const DESCRIPTION = 'German Red Cross (Deutsches Rotes Kreuz) blood donation service feed with more details'; | ||
const PARAMETERS = [ | ||
'Termine' => [ | ||
'term' => [ | ||
'name' => 'PLZ / Ort', | ||
'required' => true, | ||
'exampleValue' => '12555', | ||
], | ||
'radius' => [ | ||
'name' => 'Umkreis in km', | ||
'type' => 'number', | ||
'exampleValue' => 10, | ||
], | ||
'limit_days' => [ | ||
'name' => 'Limit von Tagen', | ||
'title' => 'Nur Termine innerhalb der nächsten x Tagen', | ||
'type' => 'number', | ||
'exampleValue' => 28, | ||
], | ||
'limit_items' => [ | ||
'name' => 'Limit von Terminen', | ||
'title' => 'Nicht mehr als x Termine', | ||
'type' => 'number', | ||
'required' => true, | ||
'defaultValue' => 20, | ||
] | ||
] | ||
]; | ||
|
||
public function collectData() | ||
{ | ||
$term = $this->getInput('term') ?? ''; | ||
$radius = $this->getInput('radius') ?? ''; | ||
$limitDays = intval($this->getInput('limit_days')); | ||
$dateTo = $limitDays > 0 ? date('Y-m-d', time() + (60 * 60 * 24 * $limitDays)) : ''; | ||
$url = self::URI . '/blutspendetermine/termine.rss?date_to=' . $dateTo . '&radius=' . $radius . '&term=' . $term; | ||
$limitItems = intval($this->getInput('limit_items')); | ||
$this->collectExpandableDatas($url, $limitItems); | ||
} | ||
|
||
protected function parseItem(array $item) | ||
{ | ||
$html = getSimpleHTMLDOM($item['uri']); | ||
|
||
$detailsElement = $html->find('.details', 0); | ||
|
||
$dateElement = $detailsElement->find('.datum', 0); | ||
$dateLines = explode_lines($dateElement->plaintext); | ||
|
||
$addressElement = $detailsElement->find('.adresse', 0); | ||
$addressLines = explode_lines($addressElement->plaintext); | ||
|
||
$infoElement = $detailsElement->find('.angebote > h4 + p', 0); | ||
$info = $infoElement ? $infoElement->innertext : ''; | ||
|
||
$imageElements = $detailsElement->find('.fotos img'); | ||
|
||
$item['title'] = $dateLines[0] . ' ' . $dateLines[1] . ' ' . $addressLines[0] . ' - ' . $addressLines[1]; | ||
|
||
$item['content'] = <<<HTML | ||
<p><b>{$dateLines[0]} {$dateLines[1]}</b></p> | ||
<p>{$addressElement->innertext}</p> | ||
<p>{$info}</p> | ||
HTML; | ||
|
||
foreach ($imageElements as $imageElement) { | ||
$src = $imageElement->getAttribute('src'); | ||
$item['content'] .= <<<HTML | ||
<p><img src="{$src}"></p> | ||
HTML; | ||
} | ||
|
||
$item['description'] = null; | ||
|
||
return $item; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters