From 74496e23aaa9101ac718a3b12dafa4206921932c Mon Sep 17 00:00:00 2001 From: Sebastian Wolf <117176763+swofl@users.noreply.github.com> Date: Sun, 24 Nov 2024 18:09:59 +0100 Subject: [PATCH] [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 --- bridges/MixologyBridge.php | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 bridges/MixologyBridge.php diff --git a/bridges/MixologyBridge.php b/bridges/MixologyBridge.php new file mode 100644 index 00000000000..1246b4dbe4c --- /dev/null +++ b/bridges/MixologyBridge.php @@ -0,0 +1,49 @@ + 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 .= ''; + } + + 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; + } +}