mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-17 14:18:35 +01:00
[PicukiBridge] Add count parameter (#3556)
This commit is contained in:
parent
517c7f5c9b
commit
2ffb54c7c2
@ -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' => <<<HTML
|
||||
<a href="{$url}">
|
||||
<img loading="lazy" src="{$imageUrl}" />
|
||||
</a>
|
||||
<a href="{$sourceUrl}">{$sourceUrl}</a>
|
||||
{$videoNote}
|
||||
<p>{$description}<p>
|
||||
HTML
|
||||
<a href="{$url}">
|
||||
<img loading="lazy" src="{$imageUrl}" />
|
||||
</a>
|
||||
<a href="{$sourceUrl}">{$sourceUrl}</a>
|
||||
{$videoNote}
|
||||
<p>{$description}<p>
|
||||
HTML
|
||||
];
|
||||
|
||||
$count++;
|
||||
if ($count >= $requestedCount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user