diff --git a/bridges/BooruprojectBridge.php b/bridges/BooruprojectBridge.php index 635aae5..b6df665 100644 --- a/bridges/BooruprojectBridge.php +++ b/bridges/BooruprojectBridge.php @@ -1,48 +1,36 @@ array( - 'name'=>'instance (required)', - 'required'=>true - ), - 'p'=>array( - 'name'=>'page', - 'type'=>'number' - ), - 't'=>array('name'=>'tags') - )); + 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 + ) + ) + ); - function getURI(){ - return 'http://'.$this->getInput('i').'.booru.org/'; + const PIDBYPAGE=20; + + public function getURI(){ + return 'http://'.$this->getInput('i').'.booru.org/'; } - 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.'); - - - 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'] = '
Tags: '.$item['tags']; - $this->items[] = $item; - } - } - - 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 f612c98..25cd6a3 100644 --- a/bridges/GelbooruBridge.php +++ b/bridges/GelbooruBridge.php @@ -1,40 +1,21 @@ array( - 'name'=>'page', - 'type'=>'number' - ), - 't'=>array('name'=>'tags') - )); + const PATHTODATA='.thumb'; + const IDATTRIBUTE='id'; - 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 PIDBYPAGE=63; - 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'] = '
Tags: '.$item['tags']; - $this->items[] = $item; - } - } - - 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 821207e..96ae52a 100644 --- a/bridges/MspabooruBridge.php +++ b/bridges/MspabooruBridge.php @@ -1,42 +1,12 @@ 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'] = '
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 541184d..62a9e10 100644 --- a/bridges/Rule34Bridge.php +++ b/bridges/Rule34Bridge.php @@ -1,41 +1,12 @@ 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'] = '
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 d27702c..ea1c004 100644 --- a/bridges/SafebooruBridge.php +++ b/bridges/SafebooruBridge.php @@ -1,40 +1,12 @@ 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'] = '
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 1927a67..d9c2119 100644 --- a/bridges/TbibBridge.php +++ b/bridges/TbibBridge.php @@ -1,41 +1,12 @@ 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'] = '
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 a909b06..e0bd4e1 100644 --- a/bridges/XbooruBridge.php +++ b/bridges/XbooruBridge.php @@ -1,41 +1,12 @@ 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'] = '
Tags: '.$item['tags']; - $this->items[] = $item; - } - } - - public function getCacheDuration(){ - return 1800; // 30 minutes - } + const PIDBYPAGE=50; }