YoutubeBridge.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * RssBridgeYoutube
  4. * Returns the newest videos
  5. *
  6. * @name Youtube Bridge
  7. * @description Returns the newest videos
  8. * @use1(u="username")
  9. */
  10. class YoutubeBridge extends BridgeAbstract{
  11. public function collectData(array $param){
  12. $html = file_get_html('https://www.youtube.com/user/'.urlencode($param['u']).'/videos') or $this->returnError('Could not request Youtube.', 404);
  13. foreach($html->find('li.channels-content-item') as $element) {
  14. $item = new \Item();
  15. $item->uri = 'https://www.youtube.com'.$element->find('a',0)->href;
  16. $item->thumbnailUri = 'https:'.$element->find('img',0)->src;
  17. $item->title = trim($element->find('h3',0)->plaintext);
  18. $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br><a href="' . $item->uri . '">' . $item->title . '</a>';
  19. $this->items[] = $item;
  20. }
  21. }
  22. public function getName(){
  23. return 'Youtube Bridge';
  24. }
  25. public function getURI(){
  26. return 'https://www.youtube.com/';
  27. }
  28. public function getCacheDuration(){
  29. return 21600; // 6 hours
  30. }
  31. }