2023-01-22 18:00:18 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class PicnobBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'sysadminstory';
|
|
|
|
const NAME = 'Picnob Bridge';
|
|
|
|
const URI = 'https://www.picnob.com/';
|
|
|
|
const CACHE_TIMEOUT = 3600; // 1h
|
2023-07-14 06:15:49 +03:00
|
|
|
const DESCRIPTION = 'Returns Picnob (Instagram viewer) posts by user or by hashtag';
|
2023-01-22 18:00:18 +03:00
|
|
|
|
|
|
|
const PARAMETERS = [
|
|
|
|
'Username' => [
|
|
|
|
'u' => [
|
|
|
|
'name' => 'username',
|
|
|
|
'type' => 'text',
|
|
|
|
'title' => 'Instagram username you want to follow',
|
|
|
|
'exampleValue' => 'aesoprockwins',
|
|
|
|
'required' => true,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'Hashtag' => [
|
|
|
|
'h' => [
|
|
|
|
'name' => 'hashtag',
|
|
|
|
'type' => 'text',
|
|
|
|
'title' => 'Instagram hastag you want to follow, without the \'#\'',
|
|
|
|
'exampleValue' => 'beautifulday',
|
|
|
|
'required' => true,
|
|
|
|
],
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
if (!is_null($this->getInput('u'))) {
|
|
|
|
return urljoin(self::URI, '/profile/' . $this->getInput('u') . '/');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_null($this->getInput('h'))) {
|
|
|
|
return urljoin(self::URI, '/tag/' . trim($this->getInput('h') . '/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getURI();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$html = getSimpleHTMLDOM($this->getURI());
|
|
|
|
foreach ($html->find('.items') as $part) {
|
|
|
|
foreach ($part->find('.item') as $element) {
|
2023-07-07 09:16:45 +03:00
|
|
|
$url = urljoin(self::URI, $element->find('a', 0)->href);
|
2023-01-22 18:00:18 +03:00
|
|
|
|
2023-07-07 09:16:45 +03:00
|
|
|
$date = date_create();
|
|
|
|
$relativeDate = date_interval_create_from_date_string(str_replace(' ago', '', $element->find('.time', 0)->plaintext));
|
|
|
|
if ($relativeDate) {
|
|
|
|
date_sub($date, $relativeDate);
|
|
|
|
}
|
2023-01-22 18:00:18 +03:00
|
|
|
|
2023-07-07 09:16:45 +03:00
|
|
|
$description = defaultLinkTo(trim($element->find('.sum', 0)->innertext), self::URI);
|
2023-01-22 18:00:18 +03:00
|
|
|
|
2023-07-07 09:16:45 +03:00
|
|
|
$isVideo = (bool) $element->find('.icon_video', 0);
|
|
|
|
$videoNote = $isVideo ? '<p><i>(video)</i></p>' : '';
|
2023-01-22 18:00:18 +03:00
|
|
|
|
2023-07-07 09:16:45 +03:00
|
|
|
$isTV = (bool) $element->find('.icon_tv', 0);
|
|
|
|
$tvNote = $isTV ? '<p><i>(TV)</i></p>' : '';
|
2023-01-22 18:00:18 +03:00
|
|
|
|
2023-07-07 09:16:45 +03:00
|
|
|
$isMoreContent = (bool) $element->find('.icon_multi', 0);
|
|
|
|
$moreContentNote = $isMoreContent ? '<p><i>(multiple images and/or videos)</i></p>' : '';
|
2023-01-22 18:00:18 +03:00
|
|
|
|
2023-07-07 09:16:45 +03:00
|
|
|
$imageUrl = $element->find('.img', 0)->getAttribute('data-src');
|
2023-01-22 18:00:18 +03:00
|
|
|
|
2023-07-07 09:16:45 +03:00
|
|
|
$uid = explode('/', parse_url($url, PHP_URL_PATH))[2];
|
2023-01-22 18:00:18 +03:00
|
|
|
|
2023-07-07 09:16:45 +03:00
|
|
|
$this->items[] = [
|
|
|
|
'uri' => $url,
|
|
|
|
'timestamp' => date_format($date, 'r'),
|
|
|
|
'title' => strlen($description) > 60 ? mb_substr($description, 0, 57) . '...' : $description,
|
|
|
|
'thumbnail' => $imageUrl,
|
|
|
|
'enclosures' => [$imageUrl],
|
|
|
|
'content' => <<<HTML
|
2023-01-22 18:00:18 +03:00
|
|
|
<a href="{$url}">
|
|
|
|
<img loading="lazy" src="{$imageUrl}" />
|
|
|
|
</a>
|
|
|
|
{$videoNote}
|
|
|
|
{$tvNote}
|
|
|
|
{$moreContentNote}
|
|
|
|
<p>{$description}<p>
|
2023-02-21 02:56:17 +03:00
|
|
|
HTML,
|
2023-07-07 09:16:45 +03:00
|
|
|
'uid' => $uid
|
|
|
|
];
|
2023-01-22 18:00:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
if (!is_null($this->getInput('u'))) {
|
|
|
|
return 'Username ' . $this->getInput('u') . ' - Picnob Bridge';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_null($this->getInput('h'))) {
|
|
|
|
return 'Hashtag ' . $this->getInput('h') . ' - Picnob Bridge';
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getName();
|
|
|
|
}
|
|
|
|
}
|