[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,14 +18,16 @@ 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) {
break;
}
$item = array(); $item = array();
$item['id'] = $element->getAttribute('data-id'); $item['id'] = $element->getAttribute('data-id');
$item['uri'] = 'http://www.rtbf.be/auvio/detail?id='.$item['id']; $item['uri'] = $this->uri.'detail?id='.$item['id'];
$thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset')); $thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset'));
$thumbnailUriLastSrc = end($thumbnailUriSrcSet); $thumbnailUriLastSrc = end($thumbnailUriSrcSet);
$thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0]; $thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
@ -36,14 +38,13 @@ class RTBFBridge extends BridgeAbstract {
$count++; $count++;
} }
} }
}
else { public function getURI(){
$this->returnClientError('You must specify a series id.'); 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(){