From 2ffb54c7c2b961c83b0a876bd5d34f7d698c2b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pred=C3=A4?= <46051820+PredaaA@users.noreply.github.com> Date: Thu, 20 Jul 2023 00:52:09 +0200 Subject: [PATCH] [PicukiBridge] Add count parameter (#3556) --- bridges/PicukiBridge.php | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/bridges/PicukiBridge.php b/bridges/PicukiBridge.php index 7a4f9eb5..f1d45e2a 100644 --- a/bridges/PicukiBridge.php +++ b/bridges/PicukiBridge.php @@ -9,6 +9,14 @@ class PicukiBridge extends BridgeAbstract const DESCRIPTION = 'Returns Picuki (Instagram viewer) posts by user and by hashtag'; const PARAMETERS = [ + 'global' => [ + 'count' => [ + 'name' => 'Count', + 'type' => 'number', + 'title' => 'How many posts to fetch', + 'defaultValue' => 12 + ] + ], 'Username' => [ 'u' => [ 'name' => 'username', @@ -43,6 +51,13 @@ class PicukiBridge extends BridgeAbstract $re = '#let short_code = "(.*?)";\s*$#m'; $html = getSimpleHTMLDOM($this->getURI()); + $requestedCount = $this->getInput('count'); + if ($requestedCount > 12) { + // Picuki shows 12 posts per page at initial load. + throw new \Exception('Maximum count is 12'); + } + + $count = 0; foreach ($html->find('.box-photos .box-photo') as $element) { // skip ad items if (in_array('adv', explode(' ', $element->class))) { @@ -86,14 +101,19 @@ class PicukiBridge extends BridgeAbstract 'source' => $sourceUrl, 'enclosures' => [$imageUrl], 'content' => << - - -{$sourceUrl} -{$videoNote} -
{$description}
-HTML + + + + {$sourceUrl} + {$videoNote} +
{$description}
+ HTML ]; + + $count++; + if ($count >= $requestedCount) { + break; + } } }