[PriviblurBridge] Fix invalid favicon, use either Tumblr or blog icon (#4327)

This commit is contained in:
July 2024-11-23 12:50:40 -05:00 committed by GitHub
parent 2294dac3f1
commit 9457e075f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,6 +17,7 @@ class PriviblurBridge extends BridgeAbstract
]; ];
private $title; private $title;
private $favicon = 'https://www.tumblr.com/favicon.ico';
public function collectData() public function collectData()
{ {
@ -25,6 +26,11 @@ class PriviblurBridge extends BridgeAbstract
$html = defaultLinkTo($html, $url); $html = defaultLinkTo($html, $url);
$this->title = $html->find('head title', 0)->innertext; $this->title = $html->find('head title', 0)->innertext;
if ($html->find('#blog-header img.avatar', 0)) {
$icon = $html->find('#blog-header img.avatar', 0)->src;
$this->favicon = str_replace('pnj', 'png', $icon);
}
$elements = $html->find('.post'); $elements = $html->find('.post');
foreach ($elements as $element) { foreach ($elements as $element) {
$item = []; $item = [];
@ -64,6 +70,11 @@ class PriviblurBridge extends BridgeAbstract
public function getURI() public function getURI()
{ {
return $this->getInput('url') ? $this->getInput('url') : parent::getURI(); return $this->getInput('url') ?? parent::getURI();
}
public function getIcon()
{
return $this->favicon;
} }
} }