From 75772f58e21b17a9abe667c247cdaf7cc138d931 Mon Sep 17 00:00:00 2001 From: Dag Date: Thu, 3 Nov 2022 21:42:26 +0100 Subject: [PATCH] fix: review news was not properly extracted (#3131) Fix #3129 --- bridges/GBAtempBridge.php | 130 +++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 64 deletions(-) diff --git a/bridges/GBAtempBridge.php b/bridges/GBAtempBridge.php index 98cafe7d..523dc980 100644 --- a/bridges/GBAtempBridge.php +++ b/bridges/GBAtempBridge.php @@ -20,70 +20,6 @@ class GBAtempBridge extends BridgeAbstract ] ]]; - private function buildItem($uri, $title, $author, $timestamp, $thumbnail, $content) - { - $item = []; - $item['uri'] = $uri; - $item['title'] = $title; - $item['author'] = $author; - $item['timestamp'] = $timestamp; - $item['content'] = $content; - if (!empty($thumbnail)) { - $item['enclosures'] = [$thumbnail]; - } - return $item; - } - - private function decodeHtmlEntities($text) - { - $text = html_entity_decode($text); - $convmap = [0x0, 0x2FFFF, 0, 0xFFFF]; - return trim(mb_decode_numericentity($text, $convmap, 'UTF-8')); - } - - private function cleanupPostContent($content, $site_url) - { - $content = defaultLinkTo($content, self::URI); - $content = stripWithDelimiters($content, ''); - $content = stripWithDelimiters($content, ''); - $content = stripRecursiveHTMLSection($content, 'div', '
decodeHtmlEntities($content); + } + + private function findItemDate($item) + { + $time = 0; + $dateField = $item->find('time', 0); + if (is_object($dateField)) { + $time = strtotime($dateField->datetime); + } + return $time; + } + + private function findItemImage($item, $selector) + { + $img = extractFromDelimiters($item->find($selector, 0)->style, 'url(', ')'); + $paramPos = strpos($img, '?'); + if ($paramPos !== false) { + $img = substr($img, 0, $paramPos); + } + if (!str_ends_with($img, '.png') && !str_ends_with($img, '.jpg')) { + $img = $img . '#.image'; + } + return urljoin(self::URI, $img); + } + public function getName() { if (!is_null($this->getInput('type'))) {