[PicukiBridge] Add source field (#3265)

* [PicukiBridge] Add source_url field

* Simplify the regex matching.

* Add picuki source for feeds
This commit is contained in:
Predä 2023-02-19 01:35:28 +01:00 committed by GitHub
parent 5d4247dded
commit db437b6326
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,6 +40,7 @@ class PicukiBridge extends BridgeAbstract
public function collectData()
{
$re = '#let short_code = "(.*?)";\s*$#m';
$html = getSimpleHTMLDOM($this->getURI());
foreach ($html->find('.box-photos .box-photo') as $element) {
@ -49,6 +50,11 @@ class PicukiBridge extends BridgeAbstract
}
$url = urljoin(self::URI, $element->find('a', 0)->href);
$html = getSimpleHTMLDOMCached($url);
$sourceUrl = null;
if (preg_match($re, $html, $matches) > 0) {
$sourceUrl = 'https://instagram.com/p/' . $matches[1];
}
$author = trim($element->find('.user-nickname', 0)->plaintext);
@ -77,11 +83,13 @@ class PicukiBridge extends BridgeAbstract
'timestamp' => date_format($date, 'r'),
'title' => strlen($description) > 60 ? mb_substr($description, 0, 57) . '...' : $description,
'thumbnail' => $imageUrl,
'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