rss-bridge/bridges/RTBFBridge.php

54 lines
1.7 KiB
PHP
Raw Normal View History

2016-05-10 14:23:43 +03:00
<?php
class RTBFBridge extends BridgeAbstract {
public $name = "RTBF Bridge";
public $uri = "http://www.rtbf.be/auvio/emissions/";
public $description = "Returns the newest RTBF videos by series ID";
public $maintainer = "Frenzie";
2016-05-10 14:23:43 +03:00
public $parameters = array( array(
'c'=>array(
'name'=>'series id',
'exampleValue'=>9500,
'required'=>true
)
));
2016-05-10 14:23:43 +03:00
public function collectData(){
2016-05-10 14:23:43 +03:00
$html = '';
$limit = 10;
$count = 0;
$html = $this->getSimpleHTMLDOM($this->getURI())
or $this->returnServerError('Could not request RTBF.');
2016-05-10 14:23:43 +03:00
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
if($count >= $limit) {
break;
}
$item = array();
$item['id'] = $element->getAttribute('data-id');
$item['uri'] = $this->uri.'detail?id='.$item['id'];
$thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset'));
$thumbnailUriLastSrc = end($thumbnailUriSrcSet);
$thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
$item['title'] = trim($element->find('h3',0)->plaintext) . ' - ' . trim($element->find('h4',0)->plaintext);
$item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime'));
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>';
$this->items[] = $item;
$count++;
2016-05-10 14:23:43 +03:00
}
}
public function getURI(){
return $this->uri.'detail?id='.$this->getInput('c');
}
2016-05-10 14:23:43 +03:00
public function getName(){
return $this->getInput('c') .' - RTBF Bridge';
2016-05-10 14:23:43 +03:00
}
public function getCacheDuration(){
return 21600; // 6 hours
}
}