From 03aade9703989f8a5a1287941d591795f0ea7fc4 Mon Sep 17 00:00:00 2001 From: Scrub000 Date: Tue, 3 Jun 2025 19:58:56 +1000 Subject: [PATCH] [TheAustraliaInstituteBridge] Add bridge --- bridges/TheAustraliaInstituteBridge.php | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 bridges/TheAustraliaInstituteBridge.php diff --git a/bridges/TheAustraliaInstituteBridge.php b/bridges/TheAustraliaInstituteBridge.php new file mode 100644 index 00000000..a7590e2b --- /dev/null +++ b/bridges/TheAustraliaInstituteBridge.php @@ -0,0 +1,74 @@ +find('article.Item') as $article) { + $item = []; + + $linkElement = $article->find('a[rel=bookmark]', 0); + if (!$linkElement) { + continue; + } + $item['uri'] = $linkElement->href; + + $titleElement = $article->find('h1.title a', 0); + $item['title'] = $titleElement ? $titleElement->plaintext : 'No title'; + + $timeElement = $article->find('time', 0); + $item['timestamp'] = $timeElement ? strtotime($timeElement->datetime) : time(); + + $img = $article->find('div.Item_thumb img', 0); + $thumbnail = $img + ? '' + : ''; + + $intro = $article->find('div.Item_intro p', 0); + $introText = $intro ? $intro->innertext : ''; + + $tags = []; + foreach ($article->find('footer.Item_tags li a') as $tagEl) { + $tags[] = html_entity_decode($tagEl->plaintext, ENT_QUOTES | ENT_HTML5); + } + $item['categories'] = $tags; + + $articleHtml = @getSimpleHTMLDOM($item['uri']); + $fullContent = ''; + + if ($articleHtml) { + foreach ($articleHtml->find('div.EntryMain_intro') as $introDiv) { + $introDiv->outertext = ''; + } + + $contentSection = $articleHtml->find('section.-typo', 0); + if ($contentSection) { + foreach ($contentSection->find('iframe') as $iframe) { + $src = $iframe->src ?? ''; + $title = $iframe->title ?? 'Video'; + + if (strpos($src, 'youtube.com/embed/') !== false) { + $linkHtml = '

Video: ' . htmlspecialchars($title) . '

'; + $iframe->outertext = $linkHtml; + } + } + + $fullContent = $contentSection->innertext; + } + } + + $item['content'] = $thumbnail . '
' . $introText . '
' . $fullContent; + $item['author'] = ''; // Optional future support + + $this->items[] = $item; + } + } +}