forked from blallo/rss-bridge
Merge pull request #303 from LogMANOriginal/CommonDreamsBridge
CommonDreamsBridge
This commit is contained in:
commit
0052f25d2a
1 changed files with 35 additions and 39 deletions
|
@ -2,21 +2,11 @@
|
||||||
class CommonDreamsBridge extends BridgeAbstract{
|
class CommonDreamsBridge extends BridgeAbstract{
|
||||||
|
|
||||||
public function loadMetadatas() {
|
public function loadMetadatas() {
|
||||||
|
|
||||||
$this->maintainer = "nyutag";
|
$this->maintainer = "nyutag";
|
||||||
$this->name = "CommonDreams Bridge";
|
$this->name = "CommonDreams Bridge";
|
||||||
$this->uri = "http://www.commondreams.org/";
|
$this->uri = "http://www.commondreams.org/";
|
||||||
$this->description = "Returns the newest articles.";
|
$this->description = "Returns the newest articles.";
|
||||||
$this->update = "2015-04-03";
|
$this->update = "2016-08-02";
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function collectData(array $param){
|
|
||||||
|
|
||||||
function CommonDreamsUrl($string) {
|
|
||||||
$html2 = explode(" ", $string);
|
|
||||||
$string = $html2[2] . "/node/" . $html2[0];
|
|
||||||
return $string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CommonDreamsExtractContent($url) {
|
function CommonDreamsExtractContent($url) {
|
||||||
|
@ -27,6 +17,14 @@ class CommonDreamsBridge extends BridgeAbstract{
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function collectData(array $param){
|
||||||
|
|
||||||
|
function CommonDreamsUrl($string) {
|
||||||
|
$html2 = explode(" ", $string);
|
||||||
|
$string = $html2[2] . "/node/" . $html2[0];
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
$html = $this->file_get_html('http://www.commondreams.org/rss.xml') or $this->returnError('Could not request CommonDreams.', 404);
|
$html = $this->file_get_html('http://www.commondreams.org/rss.xml') or $this->returnError('Could not request CommonDreams.', 404);
|
||||||
$limit = 0;
|
$limit = 0;
|
||||||
foreach($html->find('item') as $element) {
|
foreach($html->find('item') as $element) {
|
||||||
|
@ -35,12 +33,11 @@ class CommonDreamsBridge extends BridgeAbstract{
|
||||||
$item->title = $element->find('title', 0)->innertext;
|
$item->title = $element->find('title', 0)->innertext;
|
||||||
$item->uri = CommonDreamsUrl($element->find('guid', 0)->innertext);
|
$item->uri = CommonDreamsUrl($element->find('guid', 0)->innertext);
|
||||||
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
|
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
|
||||||
$item->content = CommonDreamsExtractContent($item->uri);
|
$item->content = $this->CommonDreamsExtractContent($item->uri);
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
$limit++;
|
$limit++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
@ -53,6 +50,5 @@ class CommonDreamsBridge extends BridgeAbstract{
|
||||||
|
|
||||||
public function getCacheDuration(){
|
public function getCacheDuration(){
|
||||||
return 3600; // 1 hours
|
return 3600; // 1 hours
|
||||||
// return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue