BandcampBridge.php 1.6 KB

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