1
0
Fork 0
forked from blallo/rss-bridge

[bridges] Gelbooru based imageboards derive form DanbooruBridge

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-09-04 01:19:54 +02:00
parent 97926b839e
commit 8ae05a0241
7 changed files with 54 additions and 230 deletions

View file

@ -1,48 +1,36 @@
<?php <?php
class BooruprojectBridge extends BridgeAbstract{ require_once('GelbooruBridge.php');
class BooruprojectBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Booruproject"; const NAME = "Booruproject";
const URI = "http://booru.org/"; const URI = "http://booru.org/";
const DESCRIPTION = "Returns images from given page and booruproject instance (****.booru.org)"; const DESCRIPTION = "Returns images from given page of booruproject";
const PARAMETERS = array( array( const PARAMETERS = array(
'i'=>array( 'global'=>array(
'name'=>'instance (required)', 'p'=>array(
'required'=>true 'name'=>'page',
), 'type'=>'number'
'p'=>array( ),
'name'=>'page', 't'=>array('name'=>'tags')
'type'=>'number' ),
), 'Booru subdomain (subdomain.booru.org)'=>array(
't'=>array('name'=>'tags') 'i'=>array(
)); 'name'=>'Subdomain',
'required'=>true
)
)
);
function getURI(){ const PIDBYPAGE=20;
return 'http://'.$this->getInput('i').'.booru.org/';
public function getURI(){
return 'http://'.$this->getInput('i').'.booru.org/';
} }
public function collectData(){ public function getName(){
$html = $this->getSimpleHTMLDOM( return static::NAME . ' ' . $this->getInput('i');
$this->getURI().'index.php?page=post&s=list'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*20:'')
.'&tags='.urlencode($this->getInput('t'))
) or $this->returnServerError('Could not request Booruprojec.');
foreach($html->find('div[class=content] span') as $element) {
$item = array();
$item['uri'] = $this->getURI().$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('a', 0)->getAttribute('id'));
$item['timestamp'] = time();
$item['tags'] = $element->find('img', 0)->getAttribute('title');
$item['title'] = 'Booruproject '.$this->getInput('i').' | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $element->find('img', 0)->src . '" /></a><br>Tags: '.$item['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
} }
} }

View file

@ -1,40 +1,21 @@
<?php <?php
class GelbooruBridge extends BridgeAbstract{ require_once('DanbooruBridge.php');
class GelbooruBridge extends DanbooruBridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Gelbooru"; const NAME = "Gelbooru";
const URI = "http://gelbooru.com/"; const URI = "http://gelbooru.com/";
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = "Returns images from given page";
const PARAMETERS = array( array( const PATHTODATA='.thumb';
'p'=>array( const IDATTRIBUTE='id';
'name'=>'page',
'type'=>'number'
),
't'=>array('name'=>'tags')
));
public function collectData(){ const PIDBYPAGE=63;
$html = $this->getSimpleHTMLDOM(
self::URI.'index.php?page=post&s=list&'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*63:'')
.'&tags='.urlencode($this->getInput('t'))
) or $this->returnServerError('Could not request Gelbooru.');
foreach($html->find('div[class=content] span') as $element) { protected function getFullURI(){
$item = array(); return $this->getURI().'index.php?page=post&s=list&'
$item['uri'] = self::URI.$element->find('a', 0)->href; .'&pid='.($this->getInput('p')?($this->getInput('p') -1)*static::PIDBYPAGE:'')
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id')); .'&tags='.urlencode($this->getInput('t'));
$item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src;
$item['tags'] = $element->find('img', 0)->getAttribute('alt');
$item['title'] = 'Gelbooru | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
} }
} }

View file

@ -1,42 +1,12 @@
<?php <?php
class MspabooruBridge extends BridgeAbstract{ require_once('GelbooruBridge.php');
class MspabooruBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Mspabooru"; const NAME = "Mspabooru";
const URI = "http://mspabooru.com/"; const URI = "http://mspabooru.com/";
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = "Returns images from given page";
const PARAMETERS = array( array( const PIDBYPAGE=50;
'p'=>array(
'name'=>'page',
'type'=>'number'
),
't'=>array('name'=>'tags')
));
public function collectData(){
$html = $this->getSimpleHTMLDOM(
self::URI.'index.php?page=post&s=list&'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'')
.'&tags='.urlencode($this->getInput('t'))
) or $this->returnServerError('Could not request Mspabooru.');
foreach($html->find('div[class=content] span') as $element) {
$item = array();
$item['uri'] = self::URI.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
$item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src;
$item['tags'] = $element->find('img', 0)->getAttribute('alt');
$item['title'] = 'Mspabooru | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
}
} }

