mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-22 16:13:35 +02:00
[bridges] Change to extend from FeedExpander
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
class DauphineLibereBridge extends BridgeAbstract {
|
||||
class DauphineLibereBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = "qwertygc";
|
||||
const NAME = "Dauphine Bridge";
|
||||
const URI = "http://www.ledauphine.com/";
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
const MAINTAINER = "qwertygc";
|
||||
const NAME = "Dauphine Bridge";
|
||||
const URI = "http://www.ledauphine.com/";
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'u'=>array(
|
||||
@@ -30,41 +30,31 @@ class DauphineLibereBridge extends BridgeAbstract {
|
||||
)
|
||||
));
|
||||
|
||||
private function ExtractContent($url, $context) {
|
||||
$html2 = $this->getSimpleHTMLDOM($url);
|
||||
$text = $html2->find('div.column', 0)->innertext;
|
||||
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
|
||||
return $text;
|
||||
}
|
||||
public function collectData(){
|
||||
$url = self::URI . 'rss';
|
||||
|
||||
public function collectData(){
|
||||
if (empty($this->getInput('u'))) {
|
||||
$url = self::URI . $this->getInput('u') . '/rss';
|
||||
}
|
||||
|
||||
$context = stream_context_create($opts);
|
||||
$this->collectExpandableDatas($url);
|
||||
}
|
||||
|
||||
if (empty($this->getInput('u'))) {
|
||||
$html = $this->getSimpleHTMLDOM(self::URI.$this->getInput('u').'/rss')
|
||||
or $this->returnServerError('Could not request DauphineLibere.');
|
||||
} else {
|
||||
$html = $this->getSimpleHTMLDOM(self::URI.'rss')
|
||||
or $this->returnServerError('Could not request DauphineLibere.');
|
||||
}
|
||||
$limit = 0;
|
||||
protected function parseItem($newsItem){
|
||||
$item = $this->parseRSS_2_0_Item($newsItem);
|
||||
$item['content'] = $this->ExtractContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
foreach($html->find('item') as $element) {
|
||||
if($limit < 10) {
|
||||
$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'] = $this->ExtractContent($item['uri'], $context);
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
private function ExtractContent($url) {
|
||||
$html2 = $this->getSimpleHTMLDOM($url);
|
||||
$text = $html2->find('div.column', 0)->innertext;
|
||||
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 3600*2; // 2 hours
|
||||
}
|
||||
public function getCacheDuration(){
|
||||
return 3600*2; // 2 hours
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user