Rule34pahealBridge.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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->update = "2014-05-25";
  9. $this->parameters[] =
  10. '[
  11. {
  12. "name" : "page",
  13. "identifier" : "p",
  14. "type" : "number"
  15. },
  16. {
  17. "name" : "tags",
  18. "identifier" : "t"
  19. }
  20. ]';
  21. }
  22. public function collectData(array $param){
  23. $page = 0;$tags='';
  24. if (isset($param['p'])) {
  25. $page = (int)preg_replace("/[^0-9]/",'', $param['p']);
  26. }
  27. if (isset($param['t'])) {
  28. $tags = urlencode($param['t']);
  29. }
  30. $html = $this->file_get_html("http://rule34.paheal.net/post/list/$tags/$page") or $this->returnError('Could not request Rule34paheal.', 404);
  31. foreach($html->find('div[class=shm-image-list] div[class=shm-thumb]') as $element) {
  32. $item = new \Item();
  33. $item->uri = 'http://rule34.paheal.net'.$element->find('a', 0)->href;
  34. $item->postid = (int)preg_replace("/[^0-9]/",'', $element->find('img', 0)->getAttribute('id'));
  35. $item->timestamp = time();
  36. $item->thumbnailUri = $element->find('img', 0)->src;
  37. $item->tags = $element->getAttribute('data-tags');
  38. $item->title = 'Rule34paheal | '.$item->postid;
  39. $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br>Tags: '.$item->tags;
  40. $this->items[] = $item;
  41. }
  42. }
  43. public function getName(){
  44. return 'Rule34paheal';
  45. }
  46. public function getURI(){
  47. return 'http://rule34.paheal.net/';
  48. }
  49. public function getCacheDuration(){
  50. return 1800; // 30 minutes
  51. }
  52. }