From 7202427fe5a69c2ae792548f1616c129d039d24b Mon Sep 17 00:00:00 2001 From: Henri Rebecq Date: Mon, 19 Aug 2013 11:30:03 +1000 Subject: [PATCH 1/3] =?UTF-8?q?Add:=20Se=20coucher=20moins=20b=C3=AAte=20B?= =?UTF-8?q?ridge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridges/ScmbBridge.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 bridges/ScmbBridge.php diff --git a/bridges/ScmbBridge.php b/bridges/ScmbBridge.php new file mode 100644 index 00000000..496bf42b --- /dev/null +++ b/bridges/ScmbBridge.php @@ -0,0 +1,36 @@ +returnError('Could not request Se Coucher Moins Bete.', 404); + + foreach($html->find('article') as $article) { + $item = new \Item(); + $item->uri = 'http://secouchermoinsbete.fr'.$article->find('p.summary a',0)->href; + $item->title = $article->find('header h1 a',0)->innertext; + $article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content + $item->content = $article->find('p.summary a',0)->innertext; + $this->items[] = $item; + } + } + + public function getName(){ + return 'Se Coucher Moins Bête Bridge'; + } + + public function getURI(){ + return 'http://secouchermoinsbete.fr/'; + } + + public function getCacheDuration(){ + return 21600; // 6 hours + } +} From 685438d29c6f941424fb0a13792b469471c72890 Mon Sep 17 00:00:00 2001 From: Henri Rebecq Date: Mon, 19 Aug 2013 11:55:07 +1000 Subject: [PATCH 2/3] Updated README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e922f586..5fb1157c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Supported sites/pages * `Identi.ca` : Identica user timeline (Should be compatible with other Pump.io instances). * `YouTube` : YouTube user channel feed. * `Cryptome` : Returns the most recent documents from Cryptome.org. + * `Se coucher moins bête` : Returns the most recent anecdotes from Secouchermoinsbete.fr Output format From 8bf6fda57db90e33bc27fd7c51ff4c40ad156efc Mon Sep 17 00:00:00 2001 From: Henri Rebecq Date: Wed, 21 Aug 2013 11:00:54 +1000 Subject: [PATCH 3/3] Updated SCMB Bridge : added timestamp and embedded content support (additional details, picture, video). --- README.md | 3 ++- bridges/ScmbBridge.php | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5fb1157c..942d96c2 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Supported sites/pages * `Identi.ca` : Identica user timeline (Should be compatible with other Pump.io instances). * `YouTube` : YouTube user channel feed. * `Cryptome` : Returns the most recent documents from Cryptome.org. - * `Se coucher moins bête` : Returns the most recent anecdotes from Secouchermoinsbete.fr + * `Se coucher moins bête` : Returns the most recent anecdotes from Secouchermoinsbete.fr with their embedded content Output format @@ -53,6 +53,7 @@ Patch/contributors : * [Mitsukarenai](https://github.com/Mitsukarenai) : Initial inspiration, TwitterBridge, IdenticaBridge, YoutubeBridge. * [ArthurHoaro](https://github.com/ArthurHoaro) * [BoboTiG](https://github.com/BoboTiG) + * [supitalp](https://github.com/supitalp) : Se coucher moins bête Bridge Licence === diff --git a/bridges/ScmbBridge.php b/bridges/ScmbBridge.php index 496bf42b..6df31964 100644 --- a/bridges/ScmbBridge.php +++ b/bridges/ScmbBridge.php @@ -4,7 +4,7 @@ * Returns the newest anecdotes * * @name Se Coucher Moins Bête Bridge -* @description Returns the newest anecdotes +* @description Returns the newest anecdotes with their embedded content if any (additional details, picture, video) */ class ScmbBridge extends BridgeAbstract{ @@ -16,8 +16,44 @@ class ScmbBridge extends BridgeAbstract{ $item = new \Item(); $item->uri = 'http://secouchermoinsbete.fr'.$article->find('p.summary a',0)->href; $item->title = $article->find('header h1 a',0)->innertext; + $article->find('span.read-more',0)->outertext=''; // remove text "En savoir plus" from anecdote content - $item->content = $article->find('p.summary a',0)->innertext; + $content = $article->find('p.summary a',0)->innertext; + $content =substr($content,0,strlen($content)-17); // remove superfluous spaces at the end + + // get publication date + $str_date = $article->find('time',0)->datetime; + list($date, $time) = explode(' ', $str_date); + list($y, $m, $d) = explode('-', $date); + list($h, $i) = explode(':', $time); + $timestamp = mktime($h,$i,0,$m,$d,$y); + $item->timestamp = $timestamp; + + // TODO: this should be optional since it is highly time and broadband consuming + // check if the anecdote has more content to offer (text details, picture, video) and follow link to retrieve it if that is the case + $optcontent = $article->find('div.metadata-list a'); + $hasPic = (preg_match("#pas#", $optcontent[0]->innertext)) ? false : true; + $hasVid = (preg_match("#pas#", $optcontent[1]->innertext)) ? false : true; + $hasDetails = (preg_match("#pas#", $optcontent[2]->innertext)) ? false : true; + + if($hasDetails || $hasPic || $hasVid) $opt_html = file_get_html($item->uri); + if($hasDetails){ + $details = $opt_html->find('p.details',0)->innertext; + $content = $content . '
' . $details; + } + if($hasPic){ + $picUri = $opt_html->find('div#sources-image-wrapper a',0)->href; + $item->pictureUri = $picUri; + $content = $content . '
'; + } + if($hasVid){ + $vidUri = $opt_html->find('div#sources-video-wrapper iframe',0)->src; + $vidUri = explode('?', $vidUri)[0]; // remove "?autoplay=0" + $item->vidUri = $vidUri; + $content = $content . ' Vidéo'; + } + + $item->content = $content; $this->items[] = $item; } }