From 8f9147458d305debd72810a84681b779d917ef21 Mon Sep 17 00:00:00 2001 From: Dag Date: Thu, 6 Jul 2023 03:36:01 +0200 Subject: [PATCH] fix(gatesnotes): fix #3493 (#3494) --- bridges/GatesNotesBridge.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bridges/GatesNotesBridge.php b/bridges/GatesNotesBridge.php index c7b7c37f..61dccb1a 100644 --- a/bridges/GatesNotesBridge.php +++ b/bridges/GatesNotesBridge.php @@ -20,11 +20,13 @@ class GatesNotesBridge extends BridgeAbstract $apiUrl = self::URI . $api_endpoint . http_build_query($params); $rawContent = getContents($apiUrl); - $cleanedContent = str_replace('\r\n', '', substr($rawContent, 1, -1)); - $cleanedContent = str_replace('\"', '"', $cleanedContent); + $cleanedContent = str_replace([ + '', + '', + ], '', $rawContent); // The content is actually a json between quotes with \r\n inserted - $json = json_decode($cleanedContent); + $json = Json::decode($cleanedContent, false); foreach ($json as $article) { $item = []; @@ -57,8 +59,10 @@ class GatesNotesBridge extends BridgeAbstract $article_html = defaultLinkTo($article_html, $this->getURI()); $top_description = '

' . $article_html->find('div.article_top_description', 0)->innertext . '

'; - $hero_image = 'getAttribute('data-src') . '>'; - + $heroImage = $article_html->find('img.article_top_DMT_Image', 0); + if ($heroImage) { + $hero_image = ''; + } $article_body = $article_html->find('div.TGN_Article_ReadTimeSection', 0); // Remove the menu bar on some articles (PDF download etc.)