Shimmie2Bridge.php 1020 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. require_once('DanbooruBridge.php');
  3. class Shimmie2Bridge extends DanbooruBridge{
  4. const NAME = "Shimmie v2";
  5. const URI = "http://shimmie.shishnet.org/v2/";
  6. const DESCRIPTION = "Returns images from given page";
  7. const PATHTODATA='.shm-thumb-link';
  8. const IDATTRIBUTE='data-post-id';
  9. protected function getFullURI(){
  10. return $this->getURI().'post/list/'
  11. .$this->getInput('t').'/'
  12. .$this->getInput('p');
  13. }
  14. protected function getItemFromElement($element){
  15. $item = array();
  16. $item['uri'] = $this->getURI().$element->href;
  17. $item['id'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute(static::IDATTRIBUTE));
  18. $item['timestamp'] = time();
  19. $thumbnailUri = $this->getURI().$element->find('img', 0)->src;
  20. $item['tags'] = $element->getAttribute('data-tags');
  21. $item['title'] = $this->getName().' | '.$item['id'];
  22. $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
  23. return $item;
  24. }
  25. }