From 5ada7afcd12b8db252d7d9a124d8ee78ace9afd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Enguehard?= Date: Tue, 22 Dec 2015 18:03:46 +0100 Subject: [PATCH 1/7] Ajout d'un pont vers Viadeo et LinkedLn --- bridges/LinkedInCompany.php | 52 +++++++++++++++++++++++++++++++++++++ bridges/ViadeoCompany.php | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 bridges/LinkedInCompany.php create mode 100644 bridges/ViadeoCompany.php diff --git a/bridges/LinkedInCompany.php b/bridges/LinkedInCompany.php new file mode 100644 index 0000000..185fee9 --- /dev/null +++ b/bridges/LinkedInCompany.php @@ -0,0 +1,52 @@ +maintainer = "regisenguehard"; + $this->name = "LinkedIn Company"; + $this->uri = "https://www.linkedin.com/"; + $this->description = "Returns most recent actus from Company on LinkedIn."; + $this->update = "2015-12-22"; + + $this->parameters[] = + '[ + { + "name" : "Company name", + "identifier" : "c" + } + ]'; + } + + public function collectData(array $param){ + $html = ''; + $link = 'https://www.linkedin.com/company/'.urlencode($param[c]); + + $html = file_get_html($link) or $this->returnError('Could not request LinkedIn.', 404); + + foreach($html->find('//*[@id="my-feed-post"]/li') as $element) { + $title = $element->find('span.share-body', 0)->innertext; + if ($title) { + $item = new \Item(); + $item->uri = $link; + $item->title = mb_substr(strip_tags($element->find('span.share-body', 0)->innertext), 0 ,100); + $item->content = strip_tags($element->find('span.share-body', 0)->innertext); + $item->thumbnailUri = htmlspecialchars_decode($element->find('img', 0)->attr['data-li-lazy-load-src']); + $this->items[] = $item; + $i++; + } + } + } + + public function getName(){ + return 'LinkedIn'; + } + + public function getURI(){ + return 'https://www.linkedin.com'; + } + + public function getCacheDuration(){ + return 0; // 6 hours + } +} diff --git a/bridges/ViadeoCompany.php b/bridges/ViadeoCompany.php new file mode 100644 index 0000000..979bdf5 --- /dev/null +++ b/bridges/ViadeoCompany.php @@ -0,0 +1,52 @@ +maintainer = "regisenguehard"; + $this->name = "Viadeo Company"; + $this->uri = "https://www.viadeo.com/"; + $this->description = "Returns most recent actus from Company on Viadeo."; + $this->update = "2015-12-22"; + + $this->parameters[] = + '[ + { + "name" : "Company name", + "identifier" : "c" + } + ]'; + } + + public function collectData(array $param){ + $html = ''; + $link = 'http://www.viadeo.com/fr/company/'.$param[c]; + + $html = file_get_html($link) or $this->returnError('Could not request Viadeo.', 404); + + foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element) { + $title = $element->find('p', 0)->innertext; + if ($title) { + $item = new \Item(); + $item->uri = $link; + $item->title = mb_substr($element->find('p', 0)->innertext, 0 ,100); + $item->content = $element->find('p', 0)->innertext; + $item->thumbnailUri = str_replace('//', 'http://', $element->find('img.usage-article__image_only', 0)->src); + $this->items[] = $item; + $i++; + } + } + } + + public function getName(){ + return 'Viadeo'; + } + + public function getURI(){ + return 'https://www.viadeo.com'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} From e4d31c32947f2b2ab50a94bebddbe51161d7fa44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Enguehard?= Date: Wed, 23 Dec 2015 16:14:28 +0100 Subject: [PATCH 2/7] maj LinkedIn & Viadeo --- bridges/LinkedInCompany.php | 6 +++--- bridges/ViadeoCompany.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bridges/LinkedInCompany.php b/bridges/LinkedInCompany.php index 185fee9..476cfc8 100644 --- a/bridges/LinkedInCompany.php +++ b/bridges/LinkedInCompany.php @@ -6,7 +6,7 @@ class LinkedInCompany extends BridgeAbstract{ $this->maintainer = "regisenguehard"; $this->name = "LinkedIn Company"; $this->uri = "https://www.linkedin.com/"; - $this->description = "Returns most recent actus from Company on LinkedIn."; + $this->description = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/apple)"; $this->update = "2015-12-22"; $this->parameters[] = @@ -20,7 +20,7 @@ class LinkedInCompany extends BridgeAbstract{ public function collectData(array $param){ $html = ''; - $link = 'https://www.linkedin.com/company/'.urlencode($param[c]); + $link = 'https://www.linkedin.com/company/'.$param[c]; $html = file_get_html($link) or $this->returnError('Could not request LinkedIn.', 404); @@ -47,6 +47,6 @@ class LinkedInCompany extends BridgeAbstract{ } public function getCacheDuration(){ - return 0; // 6 hours + return 21600; // 6 hours } } diff --git a/bridges/ViadeoCompany.php b/bridges/ViadeoCompany.php index 979bdf5..6b474f5 100644 --- a/bridges/ViadeoCompany.php +++ b/bridges/ViadeoCompany.php @@ -6,7 +6,7 @@ class ViadeoCompany extends BridgeAbstract{ $this->maintainer = "regisenguehard"; $this->name = "Viadeo Company"; $this->uri = "https://www.viadeo.com/"; - $this->description = "Returns most recent actus from Company on Viadeo."; + $this->description = "Returns most recent actus from Company on Viadeo. (http://www.viadeo.com/fr/company/apple)"; $this->update = "2015-12-22"; $this->parameters[] = From 438a389286017a90a24fd0e3b2c34d9091695e7f Mon Sep 17 00:00:00 2001 From: Ginko-Aloe Date: Tue, 19 Jan 2016 18:04:35 +0100 Subject: [PATCH 3/7] urlencode keyword parameter in order to handle non-trivial request keywords --- bridges/LeBonCoinBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php index 72d2109..21e7706 100755 --- a/bridges/LeBonCoinBridge.php +++ b/bridges/LeBonCoinBridge.php @@ -134,7 +134,7 @@ class LeBonCoinBridge extends BridgeAbstract{ public function collectData(array $param){ $html = ''; - $link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r'] . '/?f=a&th=1&q=' . $param['k']; + $link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r'] . '/?f=a&th=1&q=' . urlencode($param['k']); $html = file_get_html($link) or $this->returnError('Could not request LeBonCoin.', 404); $list = $html->find('.list-lbc', 0); From 445568db27811b8c74fdd60c41f409f12623dd7f Mon Sep 17 00:00:00 2001 From: Kevin Lagaisse Date: Tue, 26 Jan 2016 18:39:05 +0100 Subject: [PATCH 4/7] Change url again & constant factorization --- bridges/CpasbienBridge.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php index 220da91..091921b 100644 --- a/bridges/CpasbienBridge.php +++ b/bridges/CpasbienBridge.php @@ -22,15 +22,17 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ $this->maintainer = "lagaisse"; $this->name = "Cpasbien Bridge"; - $this->uri = "http://Cpasbien.pw/"; - $this->description = "Returns latest torrent from request query"; - $this->update = "2015-05-17"; + $this->uri = "http://www.cpasbien.io"; + $this->description = "Returns latest torrents from a request query"; + $this->update = "2016-01-26"; $this->parameters[] = '[ { - "name" : "keyword", - "identifier" : "q" + "name" : "Search", + "identifier" : "q", + "required" : true, + "title" : "Type your search" } ]'; @@ -38,10 +40,11 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ public function collectData(array $param){ + $this->loadMetadatas(); $html = ''; if (isset($param['q'])) { /* keyword search mode */ $this->request = str_replace(" ","-",trim($param['q'])); - $html = file_get_html('http://www.cpasbien.pw/recherche/'.urlencode($this->request).'.html') or $this->returnError('No results for this query.', 404); + $html = file_get_html($this->uri.'/recherche/'.urlencode($this->request).'.html') or $this->returnError('No results for this query.', 404); } else { $this->returnError('You must specify a keyword (?q=...).', 400); @@ -66,7 +69,7 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ } $item->id = $episode->find('a', 0)->getAttribute('href'); - $item->uri = $this->getURI() . $htmlepisode->find('#telecharger',0)->getAttribute('href'); + $item->uri = $this->uri . $htmlepisode->find('#telecharger',0)->getAttribute('href'); $item->thumbnailUri = $htmlepisode->find('#bigcover', 0)->find('img',0)->getAttribute('src'); $this->items[] = $item; } @@ -77,11 +80,11 @@ class CpasbienBridge extends HttpCachingBridgeAbstract{ public function getName(){ - return (!empty($this->request) ? $this->request .' - ' : '') .'Cpasbien Bridge'; + return (!empty($this->request) ? $this->request .' - ' : '') . $this->name; } public function getURI(){ - return 'http://www.cpasbien.pw'; + return $this->uri; } public function getCacheDuration(){ From 651f5ac94fd9e359dfd3e72dbb4589804db6f435 Mon Sep 17 00:00:00 2001 From: mxmehl Date: Wed, 27 Jan 2016 11:44:28 +0100 Subject: [PATCH 5/7] add another improved Twitter Bridge --- bridges/TwitterBridgeCleanExtended.php | 90 ++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 bridges/TwitterBridgeCleanExtended.php diff --git a/bridges/TwitterBridgeCleanExtended.php b/bridges/TwitterBridgeCleanExtended.php new file mode 100644 index 0000000..5358ae0 --- /dev/null +++ b/bridges/TwitterBridgeCleanExtended.php @@ -0,0 +1,90 @@ +maintainer = "Max Mehl"; + $this->name = "Twitter Bridge Clean Extended"; + $this->uri = "http://twitter.com/"; + $this->description = "Returns user timelines showing RTs correctly or search results for keywords/hashtags (without using their API)."; + $this->update = "2016-01-27"; + + $this->parameters["By keyword or hashtag"] = + '[ + { + "name" : "Keyword or #hashtag", + "identifier" : "q" + } + ]'; + + $this->parameters["By username"] = + '[ + { + "name" : "username", + "identifier" : "u" + } + ]'; + + } + + public function collectData(array $param){ + $html = ''; + if (isset($param['q'])) { /* keyword search mode */ + $this->request = $param['q']; + $html = file_get_html('https://twitter.com/search?q='.urlencode($this->request).'&f=tweets') or $this->returnError('No results for this query.', 404); + } + elseif (isset($param['u'])) { /* user timeline mode */ + $this->request = $param['u']; + $html = file_get_html('http://twitter.com/'.urlencode($this->request)) or $this->returnError('Requested username can\'t be found.', 404); + } + else { + $this->returnError('You must specify a keyword (?q=...) or a Twitter username (?u=...).', 400); + } + + foreach($html->find('div.js-stream-tweet') as $tweet) { + $item = new \Item(); + $item->username = $tweet->getAttribute('data-screen-name'); // extract username and sanitize + $item->fullname = $tweet->getAttribute('data-name'); // extract fullname (pseudonym) + $item->avatar = $tweet->find('img', 0)->src; // get avatar link + $item->id = $tweet->getAttribute('data-tweet-id'); // get TweetID + $item->uri = 'https://twitter.com'.$tweet->find('a.js-permalink', 0)->getAttribute('href'); // get tweet link + $item->timestamp = $tweet->find('span.js-short-timestamp', 0)->getAttribute('data-time'); // extract tweet timestamp + // processing content links + foreach($tweet->find('a') as $link) { + if($link->hasAttribute('data-expanded-url') ) { + $link->href = $link->getAttribute('data-expanded-url'); + } + $link->removeAttribute('data-expanded-url'); + $link->removeAttribute('data-query-source'); + $link->removeAttribute('rel'); + $link->removeAttribute('class'); + $link->removeAttribute('target'); + $link->removeAttribute('title'); + $link->removeAttribute('dir'); + } + $item->content = str_replace('pic.twitter.com', 'https://pic.twitter.com', strip_tags($tweet->find('p.js-tweet-text', 0)->innertext)); // extract tweet text + if(isset($param['u'])) { + if($item->username != $param['u']) { + $item->content = '♻ @' . $item->username . ': ' . $item->content; + } + } + $item->title = $item->content; + $this->items[] = $item; + } + } + + public function getName(){ + return (!empty($this->request) ? $this->request : ''); + } + + public function getURI(){ + return 'http://twitter.com'; + } + + public function getCacheDuration(){ + return 300; // 5 minutes + } +} From f837032afb70d9a8b95a05ed4b1941f348807127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Enguehard?= Date: Tue, 22 Dec 2015 18:03:46 +0100 Subject: [PATCH 6/7] Ajout d'un pont vers Viadeo et LinkedLn --- bridges/LinkedInCompany.php | 52 +++++++++++++++++++++++++++++++++++++ bridges/ViadeoCompany.php | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 bridges/LinkedInCompany.php create mode 100644 bridges/ViadeoCompany.php diff --git a/bridges/LinkedInCompany.php b/bridges/LinkedInCompany.php new file mode 100644 index 0000000..185fee9 --- /dev/null +++ b/bridges/LinkedInCompany.php @@ -0,0 +1,52 @@ +maintainer = "regisenguehard"; + $this->name = "LinkedIn Company"; + $this->uri = "https://www.linkedin.com/"; + $this->description = "Returns most recent actus from Company on LinkedIn."; + $this->update = "2015-12-22"; + + $this->parameters[] = + '[ + { + "name" : "Company name", + "identifier" : "c" + } + ]'; + } + + public function collectData(array $param){ + $html = ''; + $link = 'https://www.linkedin.com/company/'.urlencode($param[c]); + + $html = file_get_html($link) or $this->returnError('Could not request LinkedIn.', 404); + + foreach($html->find('//*[@id="my-feed-post"]/li') as $element) { + $title = $element->find('span.share-body', 0)->innertext; + if ($title) { + $item = new \Item(); + $item->uri = $link; + $item->title = mb_substr(strip_tags($element->find('span.share-body', 0)->innertext), 0 ,100); + $item->content = strip_tags($element->find('span.share-body', 0)->innertext); + $item->thumbnailUri = htmlspecialchars_decode($element->find('img', 0)->attr['data-li-lazy-load-src']); + $this->items[] = $item; + $i++; + } + } + } + + public function getName(){ + return 'LinkedIn'; + } + + public function getURI(){ + return 'https://www.linkedin.com'; + } + + public function getCacheDuration(){ + return 0; // 6 hours + } +} diff --git a/bridges/ViadeoCompany.php b/bridges/ViadeoCompany.php new file mode 100644 index 0000000..979bdf5 --- /dev/null +++ b/bridges/ViadeoCompany.php @@ -0,0 +1,52 @@ +maintainer = "regisenguehard"; + $this->name = "Viadeo Company"; + $this->uri = "https://www.viadeo.com/"; + $this->description = "Returns most recent actus from Company on Viadeo."; + $this->update = "2015-12-22"; + + $this->parameters[] = + '[ + { + "name" : "Company name", + "identifier" : "c" + } + ]'; + } + + public function collectData(array $param){ + $html = ''; + $link = 'http://www.viadeo.com/fr/company/'.$param[c]; + + $html = file_get_html($link) or $this->returnError('Could not request Viadeo.', 404); + + foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element) { + $title = $element->find('p', 0)->innertext; + if ($title) { + $item = new \Item(); + $item->uri = $link; + $item->title = mb_substr($element->find('p', 0)->innertext, 0 ,100); + $item->content = $element->find('p', 0)->innertext; + $item->thumbnailUri = str_replace('//', 'http://', $element->find('img.usage-article__image_only', 0)->src); + $this->items[] = $item; + $i++; + } + } + } + + public function getName(){ + return 'Viadeo'; + } + + public function getURI(){ + return 'https://www.viadeo.com'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} From 65a9c2b0bc18ffef9517f174f1034368c8e96d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Enguehard?= Date: Wed, 23 Dec 2015 16:14:28 +0100 Subject: [PATCH 7/7] maj LinkedIn & Viadeo --- bridges/LinkedInCompany.php | 6 +++--- bridges/ViadeoCompany.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bridges/LinkedInCompany.php b/bridges/LinkedInCompany.php index 185fee9..476cfc8 100644 --- a/bridges/LinkedInCompany.php +++ b/bridges/LinkedInCompany.php @@ -6,7 +6,7 @@ class LinkedInCompany extends BridgeAbstract{ $this->maintainer = "regisenguehard"; $this->name = "LinkedIn Company"; $this->uri = "https://www.linkedin.com/"; - $this->description = "Returns most recent actus from Company on LinkedIn."; + $this->description = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/apple)"; $this->update = "2015-12-22"; $this->parameters[] = @@ -20,7 +20,7 @@ class LinkedInCompany extends BridgeAbstract{ public function collectData(array $param){ $html = ''; - $link = 'https://www.linkedin.com/company/'.urlencode($param[c]); + $link = 'https://www.linkedin.com/company/'.$param[c]; $html = file_get_html($link) or $this->returnError('Could not request LinkedIn.', 404); @@ -47,6 +47,6 @@ class LinkedInCompany extends BridgeAbstract{ } public function getCacheDuration(){ - return 0; // 6 hours + return 21600; // 6 hours } } diff --git a/bridges/ViadeoCompany.php b/bridges/ViadeoCompany.php index 979bdf5..6b474f5 100644 --- a/bridges/ViadeoCompany.php +++ b/bridges/ViadeoCompany.php @@ -6,7 +6,7 @@ class ViadeoCompany extends BridgeAbstract{ $this->maintainer = "regisenguehard"; $this->name = "Viadeo Company"; $this->uri = "https://www.viadeo.com/"; - $this->description = "Returns most recent actus from Company on Viadeo."; + $this->description = "Returns most recent actus from Company on Viadeo. (http://www.viadeo.com/fr/company/apple)"; $this->update = "2015-12-22"; $this->parameters[] =