rss-bridge/bridges/MixologyBridge.php
Sebastian Wolf 74496e23aa
[MixologyBridge] add new bridge (#4331)
* [MixologyBridge] add new bridge

* [MixologyBridge] change invalid item property tags to categories

* [MixologyBridge] rewrite into FeedExpander

* [MixologyBridge] fix code formatting
2024-11-24 18:09:59 +01:00

49 lines
1.3 KiB
PHP

<?php
class MixologyBridge extends FeedExpander
{
const MAINTAINER = 'swofl';
const NAME = 'Mixology';
const URI = 'https://mixology.eu';
const CACHE_TIMEOUT = 6 * 60 * 60; // 6h
const DESCRIPTION = 'Get latest blog posts from Mixology';
const PARAMETERS = [ [
'limit' => self::LIMIT,
] ];
public function collectData()
{
$feed_url = self::URI . '/feed';
$limit = $this->getInput('limit') ?? 10;
$this->collectExpandableDatas($feed_url, $limit);
}
protected function parseItem(array $item)
{
$article = getSimpleHTMLDOMCached($item['uri']);
$content = '';
$headerImage = $article->find('div.edgtf-full-width img.wp-post-image', 0);
if (is_object($headerImage)) {
$item['enclosures'] = [];
$item['enclosures'][] = $headerImage->src;
$content .= '<img src="' . $headerImage->src . '"/>';
}
foreach ($article->find('article .wpb_content_element > .wpb_wrapper') as $element) {
$content .= $element->innertext;
}
$item['content'] = $content;
$item['categories'] = [];
foreach ($article->find('.edgtf-tags > a') as $tag) {
$item['categories'][] = $tag->plaintext;
}
return $item;
}
}