From cc91ee1e37a16e40c89bb04b0782ab8eb2187655 Mon Sep 17 00:00:00 2001 From: rmscoelho <50850007+rmscoelho@users.noreply.github.com> Date: Fri, 30 Jun 2023 14:54:53 +0100 Subject: [PATCH] [JornalNBridge] getName() fix (#3456) * [JornalNBridge] getName() fix * [JornalNBridge] feed fixes --- bridges/JornalNBridge.php | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/bridges/JornalNBridge.php b/bridges/JornalNBridge.php index aff455b1..89381062 100644 --- a/bridges/JornalNBridge.php +++ b/bridges/JornalNBridge.php @@ -6,7 +6,7 @@ class JornalNBridge extends BridgeAbstract const URI = 'https://www.jornaln.pt/'; const DESCRIPTION = 'Returns news from the Portuguese local newspaper Jornal N'; const MAINTAINER = 'rmscoelho'; - const CACHE_TIMEOUT = 86400; + const CACHE_TIMEOUT = 3600; const PARAMETERS = [ [ 'feed' => [ @@ -19,12 +19,12 @@ class JornalNBridge extends BridgeAbstract 'Ovar' => 'ovar', 'Santa Maria da Feira' => 'santa-maria-da-feira', ], - 'Cultura' => 'cultura', + 'Cultura' => 'ovar/cultura', 'Desporto' => 'desporto', - 'Economia' => 'economia', - 'Política' => 'politica', - 'Opinião' => 'opiniao', - 'Sociedade' => 'sociedade', + 'Economia' => 'santa-maria-da-feira/economia', + 'Política' => 'santa-maria-da-feira/politica', + 'Opinião' => 'santa-maria-da-feira/opiniao', + 'Sociedade' => 'santa-maria-da-feira/sociedade', ] ] ] @@ -52,16 +52,7 @@ class JornalNBridge extends BridgeAbstract public function getName() { - $feed = $this->getInput('feed'); - if ($this->getInput('feed') !== null && $this->getInput('feed') !== '') { - if ($feed === 'santa-maria-da-feira') { - $name = 'Santa Maria da Feira'; - } else { - $name = ucfirst($feed); - } - return self::NAME . ' | ' . $name; - } - return self::NAME; + return !is_null($this->getKey('feed')) ? self::NAME . ' | ' . $this->getKey('feed') : self::NAME; } public function getURI() @@ -71,7 +62,7 @@ class JornalNBridge extends BridgeAbstract public function collectData() { - $url = sprintf('https://www.jornaln.pt/%s', $this->getInput('feed')); + $url = sprintf(self::URI . '/%s', $this->getInput('feed')); $dom = getSimpleHTMLDOMCached($url); $domSelector = '.elementor-widget-container > .elementor-posts-container'; $dom = $dom->find($domSelector, 0); @@ -81,7 +72,7 @@ class JornalNBridge extends BridgeAbstract $dom = defaultLinkTo($dom, $this->getURI()); foreach ($dom->find('article') as $article) { //Get thumbnail - $image = $article->find('img', 0)->src; + $image = $article->find('.elementor-post__thumbnail img', 0)->src; //Timestamp $date = $article->find('.elementor-post-date', 0)->plaintext; $date = preg_replace('/ de /i', '/', $date);