2014-05-26 02:30:46 +04:00
|
|
|
<?php
|
2016-09-04 02:19:54 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
class BooruprojectBridge extends DanbooruBridge
|
|
|
|
{
|
|
|
|
const MAINTAINER = 'mitsukarenai';
|
|
|
|
const NAME = 'Booruproject';
|
|
|
|
const URI = 'https://booru.org/';
|
|
|
|
const DESCRIPTION = 'Returns images from given page of booruproject';
|
|
|
|
const PARAMETERS = [
|
|
|
|
'global' => [
|
|
|
|
'p' => [
|
|
|
|
'name' => 'page',
|
|
|
|
'defaultValue' => 0,
|
|
|
|
'type' => 'number'
|
|
|
|
],
|
|
|
|
't' => [
|
|
|
|
'name' => 'tags',
|
|
|
|
'required' => true,
|
|
|
|
'exampleValue' => 'tagme',
|
|
|
|
'title' => 'Use "all" to get all posts'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'Booru subdomain (subdomain.booru.org)' => [
|
|
|
|
'i' => [
|
|
|
|
'name' => 'Subdomain',
|
|
|
|
'required' => true,
|
|
|
|
'exampleValue' => 'rm'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
const PATHTODATA = '.thumb';
|
|
|
|
const IDATTRIBUTE = 'id';
|
|
|
|
const TAGATTRIBUTE = 'title';
|
|
|
|
const PIDBYPAGE = 20;
|
2016-08-28 13:14:36 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
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'));
|
|
|
|
}
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
protected function getTags($element)
|
|
|
|
{
|
|
|
|
$tags = parent::getTags($element);
|
|
|
|
$tags = explode(' ', $tags);
|
2022-03-29 23:42:09 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
// Remove statistics from the tags list (identified by colon)
|
|
|
|
foreach ($tags as $key => $tag) {
|
|
|
|
if (strpos($tag, ':') !== false) {
|
|
|
|
unset($tags[$key]);
|
|
|
|
}
|
|
|
|
}
|
2022-03-29 23:42:09 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
return implode(' ', $tags);
|
|
|
|
}
|
2022-03-29 23:42:09 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
if (!is_null($this->getInput('i'))) {
|
|
|
|
return 'https://' . $this->getInput('i') . '.booru.org/';
|
|
|
|
}
|
2022-03-29 23:42:09 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
return parent::getURI();
|
|
|
|
}
|
2017-02-15 00:36:33 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
if (!is_null($this->getInput('i'))) {
|
|
|
|
return static::NAME . ' ' . $this->getInput('i');
|
|
|
|
}
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
return parent::getName();
|
|
|
|
}
|
2014-05-26 02:30:46 +04:00
|
|
|
}
|