[GooglePlusPostBridge] Fix bridge implementation
This bridge was broken due to DOM changes. This commit fixes most of the broken code. Hashtags do no longer work because they are no longer supported/provided. The timing might be off as the source only provides a rough relative value like '1 hour' or '1 year'. Closes #485
This commit is contained in:
parent
59025d96bc
commit
bd92392921
1 changed files with 22 additions and 18 deletions
|
@ -30,25 +30,27 @@ class GooglePlusPostBridge extends BridgeAbstract{
|
||||||
) or returnServerError('No results for this query.');
|
) or returnServerError('No results for this query.');
|
||||||
|
|
||||||
// get title, url, ... there is a lot of intresting stuff in meta
|
// get title, url, ... there is a lot of intresting stuff in meta
|
||||||
$this->_title = $html->find('meta[property]', 0)->getAttribute('content');
|
$this->_title = $html->find('meta[property=og:title]', 0)->getAttribute('content');
|
||||||
$this->_url = $html->find('meta[itemprop=url]', 0)->getAttribute('content');
|
$this->_url = $html->find('meta[property=og:url]', 0)->getAttribute('content');
|
||||||
|
|
||||||
// div[jsmodel=XNmfOc]
|
// I don't even know where to start with this discusting html...
|
||||||
foreach($html->find('div.yt') as $post){
|
foreach($html->find('div[jsname=WsjYwc]') as $post){
|
||||||
$item = array();
|
$item = array();
|
||||||
// $item['content'] = $post->find('div.Al', 0)->innertext;
|
|
||||||
$item['author'] = $item['fullname'] = $post->find('header.lea h3 a', 0)->innertext;
|
$item['author'] = $item['fullname'] = $post->find('div div div div a', 0)->innertext;
|
||||||
$item['id'] = $post->getAttribute('id');
|
$item['id'] = $post->find('div div div', 0)->getAttribute('id');
|
||||||
$item['title'] = $item['fullname'] = $post->find('header.lea', 0)->plaintext;
|
$item['avatar'] = $post->find('div img', 0)->src;
|
||||||
$item['avatar'] = $post->find('div.ys img', 0)->src;
|
$item['uri'] = self::URI . $post->find('div div div a', 1)->href;
|
||||||
$item['uri'] = self::URI . $post->find('a.o-U-s', 0)->href;
|
$item['timestamp'] = strtotime(
|
||||||
$item['timestamp'] = strtotime($post->find('a.o-U-s', 0)->plaintext);
|
'+' . preg_replace('/[^0-9A-Za-z]/',
|
||||||
|
'',
|
||||||
|
$post->find('div div div a span', 1)->getAttribute('aria-label')));
|
||||||
|
|
||||||
// hashtag to treat : https://plus.google.com/explore/tag
|
// hashtag to treat : https://plus.google.com/explore/tag
|
||||||
$hashtags = array();
|
// $hashtags = array();
|
||||||
foreach($post->find('a.d-s') as $hashtag){
|
// foreach($post->find('a.d-s') as $hashtag){
|
||||||
$hashtags[trim($hashtag->plaintext)] = self::URI . $hashtag->href;
|
// $hashtags[trim($hashtag->plaintext)] = self::URI . $hashtag->href;
|
||||||
}
|
// }
|
||||||
|
|
||||||
$item['content'] = '';
|
$item['content'] = '';
|
||||||
|
|
||||||
|
@ -63,7 +65,10 @@ class GooglePlusPostBridge extends BridgeAbstract{
|
||||||
. $item['avatar']
|
. $item['avatar']
|
||||||
. '" /></a></div>';
|
. '" /></a></div>';
|
||||||
|
|
||||||
$content = $post->find('div.Al', 0);
|
$content = $post->find('div div[id^=body] div div', 0);
|
||||||
|
// extract plaintext
|
||||||
|
$item['content_simple'] = $content->plaintext;
|
||||||
|
$item['title'] = substr($item['content_simple'], 0, 72) . '...';
|
||||||
|
|
||||||
// XXX ugly but I don't have any idea how to do a better stuff,
|
// XXX ugly but I don't have any idea how to do a better stuff,
|
||||||
// str_replace on link doesn't work as expected and ask too many checks
|
// str_replace on link doesn't work as expected and ask too many checks
|
||||||
|
@ -86,8 +91,7 @@ class GooglePlusPostBridge extends BridgeAbstract{
|
||||||
|
|
||||||
$item['content'] .= '<div style="margin-top: -1.5em">' . $content . '</div>';
|
$item['content'] .= '<div style="margin-top: -1.5em">' . $content . '</div>';
|
||||||
$item['content'] = trim(strip_tags($item['content'], '<a><p><div><img>'));
|
$item['content'] = trim(strip_tags($item['content'], '<a><p><div><img>'));
|
||||||
// extract plaintext
|
|
||||||
$item['content_simple'] = $post->find('div.Al', 0)->plaintext;
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue