BandcampBridge.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * BandcampTagRSS
  4. *
  5. * @name Bandcamp Tag
  6. * @description New bandcamp release by tag
  7. * @maintainer sebsauvage
  8. * @use1(tag="tag")
  9. */
  10. class BandcampBridge extends BridgeAbstract{
  11. private $request;
  12. public function collectData(array $param){
  13. $html = '';
  14. if (isset($param['tag'])) {
  15. $this->request = $param['tag'];
  16. $html = file_get_html('http://bandcamp.com/tag/'.urlencode($this->request).'?sort_field=date') or $this->returnError('No results for this query.', 404);
  17. }
  18. else {
  19. $this->returnError('You must specify tag (/tag/...)', 400);
  20. }
  21. foreach($html->find('li.item') as $release) {
  22. $item = new \Item();
  23. $item->name = $release->find('div.itemsubtext',0)->plaintext . ' - ' . $release->find('div.itemtext',0)->plaintext;
  24. $item->title = $release->find('div.itemsubtext',0)->plaintext . ' - ' . $release->find('div.itemtext',0)->plaintext;
  25. $item->content = '<img src="' . $release->find('img.art',0)->src . '"/><br/>' . $release->find('div.itemsubtext',0)->plaintext . ' - ' . $release->find('div.itemtext',0)->plaintext;
  26. $item->id = $release->find('a',0)->getAttribute('href');
  27. $item->uri = $release->find('a',0)->getAttribute('href');
  28. $this->items[] = $item;
  29. }
  30. }
  31. public function getName(){
  32. return (!empty($this->request) ? $this->request .' - ' : '') .'Bandcamp Tag';
  33. }
  34. public function getURI(){
  35. return 'http://bandcamp.com';
  36. }
  37. public function getCacheDuration(){
  38. return 600; // 10 minutes
  39. }
  40. }