From c0df9815c73bb80f5474a2e50e32f65d8f149466 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Fri, 1 Nov 2019 15:07:25 +0100 Subject: [PATCH] [DesoutterBridge] Add feed item limit This bridge currently takes a very long time to process all news items on the page, when in many cases only one or two had been added since the last check. This commit adds a new parameter 'limit', which defines the maximum number of items to add to the feed. This is an optional paramter that defaults to 3. --- bridges/DesoutterBridge.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bridges/DesoutterBridge.php b/bridges/DesoutterBridge.php index 0aae41ad..38761ed8 100644 --- a/bridges/DesoutterBridge.php +++ b/bridges/DesoutterBridge.php @@ -116,6 +116,12 @@ class DesoutterBridge extends BridgeAbstract { 'name' => 'Load full articles', 'type' => 'checkbox', 'title' => 'Enable to load the full article for each item' + ), + 'limit' => array( + 'name' => 'Limit', + 'type' => 'number', + 'defaultValue' => 3, + 'title' => "Maximum number of items to return in the feed.\n0 = unlimited" ) ) ); @@ -156,6 +162,8 @@ class DesoutterBridge extends BridgeAbstract { $this->title = html_entity_decode($html->find('title', 0)->plaintext, ENT_QUOTES); + $limit = $this->getInput('limit') ?: 0; + foreach($html->find('article') as $article) { $item = array(); @@ -169,6 +177,8 @@ class DesoutterBridge extends BridgeAbstract { } $this->items[] = $item; + + if ($limit > 0 && count($this->items) >= $limit) break; } }