2016-05-10 14:23:43 +03:00
|
|
|
<?php
|
|
|
|
class RTBFBridge extends BridgeAbstract {
|
2016-08-30 12:23:55 +03:00
|
|
|
const NAME = "RTBF Bridge";
|
|
|
|
const URI = "http://www.rtbf.be/auvio/emissions/";
|
2016-09-25 18:04:28 +03:00
|
|
|
const CACHE_TIMEOUT = 21600; //6h
|
2016-08-30 12:23:55 +03:00
|
|
|
const DESCRIPTION = "Returns the newest RTBF videos by series ID";
|
|
|
|
const MAINTAINER = "Frenzie";
|
2016-05-10 14:23:43 +03:00
|
|
|
|
2016-08-30 12:23:55 +03:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 22:03:26 +03:00
|
|
|
'c'=>array(
|
2016-08-22 02:25:56 +03:00
|
|
|
'name'=>'series id',
|
|
|
|
'exampleValue'=>9500,
|
|
|
|
'required'=>true
|
2016-08-27 22:03:26 +03:00
|
|
|
)
|
|
|
|
));
|
2016-05-10 14:23:43 +03:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2016-05-10 14:23:43 +03:00
|
|
|
$html = '';
|
|
|
|
$limit = 10;
|
|
|
|
$count = 0;
|
|
|
|
|
2016-09-26 00:22:33 +03:00
|
|
|
$html = getSimpleHTMLDOM($this->getURI())
|
|
|
|
or returnServerError('Could not request RTBF.');
|
2016-05-10 14:23:43 +03:00
|
|
|
|
2016-08-29 23:04:26 +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');
|
2016-08-30 12:23:55 +03:00
|
|
|
$item['uri'] = self::URI.'detail?id='.$item['id'];
|
2016-08-29 23:04:26 +03:00
|
|
|
$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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-29 23:04:26 +03:00
|
|
|
public function getURI(){
|
2016-08-30 12:23:55 +03:00
|
|
|
return self::URI.'detail?id='.$this->getInput('c');
|
2016-08-29 23:04:26 +03:00
|
|
|
}
|
|
|
|
|
2016-05-10 14:23:43 +03:00
|
|
|
public function getName(){
|
2016-08-29 23:04:26 +03:00
|
|
|
return $this->getInput('c') .' - RTBF Bridge';
|
2016-05-10 14:23:43 +03:00
|
|
|
}
|
|
|
|
}
|