RTBFBridge.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. class RTBFBridge extends BridgeAbstract {
  3. const NAME = "RTBF Bridge";
  4. const URI = "http://www.rtbf.be/auvio/emissions/";
  5. const DESCRIPTION = "Returns the newest RTBF videos by series ID";
  6. const MAINTAINER = "Frenzie";
  7. const PARAMETERS = array( array(
  8. 'c'=>array(
  9. 'name'=>'series id',
  10. 'exampleValue'=>9500,
  11. 'required'=>true
  12. )
  13. ));
  14. public function collectData(){
  15. $html = '';
  16. $limit = 10;
  17. $count = 0;
  18. $html = $this->getSimpleHTMLDOM($this->getURI())
  19. or $this->returnServerError('Could not request RTBF.');
  20. foreach($html->find('section[id!=widget-ml-avoiraussi-] .rtbf-media-grid article') as $element) {
  21. if($count >= $limit) {
  22. break;
  23. }
  24. $item = array();
  25. $item['id'] = $element->getAttribute('data-id');
  26. $item['uri'] = self::URI.'detail?id='.$item['id'];
  27. $thumbnailUriSrcSet = explode(',', $element->find('figure .www-img-16by9 img', 0)->getAttribute('data-srcset'));
  28. $thumbnailUriLastSrc = end($thumbnailUriSrcSet);
  29. $thumbnailUri = explode(' ', $thumbnailUriLastSrc)[0];
  30. $item['title'] = trim($element->find('h3',0)->plaintext) . ' - ' . trim($element->find('h4',0)->plaintext);
  31. $item['timestamp'] = strtotime($element->find('time', 0)->getAttribute('datetime'));
  32. $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>';
  33. $this->items[] = $item;
  34. $count++;
  35. }
  36. }
  37. public function getURI(){
  38. return self::URI.'detail?id='.$this->getInput('c');
  39. }
  40. public function getName(){
  41. return $this->getInput('c') .' - RTBF Bridge';
  42. }
  43. public function getCacheDuration(){
  44. return 21600; // 6 hours
  45. }
  46. }