Merge branch 'FixPinterestBridge' of https://github.com/logmanoriginal/rss-bridge
This commit is contained in:
commit
e0407326c3
1 changed files with 96 additions and 76 deletions
|
@ -25,7 +25,6 @@ class PinterestBridge extends BridgeAbstract{
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$html = $this->getSimpleHTMLDOM($this->getURI());
|
$html = $this->getSimpleHTMLDOM($this->getURI());
|
||||||
if(!$html){
|
if(!$html){
|
||||||
|
@ -37,24 +36,22 @@ class PinterestBridge extends BridgeAbstract{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($html->find('div.pinWrapper') as $div)
|
if($this->queriedContext === 'From search'){
|
||||||
{
|
foreach($html->find('div.pinWrapper') as $div){
|
||||||
$a = $div->find('a.pinImageWrapper',0);
|
$item = array();
|
||||||
|
|
||||||
|
$a = $div->find('a.pinImageWrapper', 0);
|
||||||
$img = $a->find('img', 0);
|
$img = $a->find('img', 0);
|
||||||
|
|
||||||
$item = array();
|
|
||||||
$item['uri'] = $this->getURI() . $a->getAttribute('href');
|
$item['uri'] = $this->getURI() . $a->getAttribute('href');
|
||||||
$item['content'] = '<img src="' . htmlentities(str_replace('/236x/', '/736x/', $img->getAttribute('src'))) . '" alt="" />';
|
$item['content'] = '<img src="'
|
||||||
|
. htmlentities(str_replace('/236x/', '/736x/', $img->getAttribute('src')))
|
||||||
|
. '" alt="" />';
|
||||||
|
|
||||||
|
|
||||||
if ($this->queriedContext==='From search')
|
|
||||||
{
|
|
||||||
$avatar = $div->find('div.creditImg', 0)->find('img', 0);
|
$avatar = $div->find('div.creditImg', 0)->find('img', 0);
|
||||||
$avatar = $avatar->getAttribute('data-src');
|
$avatar = $avatar->getAttribute('data-src');
|
||||||
$avatar = str_replace("\\", "", $avatar);
|
$avatar = str_replace("\\", "", $avatar);
|
||||||
|
|
||||||
|
|
||||||
$username = $div->find('div.creditName', 0);
|
$username = $div->find('div.creditName', 0);
|
||||||
$board = $div->find('div.creditTitle', 0);
|
$board = $div->find('div.creditTitle', 0);
|
||||||
|
|
||||||
|
@ -62,15 +59,39 @@ class PinterestBridge extends BridgeAbstract{
|
||||||
$item['fullname'] = $board->innertext;
|
$item['fullname'] = $board->innertext;
|
||||||
$item['avatar'] = $avatar;
|
$item['avatar'] = $avatar;
|
||||||
|
|
||||||
$item['content'] .= '<br /><img align="left" style="margin: 2px 4px;" src="'.htmlentities($item['avatar']).'" /> <strong>'.$item['username'].'</strong>';
|
$item['content'] .= '<br /><img align="left" style="margin: 2px 4px;" src="'
|
||||||
$item['content'] .= '<br />'.$item['fullname'];
|
. htmlentities($item['avatar'])
|
||||||
}
|
. '" /> <strong>'
|
||||||
|
. $item['username']
|
||||||
|
. '</strong>'
|
||||||
|
. '<br />'
|
||||||
|
. $item['fullname'];
|
||||||
|
|
||||||
$item['title'] = $img->getAttribute('alt');
|
$item['title'] = $img->getAttribute('alt');
|
||||||
|
|
||||||
//$item['timestamp'] = $media->created_time;
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
} elseif($this->queriedContext === 'By username and board'){
|
||||||
|
$container = $html->find('SCRIPT[type="application/ld+json"]', 0)
|
||||||
|
or $this->returnServerError('Unable to find data container!');
|
||||||
|
|
||||||
|
$json = json_decode($container->innertext, true);
|
||||||
|
|
||||||
|
foreach($json['itemListElement'] as $element){
|
||||||
|
$item = array();
|
||||||
|
|
||||||
|
$item['uri'] = $element['item']['sharedContent']['author']['url'];
|
||||||
|
$item['title'] = $element['item']['name'];
|
||||||
|
$item['author'] = $element['item']['user']['name'];
|
||||||
|
$item['timestamp'] = strtotime($element['item']['datePublished']);
|
||||||
|
$item['content'] = <<<EOD
|
||||||
|
<a href="{$item['uri']}">
|
||||||
|
<img src="{$element['item']['image']}">
|
||||||
|
</a>
|
||||||
|
<p>{$element['item']['text']}</p>
|
||||||
|
EOD;
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +104,6 @@ class PinterestBridge extends BridgeAbstract{
|
||||||
$uri = self::URI . 'search/?q=' . urlencode($this->getInput('q'));
|
$uri = self::URI . 'search/?q=' . urlencode($this->getInput('q'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue