aboutsummaryrefslogtreecommitdiff
path: root/bridges/MixologyBridge.php
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2025-03-02 19:32:33 -0800
committerGravatar GitHub <noreply@github.com> 2025-03-02 19:32:33 -0800
commit8b16dd20f6544af3eedf286e23c0d34ab525736c (patch)
treeec284e22a046c4c8e9626e3fa64a000a2747bf84 /bridges/MixologyBridge.php
parentb183aa798af48af556496c42780d6e844172cf44 (diff)
parent00a24e2f694a319a5e6cb070dddfff2dae892378 (diff)
downloadrss-bridge-master.tar.gz
rss-bridge-master.tar.zst
rss-bridge-master.zip
Merge branch 'RSS-Bridge:master' into masterHEADmaster
Diffstat (limited to 'bridges/MixologyBridge.php')
-rw-r--r--bridges/MixologyBridge.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/bridges/MixologyBridge.php b/bridges/MixologyBridge.php
new file mode 100644
index 00000000..42192471
--- /dev/null
+++ b/bridges/MixologyBridge.php
@@ -0,0 +1,80 @@
+<?php
+
+class MixologyBridge extends BridgeAbstract
+{
+ 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';
+
+ public function collectData()
+ {
+ $html = getSimpleHTMLDOM(self::URI);
+
+ $teasers = [];
+ $teaserElements = [];
+
+ $teaserElements[] = $html->find('.aufmacher .views-view-responsive-grid__item-inner', 0);
+ foreach ($html->find('.block-views-blockmixology-frontpage-block-2 .views-col') as $teaser) {
+ $teaserElements[] = $teaser;
+ }
+
+ foreach ($teaserElements as $teaser) {
+ $teasers[] = $this->parseTeaser($teaser);
+ }
+
+ foreach ($teasers as $article) {
+ $this->items[] = $this->parseItem($article);
+ }
+ }
+
+ protected function parseTeaser($teaser)
+ {
+ $result = [];
+
+ $title = $teaser->find('.views-field-title a', 0);
+ $result['title'] = $title->plaintext;
+ $result['uri'] = self::URI . $title->href;
+ $result['enclosures'] = [];
+ $result['enclosures'][] = self::URI . $teaser->find('img', 0)->src;
+ $result['uid'] = hash('sha256', $result['title']);
+
+ $categories = $teaser->find('.views-field-field-kategorie', 0);
+ if ($categories) {
+ $result['categories'] = [];
+ foreach ($categories->find('a') as $category) {
+ $result['categories'][] = $category->innertext;
+ }
+ }
+
+ return $result;
+ }
+
+ protected function parseItem(array $item)
+ {
+ $article = getSimpleHTMLDOMCached($item['uri']);
+
+ $authorLink = $article->find('.beitrag-author a', 0);
+ if (!empty($authorLink)) {
+ $item['author'] = $authorLink->plaintext;
+ }
+
+ $timeElement = $article->find('.beitrag-date time', 0);
+ if (!empty($timeElement)) {
+ $item['timestamp'] = strtotime($timeElement->datetime);
+ }
+
+ $content = '';
+
+ $content .= '<img src="' . $item['enclosures'][0] . '"/>';
+
+ foreach ($article->find('article .wpb_content_element>.wpb_wrapper, article .field--type-text-with-summary>.wp-block-columns>.wp-block-column') as $element) {
+ $content .= $element->innertext;
+ }
+
+ $item['content'] = $content;
+
+ return $item;
+ }
+}