View file

@ -1,41 +1,12 @@
<?php <?php
class Rule34Bridge extends BridgeAbstract{ require_once('GelbooruBridge.php');
class Rule34Bridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Rule34"; const NAME = "Rule34";
const URI = "http://rule34.xxx/"; const URI = "http://rule34.xxx/";
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = "Returns images from given page";
const PARAMETERS = array( array( const PIDBYPAGE=50;
'p'=>array(
'name'=>'page',
'type'=>'number'
),
't'=>array('name'=>'tags')
));
public function collectData(){
$html = $this->getSimpleHTMLDOM(
self::URI.'index.php?page=post&s=list&'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'')
.'&tags='.urlencode($this->getInput('t'))
) or $this->returnServerError('Could not request Rule34.');
foreach($html->find('div[class=content] span') as $element) {
$item = array();
$item['uri'] = self::URI.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
$item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src;
$item['tags'] = $element->find('img', 0)->getAttribute('alt');
$item['title'] = 'Rule34 | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
}
} }

View file

@ -1,40 +1,12 @@
<?php <?php
class SafebooruBridge extends BridgeAbstract{ require_once('GelbooruBridge.php');
class SafebooruBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Safebooru"; const NAME = "Safebooru";
const URI = "http://safebooru.org/"; const URI = "http://safebooru.org/";
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = "Returns images from given page";
const PARAMETERS = array( array( const PIDBYPAGE=40;
'p'=>array(
'name'=>'page',
'type'=>'number'
),
't'=>array('name'=>'tags')
));
public function collectData(){
$html = $this->getSimpleHTMLDOM(
self::URI.'index.php?page=post&s=list&'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*40:'')
.'&tags='.urlencode($this->getInput('t'))
) or $this->returnServerError('Could not request Safebooru.');
foreach($html->find('div[class=content] span') as $element) {
$item = array();
$item['uri'] = self::URI.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
$item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src;
$item['tags'] = $element->find('img', 0)->getAttribute('alt');
$item['title'] = 'Safebooru | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
}
} }

View file

@ -1,41 +1,12 @@
<?php <?php
class TbibBridge extends BridgeAbstract{ require_once('GelbooruBridge.php');
class TbibBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Tbib"; const NAME = "Tbib";
const URI = "http://tbib.org/"; const URI = "http://tbib.org/";
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = "Returns images from given page";
const PARAMETERS = array( array( const PIDBYPAGE=50;
'p'=>array(
'name'=>'page',
'type'=>'number'
),
't'=>array('name'=>'tags')
));
public function collectData(){
$html = $this->getSimpleHTMLDOM(
self::URI.'index.php?page=post&s=list&'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'')
.'&tags='.urlencode($this->getInput('t'))
) or $this->returnServerError('Could not request Tbib.');
foreach($html->find('div[class=content] span') as $element) {
$item = array();
$item['uri'] = self::URI.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
$item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src;
$item['tags'] = $element->find('img', 0)->getAttribute('alt');
$item['title'] = 'Tbib | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
}
} }

View file

@ -1,41 +1,12 @@
<?php <?php
class XbooruBridge extends BridgeAbstract{ require_once('GelbooruBridge.php');
class XbooruBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai"; const MAINTAINER = "mitsukarenai";
const NAME = "Xbooru"; const NAME = "Xbooru";
const URI = "http://xbooru.com/"; const URI = "http://xbooru.com/";
const DESCRIPTION = "Returns images from given page"; const DESCRIPTION = "Returns images from given page";
const PARAMETERS = array( array( const PIDBYPAGE=50;
'p'=>array(
'name'=>'page',
'type'=>'number'
),
't'=>array('name'=>'tags')
));
public function collectData(){
$html = $this->getSimpleHTMLDOM(
self::URI.'index.php?page=post&s=list&'
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*50:'')
.'&tags='.urlencode($this->getInput('t'))
) or $this->returnServerError('Could not request Xbooru.');
foreach($html->find('div[class=content] span') as $element) {
$item = array();
$item['uri'] = self::URI.$element->find('a', 0)->href;
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('id'));
$item['timestamp'] = time();
$thumbnailUri = $element->find('img', 0)->src;
$item['tags'] = $element->find('img', 0)->getAttribute('alt');
$item['title'] = 'Xbooru | '.$item['postid'];
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
$this->items[] = $item;
}
}
public function getCacheDuration(){
return 1800; // 30 minutes
}
} }