summaryrefslogtreecommitdiff
path: root/bridges/GelbooruBridge.php
blob: 4fe30e2170313e026ddbbe037897a346f8ca4b0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once('DanbooruBridge.php');

class GelbooruBridge extends DanbooruBridge {

	const MAINTAINER = 'mitsukarenai';
	const NAME = 'Gelbooru';
	const URI = 'http://gelbooru.com/';
	const DESCRIPTION = 'Returns images from given page';

	const PATHTODATA = '.thumb';
	const IDATTRIBUTE = 'id';
	const TAGATTRIBUTE = 'title';

	const PIDBYPAGE = 63;

	protected function getFullURI(){
		return $this->getURI()
		. 'index.php?page=post&s=list&pid='
		. ($this->getInput('p') ? ($this->getInput('p') - 1) * static::PIDBYPAGE : '')
		. '&tags=' . urlencode($this->getInput('t'));
	}

	protected function getTags($element){
		$tags = parent::getTags($element);
		$tags = explode(' ', $tags);

		// Remove statistics from the tags list (identified by colon)
		foreach($tags as $key => $tag) {
			if(strpos($tag, ':') !== false) unset($tags[$key]);
		}

		return implode(' ', $tags);
	}
}