1
0

BandcampBridge.php 1.7 KB

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