aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Pierre Mazière <pierre.maziere@gmx.com> 2016-09-04 01:19:54 +0200
committerGravatar Pierre Mazière <pierre.maziere@gmx.com> 2016-09-04 01:27:58 +0200
commit8ae05a024123bb1e9b11e213fd78bf93a40b1da1 (patch)
tree06348217feb9a3041a190de282b6520ca1fdf2ca
parent97926b839e51abf6d8e4ec616bc7231ecaac6da8 (diff)
downloadrss-bridge-8ae05a024123bb1e9b11e213fd78bf93a40b1da1.tar.gz
rss-bridge-8ae05a024123bb1e9b11e213fd78bf93a40b1da1.tar.zst
rss-bridge-8ae05a024123bb1e9b11e213fd78bf93a40b1da1.zip
[bridges] Gelbooru based imageboards derive form DanbooruBridge
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
-rw-r--r--bridges/BooruprojectBridge.php60
-rw-r--r--bridges/GelbooruBridge.php39
-rw-r--r--bridges/MspabooruBridge.php36
-rw-r--r--bridges/Rule34Bridge.php37
-rw-r--r--bridges/SafebooruBridge.php36
-rw-r--r--bridges/TbibBridge.php37
-rw-r--r--bridges/XbooruBridge.php37
7 files changed, 53 insertions, 229 deletions
diff --git a/bridges/BooruprojectBridge.php b/bridges/BooruprojectBridge.php
index 635aae55..b6df6654 100644
--- a/bridges/BooruprojectBridge.php
+++ b/bridges/BooruprojectBridge.php
@@ -1,48 +1,36 @@
<?php
-class BooruprojectBridge extends BridgeAbstract{
+require_once('GelbooruBridge.php');
+
+class BooruprojectBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai";
const NAME = "Booruproject";
const URI = "http://booru.org/";
- const DESCRIPTION = "Returns images from given page and booruproject instance (****.booru.org)";
-
- const PARAMETERS = array( array(
- 'i'=>array(
- 'name'=>'instance (required)',
- 'required'=>true
- ),
- 'p'=>array(
- 'name'=>'page',
- 'type'=>'number'
- ),
- 't'=>array('name'=>'tags')
- ));
-
- function getURI(){
- return 'http://'.$this->getInput('i').'.booru.org/';
- }
+ const DESCRIPTION = "Returns images from given page of booruproject";
- public function collectData(){
- $html = $this->getSimpleHTMLDOM(
- $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.');
+ const PARAMETERS = array(
+ 'global'=>array(
+ 'p'=>array(
+ 'name'=>'page',
+ 'type'=>'number'
+ ),
+ 't'=>array('name'=>'tags')
+ ),
+ 'Booru subdomain (subdomain.booru.org)'=>array(
+ 'i'=>array(
+ 'name'=>'Subdomain',
+ 'required'=>true
+ )
+ )
+ );
+ const PIDBYPAGE=20;
- 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 getURI(){
+ return 'http://'.$this->getInput('i').'.booru.org/';
}
- public function getCacheDuration(){
- return 1800; // 30 minutes
+ public function getName(){
+ return static::NAME . ' ' . $this->getInput('i');
}
}
diff --git a/bridges/GelbooruBridge.php b/bridges/GelbooruBridge.php
index f612c98c..25cd6a3a 100644
--- a/bridges/GelbooruBridge.php
+++ b/bridges/GelbooruBridge.php
@@ -1,40 +1,21 @@
<?php
-class GelbooruBridge extends BridgeAbstract{
+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 PARAMETERS = array( array(
- '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)*63:'')
- .'&tags='.urlencode($this->getInput('t'))
- ) or $this->returnServerError('Could not request Gelbooru.');
+ const PATHTODATA='.thumb';
+ const IDATTRIBUTE='id';
- 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'] = 'Gelbooru | '.$item['postid'];
- $item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
- $this->items[] = $item;
- }
- }
+ const PIDBYPAGE=63;
- public function getCacheDuration(){
- return 1800; // 30 minutes
+ 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'));
}
}
diff --git a/bridges/MspabooruBridge.php b/bridges/MspabooruBridge.php
index 821207e5..96ae52ad 100644
--- a/bridges/MspabooruBridge.php
+++ b/bridges/MspabooruBridge.php
@@ -1,42 +1,12 @@
<?php
-class MspabooruBridge extends BridgeAbstract{
+require_once('GelbooruBridge.php');
+class MspabooruBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai";
const NAME = "Mspabooru";
const URI = "http://mspabooru.com/";
const DESCRIPTION = "Returns images from given page";
- const PARAMETERS = array( array(
- '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
- }
+ const PIDBYPAGE=50;
}
diff --git a/bridges/Rule34Bridge.php b/bridges/Rule34Bridge.php
index 541184df..62a9e105 100644
--- a/bridges/Rule34Bridge.php
+++ b/bridges/Rule34Bridge.php
@@ -1,41 +1,12 @@
<?php
-class Rule34Bridge extends BridgeAbstract{
+require_once('GelbooruBridge.php');
+
+class Rule34Bridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai";
const NAME = "Rule34";
const URI = "http://rule34.xxx/";
const DESCRIPTION = "Returns images from given page";
- const PARAMETERS = array( array(
- '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
- }
+ const PIDBYPAGE=50;
}
diff --git a/bridges/SafebooruBridge.php b/bridges/SafebooruBridge.php
index d27702ce..ea1c0043 100644
--- a/bridges/SafebooruBridge.php
+++ b/bridges/SafebooruBridge.php
@@ -1,40 +1,12 @@
<?php
-class SafebooruBridge extends BridgeAbstract{
+require_once('GelbooruBridge.php');
+
+class SafebooruBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai";
const NAME = "Safebooru";
const URI = "http://safebooru.org/";
const DESCRIPTION = "Returns images from given page";
- const PARAMETERS = array( array(
- '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
- }
+ const PIDBYPAGE=40;
}
diff --git a/bridges/TbibBridge.php b/bridges/TbibBridge.php
index 1927a67c..d9c2119c 100644
--- a/bridges/TbibBridge.php
+++ b/bridges/TbibBridge.php
@@ -1,41 +1,12 @@
<?php
-class TbibBridge extends BridgeAbstract{
+require_once('GelbooruBridge.php');
+
+class TbibBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai";
const NAME = "Tbib";
const URI = "http://tbib.org/";
const DESCRIPTION = "Returns images from given page";
- const PARAMETERS = array( array(
- '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
- }
+ const PIDBYPAGE=50;
}
diff --git a/bridges/XbooruBridge.php b/bridges/XbooruBridge.php
index a909b068..e0bd4e18 100644
--- a/bridges/XbooruBridge.php
+++ b/bridges/XbooruBridge.php
@@ -1,41 +1,12 @@
<?php
-class XbooruBridge extends BridgeAbstract{
+require_once('GelbooruBridge.php');
+
+class XbooruBridge extends GelbooruBridge{
const MAINTAINER = "mitsukarenai";
const NAME = "Xbooru";
const URI = "http://xbooru.com/";
const DESCRIPTION = "Returns images from given page";
- const PARAMETERS = array( array(
- '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
- }
+ const PIDBYPAGE=50;
}