1
0
Fork 0
forked from blallo/rss-bridge

[RTBFBridge] add getURI() + code simplification

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-29 22:04:26 +02:00
parent 08158825d9
commit 9f82adc87b

View file

@ -1,7 +1,7 @@
<?php <?php
class RTBFBridge extends BridgeAbstract { class RTBFBridge extends BridgeAbstract {
public $name = "RTBF Bridge"; public $name = "RTBF Bridge";
public $uri = "http://www.rtbf.be/auvio/emissions"; public $uri = "http://www.rtbf.be/auvio/emissions/";
public $description = "Returns the newest RTBF videos by series ID"; public $description = "Returns the newest RTBF videos by series ID";
public $maintainer = "Frenzie"; public $maintainer = "Frenzie";
@ -18,32 +18,33 @@ class RTBFBridge extends BridgeAbstract {
$limit = 10; $limit = 10;
$count = 0; $count = 0;
if ($this->getInput('c')) { $html = $this->getSimpleHTMLDOM($this->getURI())
$html = $this->getSimpleHTMLDOM('http://www.rtbf.be/auvio/emissions/detail?id='.$this->getInput('c')) or $this->returnServerError('Could not request RTBF.'); or $this->returnServerError('Could not request RTBF.');
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) { foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
if($count < $limit) { if($count >= $limit) {
$item = array(); break;
$item['id'] = $element->getAttribute('data-id'); }
$item['uri'] = 'http://www.rtbf.be/auvio/detail?id='.$item['id']; $item = array();
$thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset')); $item['id'] = $element->getAttribute('data-id');
$thumbnailUriLastSrc = end($thumbnailUriSrcSet); $item['uri'] = $this->uri.'detail?id='.$item['id'];
$thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0]; $thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset'));
$item['title'] = trim($element->find('h3',0)->plaintext) . ' - ' . trim($element->find('h4',0)->plaintext); $thumbnailUriLastSrc = end($thumbnailUriSrcSet);
$item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime')); $thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>'; $item['title'] = trim($element->find('h3',0)->plaintext) . ' - ' . trim($element->find('h4',0)->plaintext);
$this->items[] = $item; $item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime'));
$count++; $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>';
} $this->items[] = $item;
} $count++;
}
else {
$this->returnClientError('You must specify a series id.');
} }
} }
public function getURI(){
return $this->uri.'detail?id='.$this->getInput('c');
}
public function getName(){ public function getName(){
return (!empty($this->request) ? $this->request .' - ' : '') .'RTBF Bridge'; return $this->getInput('c') .' - RTBF Bridge';
} }
public function getCacheDuration(){ public function getCacheDuration(){