forked from blallo/rss-bridge
commit
a84f11aed8
1 changed files with 33 additions and 40 deletions
|
@ -1,25 +1,19 @@
|
|||
<?php
|
||||
class BastaBridge extends BridgeAbstract{
|
||||
|
||||
public function loadMetadatas() {
|
||||
|
||||
$this->maintainer = "qwertygc";
|
||||
$this->name = "Bastamag Bridge";
|
||||
$this->uri = "http://www.bastamag.net/";
|
||||
$this->description = "Returns the newest articles.";
|
||||
$this->update = "2014-05-25";
|
||||
|
||||
$this->update = "2016-08-02";
|
||||
}
|
||||
|
||||
|
||||
public function collectData(array $param){
|
||||
|
||||
|
||||
function BastaExtractContent($url) {
|
||||
$html2 = $this->file_get_html($url);
|
||||
$text = $html2->find('div.texte', 0)->innertext;
|
||||
return $text;
|
||||
// Replaces all relative image URLs by absolute URLs. Relative URLs always start with 'local/'!
|
||||
function ReplaceImageUrl($content){
|
||||
return preg_replace('/src=["\']{1}([^"\']+)/ims', 'src=\'http://www.bastamag.net/$1\'', $content);
|
||||
}
|
||||
|
||||
$html = $this->file_get_html('http://www.bastamag.net/spip.php?page=backend') or $this->returnError('Could not request Bastamag.', 404);
|
||||
$limit = 0;
|
||||
|
||||
|
@ -28,13 +22,12 @@ class BastaBridge extends BridgeAbstract{
|
|||
$item = new \Item();
|
||||
$item->title = $element->find('title', 0)->innertext;
|
||||
$item->uri = $element->find('guid', 0)->plaintext;
|
||||
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
|
||||
$item->content = BastaExtractContent($item->uri);
|
||||
$item->timestamp = strtotime($element->find('dc:date', 0)->plaintext);
|
||||
$item->content = ReplaceImageUrl($this->file_get_html($item->uri)->find('div.texte', 0)->innertext);
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
|
@ -47,6 +40,6 @@ class BastaBridge extends BridgeAbstract{
|
|||
|
||||
public function getCacheDuration(){
|
||||
return 3600*2; // 2 hours
|
||||
// return 0; // 2 hours
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue