1
0

DollbooruBridge.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * RssBridgeDollbooru
  4. * Returns images from given page
  5. * 2015-01-20
  6. *
  7. * @name Dollbooru
  8. * @homepage http://dollbooru.org/
  9. * @description Returns images from given page
  10. * @maintainer mitsukarenai
  11. * @use1(p="page", t="tags")
  12. */
  13. class DollbooruBridge extends BridgeAbstract{
  14. public function collectData(array $param){
  15. $page = 0;$tags='';
  16. if (isset($param['p'])) {
  17. $page = (int)preg_replace("/[^0-9]/",'', $param['p']);
  18. }
  19. if (isset($param['t'])) {
  20. $tags = urlencode($param['t']);
  21. }
  22. $html = file_get_html("http://dollbooru.org/post/list/$tags/$page") or $this->returnError('Could not request Dollbooru.', 404);
  23. foreach($html->find('div[class=shm-image-list] a') as $element) {
  24. $item = new \Item();
  25. $item->uri = 'http://dollbooru.org'.$element->href;
  26. $item->postid = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('data-post-id'));
  27. $item->timestamp = time();
  28. $item->thumbnailUri = 'http://dollbooru.org'.$element->find('img', 0)->src;
  29. $item->tags = $element->getAttribute('data-tags');
  30. $item->title = 'Dollbooru | '.$item->postid;
  31. $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br>Tags: '.$item->tags;
  32. $this->items[] = $item;
  33. }
  34. }
  35. public function getName(){
  36. return 'Dollbooru';
  37. }
  38. public function getURI(){
  39. return 'http://dollbooru.org/';
  40. }
  41. public function getCacheDuration(){
  42. return 1800; // 30 minutes
  43. }
  44. }