From 244516f0a29329f47c7eb9953b66b91cc218a5a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Wed, 14 Sep 2016 13:32:34 +0200 Subject: [PATCH] [GizmodoFRBridge => GizmodoBridge] rename and make it a FeedExpander MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/GizmodoBridge.php | 35 +++++++++++++++++++++++++++ bridges/GizmodoFRBridge.php | 48 ------------------------------------- 2 files changed, 35 insertions(+), 48 deletions(-) create mode 100644 bridges/GizmodoBridge.php delete mode 100644 bridges/GizmodoFRBridge.php diff --git a/bridges/GizmodoBridge.php b/bridges/GizmodoBridge.php new file mode 100644 index 0000000..0fc80a5 --- /dev/null +++ b/bridges/GizmodoBridge.php @@ -0,0 +1,35 @@ +getSimpleHTMLDOMCached($item['uri']); + if(!$articleHTMLContent){ + $text = 'Could not load '.$item['uri']; + }else{ + $text = $articleHTMLContent->find('div.entry-content', 0)->innertext; + foreach($articleHTMLContent->find('pagespeed_iframe') as $element) { + $text .= '

link to a iframe (could be a video): '.$element->src.'


'; + } + + $text = strip_tags($text, '

'); + } + + $item['content'] = $text; + return $item; + } + + public function collectData(){ + $this->collectExpandableDatas('http://feeds.gawker.com/gizmodo/full'); + } + + public function getCacheDuration(){ + return 1800; // 30min + } +} diff --git a/bridges/GizmodoFRBridge.php b/bridges/GizmodoFRBridge.php deleted file mode 100644 index e653130..0000000 --- a/bridges/GizmodoFRBridge.php +++ /dev/null @@ -1,48 +0,0 @@ -getSimpleHTMLDOM($url); - if(!$articleHTMLContent){ - return 'Could not load '.$url; - } - $text = $articleHTMLContent->find('div.entry-thumbnail', 0)->innertext; - $text = $text.$articleHTMLContent->find('div.entry-excerpt', 0)->innertext; - $text = $text.$articleHTMLContent->find('div.entry-content', 0)->innertext; - foreach($articleHTMLContent->find('pagespeed_iframe') as $element) { - $text = $text.'

link to a iframe (could be a video): '.$element->src.'


'; - } - - $text = strip_tags($text, '

'); - return $text; - } - - $rssFeed = $this->getSimpleHTMLDOM(self::URI.'/feed') - or $this->returnServerError('Could not request '.self::URI.'/feed'); - $limit = 0; - - foreach($rssFeed->find('item') as $element) { - if($limit < 15) { - $item = array(); - $item['title'] = $element->find('title', 0)->innertext; - $item['uri'] = $element->find('guid', 0)->plaintext; - $item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext); - $item['content'] = GizmodoFRExtractContent($item['uri']); - $this->items[] = $item; - $limit++; - } - } - - } - - public function getCacheDuration(){ - return 1800; // 30min - } -}