From 11ea6aedfd06e1da1294883d382c063951ae3c2e Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 10 Aug 2023 23:59:37 +0200 Subject: [PATCH] hide dpa articles in Nordbayern News (#3608) --- bridges/NordbayernBridge.php | 42 ++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/bridges/NordbayernBridge.php b/bridges/NordbayernBridge.php index b409e1e0..aa32f4ba 100644 --- a/bridges/NordbayernBridge.php +++ b/bridges/NordbayernBridge.php @@ -44,6 +44,12 @@ class NordbayernBridge extends BridgeAbstract 'type' => 'checkbox', 'exampleValue' => 'unchecked', 'title' => 'Hide all paywall articles on NN' + ], + 'hideDPA' => [ + 'name' => 'Hide dpa articles', + 'type' => 'checkbox', + 'exampleValue' => 'unchecked', + 'title' => 'Hide external articles from dpa' ] ]]; @@ -103,7 +109,7 @@ class NordbayernBridge extends BridgeAbstract return $teaser; } - private function handleArticle($link) + private function getArticle($link) { $item = []; $article = getSimpleHTMLDOM($link); @@ -142,15 +148,9 @@ class NordbayernBridge extends BridgeAbstract $item['content'] .= self::getUseFullContent($content); } - // exclude police reports if desired - if ( - $this->getInput('policeReports') || - !str_contains($item['content'], 'Hier geht es zu allen aktuellen Polizeimeldungen.') - ) { - $this->items[] = $item; - } $article->clear(); + return $item; } private function handleNewsblock($listSite) @@ -161,11 +161,31 @@ class NordbayernBridge extends BridgeAbstract $url = urljoin(self::URI, $url); // exclude nn+ articles if desired if ( - !$this->getInput('hideNNPlus') || - !str_contains($url, 'www.nn.de') + $this->getInput('hideNNPlus') && + str_contains($url, 'www.nn.de') ) { - self::handleArticle($url); + continue; } + + $item = self::getArticle($url); + + // exclude police reports if desired + if ( + !$this->getInput('policeReports') && + str_contains($item['content'], 'Hier geht es zu allen aktuellen Polizeimeldungen.') + ) { + continue; + } + + // exclude dpa articles + if ( + $this->getInput('hideDPA') && + str_contains($item['author'], 'dpa') + ) { + continue; + } + + $this->items[] = $item; } }