1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-01-17 22:28:22 +01:00

[PicukiBridge] Add count parameter (#3556)

This commit is contained in:
Predä 2023-07-20 00:52:09 +02:00 committed by GitHub
parent 517c7f5c9b
commit 2ffb54c7c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,14 @@ class PicukiBridge extends BridgeAbstract
const DESCRIPTION = 'Returns Picuki (Instagram viewer) posts by user and by hashtag'; const DESCRIPTION = 'Returns Picuki (Instagram viewer) posts by user and by hashtag';
const PARAMETERS = [ const PARAMETERS = [
'global' => [
'count' => [
'name' => 'Count',
'type' => 'number',
'title' => 'How many posts to fetch',
'defaultValue' => 12
]
],
'Username' => [ 'Username' => [
'u' => [ 'u' => [
'name' => 'username', 'name' => 'username',
@ -43,6 +51,13 @@ class PicukiBridge extends BridgeAbstract
$re = '#let short_code = "(.*?)";\s*$#m'; $re = '#let short_code = "(.*?)";\s*$#m';
$html = getSimpleHTMLDOM($this->getURI()); $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) { foreach ($html->find('.box-photos .box-photo') as $element) {
// skip ad items // skip ad items
if (in_array('adv', explode(' ', $element->class))) { if (in_array('adv', explode(' ', $element->class))) {
@ -86,14 +101,19 @@ class PicukiBridge extends BridgeAbstract
'source' => $sourceUrl, 'source' => $sourceUrl,
'enclosures' => [$imageUrl], 'enclosures' => [$imageUrl],
'content' => <<<HTML 'content' => <<<HTML
<a href="{$url}"> <a href="{$url}">
<img loading="lazy" src="{$imageUrl}" /> <img loading="lazy" src="{$imageUrl}" />
</a> </a>
<a href="{$sourceUrl}">{$sourceUrl}</a> <a href="{$sourceUrl}">{$sourceUrl}</a>
{$videoNote} {$videoNote}
<p>{$description}<p> <p>{$description}<p>
HTML HTML
]; ];
$count++;
if ($count >= $requestedCount) {
break;
}
} }
} }