From db437b63265c4b9b1d15673d0c7d860700062ce4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pred=C3=A4?= <46051820+PredaaA@users.noreply.github.com>
Date: Sun, 19 Feb 2023 01:35:28 +0100
Subject: [PATCH] [PicukiBridge] Add source field (#3265)
* [PicukiBridge] Add source_url field
* Simplify the regex matching.
* Add picuki source for feeds
---
bridges/PicukiBridge.php | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/bridges/PicukiBridge.php b/bridges/PicukiBridge.php
index 9f9acf6b..e90177ed 100644
--- a/bridges/PicukiBridge.php
+++ b/bridges/PicukiBridge.php
@@ -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' => <<
+{$sourceUrl}
{$videoNote}
{$description}
HTML