diff --git a/bridges/CpasbienBridge.php b/bridges/CpasbienBridge.php index 220da91e..091921bc 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(){ diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php index 72d21099..21e77063 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); diff --git a/bridges/LinkedInCompany.php b/bridges/LinkedInCompany.php new file mode 100644 index 00000000..476cfc81 --- /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. (https://www.linkedin.com/company/apple)"; + $this->update = "2015-12-22"; + + $this->parameters[] = + '[ + { + "name" : "Company name", + "identifier" : "c" + } + ]'; + } + + public function collectData(array $param){ + $html = ''; + $link = 'https://www.linkedin.com/company/'.$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 21600; // 6 hours + } +} diff --git a/bridges/TwitterBridgeCleanExtended.php b/bridges/TwitterBridgeCleanExtended.php new file mode 100644 index 00000000..5358ae04 --- /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 + } +} diff --git a/bridges/ViadeoCompany.php b/bridges/ViadeoCompany.php new file mode 100644 index 00000000..6b474f57 --- /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. (http://www.viadeo.com/fr/company/apple)"; + $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 + } +}