Shimmie2Bridge.php 1020 B

123456789101112131415161718192021222324252627282930313233343536373839
  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()
  11. . 'post/list/'
  12. . $this->getInput('t')
  13. . '/'
  14. . $this->getInput('p');
  15. }
  16. protected function getItemFromElement($element){
  17. $item = array();
  18. $item['uri'] = $this->getURI() . $element->href;
  19. $item['id'] = (int)preg_replace('/[^0-9]/', '', $element->getAttribute(static::IDATTRIBUTE));
  20. $item['timestamp'] = time();
  21. $thumbnailUri = $this->getURI() . $element->find('img', 0)->src;
  22. $item['tags'] = $element->getAttribute('data-tags');
  23. $item['title'] = $this->getName() . ' | ' . $item['id'];
  24. $item['content'] = '<a href="'
  25. . $item['uri']
  26. . '"><img src="'
  27. . $thumbnailUri
  28. . '" /></a><br>Tags: '
  29. . $item['tags'];
  30. return $item;
  31. }
  32. }