1
0
Fork 0
forked from blallo/rss-bridge
rss-bridge/bridges/EstCeQuonMetEnProdBridge.php
ORelio 6abca16f06 [EstCeQuonMetEnProd] Add EstCeQuonMetEnProd Bridge
Should we put a website in production today?
2016-07-17 14:40:10 +02:00

56 lines
No EOL
1.9 KiB
PHP

<?php
class EstCeQuonMetEnProdBridge extends BridgeAbstract {
public function loadMetadatas() {
$this->maintainer = 'ORelio';
$this->name = $this->getName();
$this->uri = $this->getURI();
$this->description = $this->getDescription();
$this->update = "02/07/2016";
}
public function collectData(array $param) {
function ExtractFromDelimiters($string, $start, $end) {
if (strpos($string, $start) !== false) {
$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
return $section_retrieved;
} return false;
}
$html = $this->file_get_html($this->getURI()) or $this->returnError('Could not request EstCeQuonMetEnProd: '.$this->getURI(), 500);
$img = $html->find('img', 0);
if (is_object($img)) {
$img = $img->src;
if ($img[0] == '/')
$img = substr($this->getURI(), 0, strlen($this->getURI()) - 1).$img;
}
$item = new \Item();
$item->uri = $this->getURI().'#'.date('Y-m-d');
$item->thumbnailUri = $img;
$item->title = $this->getName();
$item->author = 'Nicolas Hoffmann';
$item->timestamp = strtotime('today midnight');
$item->content = str_replace('src="/', 'src="'.$this->getURI(), trim(ExtractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />')));
$this->items[] = $item;
}
public function getName() {
return 'Est-ce qu\'on met en prod aujourd\'hui ?';
}
public function getURI() {
return 'https://www.estcequonmetenprodaujourdhui.info/';
}
public function getDescription() {
return 'Should we put a website in production today? (French)';
}
public function getCacheDuration() {
return 21600; // 6 hours
}
}
?>