TbibBridge.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * RssBridgeTbib
  4. * Returns images from given page
  5. * 2014-05-25
  6. *
  7. * @name Tbib
  8. * @homepage http://tbib.org/
  9. * @description Returns images from given page
  10. * @maintainer mitsukarenai
  11. * @use1(p="page",t="tags")
  12. */
  13. class TbibBridge 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. $page = $page - 1;
  19. $page = $page * 50;
  20. }
  21. if (isset($param['t'])) {
  22. $tags = urlencode($param['t']);
  23. }
  24. $html = file_get_html("http://tbib.org/index.php?page=post&s=list&tags=$tags&pid=$page") or $this->returnError('Could not request Tbib.', 404);
  25. foreach($html->find('div[class=content] span') as $element) {
  26. $item = new \Item();
  27. $item->uri = 'http://tbib.org/'.$element->find('a', 0)->href;
  28. $item->postid = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
  29. $item->timestamp = time();
  30. $item->thumbnailUri = $element->find('img', 0)->src;
  31. $item->tags = $element->find('img', 0)->getAttribute('alt');
  32. $item->title = 'Tbib | '.$item->postid;
  33. $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br>Tags: '.$item->tags;
  34. $this->items[] = $item;
  35. }
  36. }
  37. public function getName(){
  38. return 'Tbib';
  39. }
  40. public function getURI(){
  41. return 'http://tbib.org/';
  42. }
  43. public function getCacheDuration(){
  44. return 1800; // 30 minutes
  45. }
  46. }