[FurAffinityBridge] Fix if search result contains hidden submission (#3637)

* Reverts to preview submission if full is hidden

* Reverts to preview submission if full is hidden

* revert

* added fallback to higher res preview if SWF

* amend
This commit is contained in:
mruac 2023-08-30 00:34:10 +09:30 committed by GitHub
parent 00a18a1cd1
commit 9e33a15b93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -892,7 +892,7 @@ class FurAffinityBridge extends BridgeAbstract
$item = [];
$submissionURL = $figure->find('b u a', 0)->href;
$imgURL = 'https:' . $figure->find('b u a img', 0)->src;
$imgURL = $figure->find('b u a img', 0)->src;
$item['uri'] = $submissionURL;
$item['title'] = html_entity_decode(
@ -900,9 +900,11 @@ class FurAffinityBridge extends BridgeAbstract
);
$item['author'] = $figure->find('figcaption p a[href*=/user/]', 0)->title;
$item['content'] = "<a href=\"$submissionURL\"> <img src=\"{$imgURL}\" referrerpolicy=\"no-referrer\"/></a>";
if ($this->getInput('full') === true) {
$submissionHTML = $this->getFASimpleHTMLDOM($submissionURL, $cache);
if (!$this->isHiddenSubmission($submissionHTML)) {
$stats = $submissionHTML->find('.stats-container', 0);
$popupDate = $stats->find('.popup_date', 0);
if ($popupDate) {
@ -918,10 +920,11 @@ class FurAffinityBridge extends BridgeAbstract
$item['categories'][] = $keyword->plaintext;
}
$previewSrc = $submissionHTML->find('#submissionImg', 0)
->{'data-preview-src'};
$previewSrc = $submissionHTML->find('#submissionImg', 0);
if ($previewSrc) {
$imgURL = 'https:' . $previewSrc;
$imgURL = 'https:' . $previewSrc->{'data-preview-src'};
} else {
$imgURL = $submissionHTML->find('[property="og:image"]', 0)->{'content'};
}
$description = $submissionHTML->find('div.submission-description', 0);
@ -932,20 +935,8 @@ class FurAffinityBridge extends BridgeAbstract
$description = '';
}
$item['content'] = <<<EOD
<a href="$submissionURL">
<img src="{$imgURL}" referrerpolicy="no-referrer" />
</a>
<p>
{$description}
</p>
EOD;
} else {
$item['content'] = <<<EOD
<a href="$submissionURL">
<img src="$imgURL" referrerpolicy="no-referrer" />
</a>
EOD;
$item['content'] = "<a href=\"$submissionURL\"> <img src=\"{$imgURL}\" referrerpolicy=\"no-referrer\"/></a><p>{$description}</p>";
}
}
$this->items[] = $item;
@ -964,4 +955,14 @@ EOD;
$img->referrerpolicy = 'no-referrer';
}
}
private function isHiddenSubmission($html)
{
//Disabled accounts prevents their userpage, gallery, favorites and journals from being viewed.
//Submissions can require maturity limit or logged-in account.
$system_message = $html->find('.section-body.alignleft', 0);
$system_message = $system_message ? $system_message->plaintext : '';
return str_contains($system_message, 'System Message');
}
}