[RTBFBridge] add getURI() + code simplification
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
08158825d9
commit
9f82adc87b
1 changed files with 23 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
class RTBFBridge extends BridgeAbstract {
|
||||
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 $maintainer = "Frenzie";
|
||||
|
||||
|
@ -18,32 +18,33 @@ class RTBFBridge extends BridgeAbstract {
|
|||
$limit = 10;
|
||||
$count = 0;
|
||||
|
||||
if ($this->getInput('c')) {
|
||||
$html = $this->getSimpleHTMLDOM('http://www.rtbf.be/auvio/emissions/detail?id='.$this->getInput('c')) or $this->returnServerError('Could not request RTBF.');
|
||||
$html = $this->getSimpleHTMLDOM($this->getURI())
|
||||
or $this->returnServerError('Could not request RTBF.');
|
||||
|
||||
foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
|
||||
if($count < $limit) {
|
||||
$item = array();
|
||||
$item['id'] = $element->getAttribute('data-id');
|
||||
$item['uri'] = 'http://www.rtbf.be/auvio/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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->returnClientError('You must specify a series id.');
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
return $this->uri.'detail?id='.$this->getInput('c');
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return (!empty($this->request) ? $this->request .' - ' : '') .'RTBF Bridge';
|
||||
return $this->getInput('c') .' - RTBF Bridge';
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
|
|
Loading…
Reference in a new issue