Skip to content

Commit

Permalink
[MixologyBridge] add new bridge (RSS-Bridge#4331)
Browse files Browse the repository at this point in the history
* [MixologyBridge] add new bridge

* [MixologyBridge] change invalid item property tags to categories

* [MixologyBridge] rewrite into FeedExpander

* [MixologyBridge] fix code formatting
  • Loading branch information
swofl authored Nov 24, 2024
1 parent 83bc3fd commit 74496e2
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions bridges/MixologyBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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;
}
}

0 comments on commit 74496e2

Please sign in to comment.