Rule34pahealBridge.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. class Rule34pahealBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "mitsukarenai";
  5. $this->name = "Rule34paheal";
  6. $this->uri = "http://rule34.paheal.net/";
  7. $this->description = "Returns images from given page";
  8. $this->parameters[] = array(
  9. 'p'=>array(
  10. 'name'=>'page',
  11. 'type'=>'number'
  12. ),
  13. 't'=>array('name'=>'tags')
  14. );
  15. }
  16. public function collectData(array $param){
  17. $page = 0;$tags='';
  18. if (isset($param['p'])) {
  19. $page = (int)preg_replace("/[^0-9]/",'', $param['p']);
  20. }
  21. if (isset($param['t'])) {
  22. $tags = urlencode($param['t']);
  23. }
  24. $html = $this->getSimpleHTMLDOM("http://rule34.paheal.net/post/list/$tags/$page") or $this->returnServerError('Could not request Rule34paheal.');
  25. foreach($html->find('div[class=shm-image-list] div[class=shm-thumb]') as $element) {
  26. $item = array();
  27. $item['uri'] = 'http://rule34.paheal.net'.$element->find('a', 0)->href;
  28. $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('img', 0)->getAttribute('id'));
  29. $item['timestamp'] = time();
  30. $thumbnailUri = $element->find('img', 0)->src;
  31. $item['tags'] = $element->getAttribute('data-tags');
  32. $item['title'] = 'Rule34paheal | '.$item['postid'];
  33. $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
  34. $this->items[] = $item;
  35. }
  36. }
  37. public function getCacheDuration(){
  38. return 1800; // 30 minutes
  39. }
  40. }