[PicukiBridge] Try to fix the bridge (#4262)

This is a try to fix the bridge HTML parsing
This commit is contained in:
sysadminstory 2024-09-11 15:14:19 +02:00 committed by GitHub
parent 40041dd65f
commit d9316cdc60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -58,26 +58,26 @@ class PicukiBridge extends BridgeAbstract
} }
$count = 0; $count = 0;
foreach ($html->find('.box-photos .box-photo') as $element) { foreach ($html->find('div[class=.box-photo][data-s=media]') as $element) {
// skip ad items // skip ad items
if (in_array('adv', explode(' ', $element->class))) { if (in_array('adv', explode(' ', $element->class))) {
continue; continue;
} }
$url = urljoin(self::URI, $element->find('a', 0)->href); $url = $element->find('a', 0)->href;
$html = getSimpleHTMLDOMCached($url); $html_single = getSimpleHTMLDOMCached($url);
$sourceUrl = null; $sourceUrl = null;
if (preg_match($re, $html, $matches) > 0) { if (preg_match($re, $html_single, $matches) > 0) {
$sourceUrl = 'https://instagram.com/p/' . $matches[1]; $sourceUrl = 'https://instagram.com/p/' . $matches[1];
} }
$author = trim($element->find('.user-nickname', 0)->plaintext); //$author = trim($element->find('.single-photo-nickname', 0)->plaintext);
$date = date_create(); $date = date_create();
$relativeDate = str_replace(' ago', '', $element->find('.time', 0)->plaintext); $relativeDate = str_replace(' ago', '', $element->find('.time', 0)->plaintext);
date_sub($date, date_interval_create_from_date_string($relativeDate)); date_sub($date, date_interval_create_from_date_string($relativeDate));
$description = trim($element->find('.photo-description', 0)->plaintext); $description = trim($element->find('.photo-action-description', 0)->plaintext);
$isVideo = (bool) $element->find('.video-icon', 0); $isVideo = (bool) $element->find('.video-icon', 0);
$videoNote = $isVideo ? '<p><i>(video)</i></p>' : ''; $videoNote = $isVideo ? '<p><i>(video)</i></p>' : '';
@ -91,7 +91,7 @@ class PicukiBridge extends BridgeAbstract
$this->items[] = [ $this->items[] = [
'uri' => $url, 'uri' => $url,
'author' => $author, /*'author' => $author,*/
'timestamp' => date_format($date, 'r'), 'timestamp' => date_format($date, 'r'),
'title' => strlen($description) > 60 ? mb_substr($description, 0, 57) . '...' : $description, 'title' => strlen($description) > 60 ? mb_substr($description, 0, 57) . '...' : $description,
'thumbnail' => $imageUrl, 'thumbnail' => $imageUrl,